barraclough@apple.com | e367b00 | 2008-12-04 05:43:14 +0000 | [diff] [blame] | 1 | /* |
oliver@apple.com | c14eb7d | 2013-07-25 03:58:47 +0000 | [diff] [blame] | 2 | * Copyright (C) 2008, 2012, 2013 Apple Inc. All rights reserved. |
barraclough@apple.com | e367b00 | 2008-12-04 05:43:14 +0000 | [diff] [blame] | 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
mark.lam@apple.com | a4fe7ab | 2012-11-09 03:03:44 +0000 | [diff] [blame] | 26 | #ifndef JITInlines_h |
| 27 | #define JITInlines_h |
barraclough@apple.com | e367b00 | 2008-12-04 05:43:14 +0000 | [diff] [blame] | 28 | |
barraclough@apple.com | e367b00 | 2008-12-04 05:43:14 +0000 | [diff] [blame] | 29 | |
| 30 | #if ENABLE(JIT) |
| 31 | |
oliver@apple.com | c4c9b8a | 2013-07-25 04:02:09 +0000 | [diff] [blame] | 32 | #include "CallFrameInlines.h" |
| 33 | |
barraclough@apple.com | e367b00 | 2008-12-04 05:43:14 +0000 | [diff] [blame] | 34 | namespace JSC { |
| 35 | |
msaboff@apple.com | 7535bbd | 2013-09-10 06:01:03 +0000 | [diff] [blame] | 36 | ALWAYS_INLINE bool JIT::isOperandConstantImmediateDouble(int src) |
oliver@apple.com | 8d18163 | 2009-09-25 02:40:59 +0000 | [diff] [blame] | 37 | { |
| 38 | return m_codeBlock->isConstantRegisterIndex(src) && getConstantOperand(src).isDouble(); |
| 39 | } |
| 40 | |
msaboff@apple.com | 7535bbd | 2013-09-10 06:01:03 +0000 | [diff] [blame] | 41 | ALWAYS_INLINE JSValue JIT::getConstantOperand(int src) |
barraclough@apple.com | be1ce03 | 2009-01-02 03:06:10 +0000 | [diff] [blame] | 42 | { |
| 43 | ASSERT(m_codeBlock->isConstantRegisterIndex(src)); |
| 44 | return m_codeBlock->getConstant(src); |
| 45 | } |
| 46 | |
mark.lam@apple.com | 4fbb9c3 | 2012-10-09 07:12:56 +0000 | [diff] [blame] | 47 | ALWAYS_INLINE void JIT::emitPutIntToCallFrameHeader(RegisterID from, JSStack::CallFrameHeaderEntry entry) |
oliver@apple.com | 9d4f0ec | 2011-03-14 18:16:36 +0000 | [diff] [blame] | 48 | { |
yuqiang.xian@intel.com | 5b1cb73 | 2012-10-19 05:46:10 +0000 | [diff] [blame] | 49 | #if USE(JSVALUE32_64) |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 50 | store32(TrustedImm32(Int32Tag), intTagFor(entry, callFrameRegister)); |
oliver@apple.com | 9d4f0ec | 2011-03-14 18:16:36 +0000 | [diff] [blame] | 51 | store32(from, intPayloadFor(entry, callFrameRegister)); |
yuqiang.xian@intel.com | 5b1cb73 | 2012-10-19 05:46:10 +0000 | [diff] [blame] | 52 | #else |
| 53 | store64(from, addressFor(entry, callFrameRegister)); |
| 54 | #endif |
| 55 | } |
| 56 | |
mark.lam@apple.com | 4fbb9c3 | 2012-10-09 07:12:56 +0000 | [diff] [blame] | 57 | ALWAYS_INLINE void JIT::emitGetFromCallFrameHeaderPtr(JSStack::CallFrameHeaderEntry entry, RegisterID to, RegisterID from) |
barraclough@apple.com | e367b00 | 2008-12-04 05:43:14 +0000 | [diff] [blame] | 58 | { |
oliver@apple.com | e79807b | 2009-05-05 11:34:23 +0000 | [diff] [blame] | 59 | loadPtr(Address(from, entry * sizeof(Register)), to); |
oliver@apple.com | e79807b | 2009-05-05 11:34:23 +0000 | [diff] [blame] | 60 | } |
| 61 | |
yuqiang.xian@intel.com | 5b1cb73 | 2012-10-19 05:46:10 +0000 | [diff] [blame] | 62 | ALWAYS_INLINE void JIT::emitGetFromCallFrameHeader32(JSStack::CallFrameHeaderEntry entry, RegisterID to, RegisterID from) |
| 63 | { |
| 64 | load32(Address(from, entry * sizeof(Register)), to); |
yuqiang.xian@intel.com | 5b1cb73 | 2012-10-19 05:46:10 +0000 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | #if USE(JSVALUE64) |
| 68 | ALWAYS_INLINE void JIT::emitGetFromCallFrameHeader64(JSStack::CallFrameHeaderEntry entry, RegisterID to, RegisterID from) |
| 69 | { |
| 70 | load64(Address(from, entry * sizeof(Register)), to); |
yuqiang.xian@intel.com | 5b1cb73 | 2012-10-19 05:46:10 +0000 | [diff] [blame] | 71 | } |
| 72 | #endif |
| 73 | |
oliver@apple.com | 5230bd3 | 2010-05-06 19:39:54 +0000 | [diff] [blame] | 74 | ALWAYS_INLINE void JIT::emitLoadCharacterString(RegisterID src, RegisterID dst, JumpList& failures) |
| 75 | { |
ggaren@apple.com | 9a9a4b5 | 2013-04-18 19:32:17 +0000 | [diff] [blame] | 76 | failures.append(branchPtr(NotEqual, Address(src, JSCell::structureOffset()), TrustedImmPtr(m_vm->stringStructure.get()))); |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 77 | failures.append(branch32(NotEqual, MacroAssembler::Address(src, ThunkHelpers::jsStringLengthOffset()), TrustedImm32(1))); |
oliver@apple.com | 5230bd3 | 2010-05-06 19:39:54 +0000 | [diff] [blame] | 78 | loadPtr(MacroAssembler::Address(src, ThunkHelpers::jsStringValueOffset()), dst); |
ggaren@apple.com | ffbe44d | 2011-10-19 19:45:35 +0000 | [diff] [blame] | 79 | failures.append(branchTest32(Zero, dst)); |
benjamin@webkit.org | de409f7 | 2013-04-30 01:22:32 +0000 | [diff] [blame] | 80 | loadPtr(MacroAssembler::Address(dst, StringImpl::flagsOffset()), regT1); |
| 81 | loadPtr(MacroAssembler::Address(dst, StringImpl::dataOffset()), dst); |
msaboff@apple.com | a64c581 | 2011-10-28 01:09:53 +0000 | [diff] [blame] | 82 | |
| 83 | JumpList is16Bit; |
| 84 | JumpList cont8Bit; |
benjamin@webkit.org | de409f7 | 2013-04-30 01:22:32 +0000 | [diff] [blame] | 85 | is16Bit.append(branchTest32(Zero, regT1, TrustedImm32(StringImpl::flagIs8Bit()))); |
msaboff@apple.com | a64c581 | 2011-10-28 01:09:53 +0000 | [diff] [blame] | 86 | load8(MacroAssembler::Address(dst, 0), dst); |
| 87 | cont8Bit.append(jump()); |
| 88 | is16Bit.link(this); |
oliver@apple.com | 5230bd3 | 2010-05-06 19:39:54 +0000 | [diff] [blame] | 89 | load16(MacroAssembler::Address(dst, 0), dst); |
msaboff@apple.com | a64c581 | 2011-10-28 01:09:53 +0000 | [diff] [blame] | 90 | cont8Bit.link(this); |
oliver@apple.com | 5230bd3 | 2010-05-06 19:39:54 +0000 | [diff] [blame] | 91 | } |
| 92 | |
barraclough@apple.com | 97bacef | 2009-06-05 07:55:38 +0000 | [diff] [blame] | 93 | ALWAYS_INLINE JIT::Call JIT::emitNakedCall(CodePtr function) |
barraclough@apple.com | e367b00 | 2008-12-04 05:43:14 +0000 | [diff] [blame] | 94 | { |
ggaren@apple.com | 1ba4981 | 2010-05-19 18:28:54 +0000 | [diff] [blame] | 95 | ASSERT(m_bytecodeOffset != (unsigned)-1); // This method should only be called during hot/cold path generation, so that m_bytecodeOffset is set. |
barraclough@apple.com | 249befb | 2008-12-13 03:18:10 +0000 | [diff] [blame] | 96 | |
barraclough@apple.com | d7e1338 | 2009-02-19 22:51:40 +0000 | [diff] [blame] | 97 | Call nakedCall = nearCall(); |
ggaren@apple.com | 1ba4981 | 2010-05-19 18:28:54 +0000 | [diff] [blame] | 98 | m_calls.append(CallRecord(nakedCall, m_bytecodeOffset, function.executableAddress())); |
barraclough@apple.com | 8092415 | 2008-12-05 06:58:40 +0000 | [diff] [blame] | 99 | return nakedCall; |
barraclough@apple.com | e367b00 | 2008-12-04 05:43:14 +0000 | [diff] [blame] | 100 | } |
| 101 | |
commit-queue@webkit.org | 8481462 | 2011-08-25 01:25:38 +0000 | [diff] [blame] | 102 | ALWAYS_INLINE void JIT::updateTopCallFrame() |
| 103 | { |
oliver@apple.com | 8b234c9 | 2012-02-08 21:22:49 +0000 | [diff] [blame] | 104 | ASSERT(static_cast<int>(m_bytecodeOffset) >= 0); |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 105 | #if USE(JSVALUE32_64) |
oliver@apple.com | c4c9b8a | 2013-07-25 04:02:09 +0000 | [diff] [blame] | 106 | Instruction* instruction = m_codeBlock->instructions().begin() + m_bytecodeOffset + 1; |
| 107 | uint32_t locationBits = CallFrame::Location::encodeAsBytecodeInstruction(instruction); |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 108 | #else |
oliver@apple.com | c4c9b8a | 2013-07-25 04:02:09 +0000 | [diff] [blame] | 109 | uint32_t locationBits = CallFrame::Location::encodeAsBytecodeOffset(m_bytecodeOffset + 1); |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 110 | #endif |
oliver@apple.com | c4c9b8a | 2013-07-25 04:02:09 +0000 | [diff] [blame] | 111 | store32(TrustedImm32(locationBits), intTagFor(JSStack::ArgumentCount)); |
ggaren@apple.com | 9a9a4b5 | 2013-04-18 19:32:17 +0000 | [diff] [blame] | 112 | storePtr(callFrameRegister, &m_vm->topCallFrame); |
commit-queue@webkit.org | 8481462 | 2011-08-25 01:25:38 +0000 | [diff] [blame] | 113 | } |
| 114 | |
msaboff@apple.com | a482c54 | 2013-10-04 18:20:40 +0000 | [diff] [blame] | 115 | ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheck(const FunctionPtr& function) |
| 116 | { |
| 117 | updateTopCallFrame(); |
| 118 | MacroAssembler::Call call = appendCall(function); |
| 119 | exceptionCheck(); |
| 120 | return call; |
| 121 | } |
| 122 | |
msaboff@apple.com | 5ca16c4 | 2013-10-07 18:20:27 +0000 | [diff] [blame] | 123 | ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithCallFrameRollbackOnException(const FunctionPtr& function) |
| 124 | { |
| 125 | updateTopCallFrame(); // The callee is responsible for setting topCallFrame to their caller |
| 126 | MacroAssembler::Call call = appendCall(function); |
| 127 | exceptionCheckWithCallFrameRollback(); |
| 128 | return call; |
| 129 | } |
| 130 | |
msaboff@apple.com | a482c54 | 2013-10-04 18:20:40 +0000 | [diff] [blame] | 131 | ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheckSetJSValueResult(const FunctionPtr& function, int dst) |
| 132 | { |
| 133 | MacroAssembler::Call call = appendCallWithExceptionCheck(function); |
| 134 | #if USE(JSVALUE64) |
mark.lam@apple.com | ab6b5eb | 2013-11-08 04:05:27 +0000 | [diff] [blame] | 135 | emitPutVirtualRegister(dst, returnValueGPR); |
msaboff@apple.com | a482c54 | 2013-10-04 18:20:40 +0000 | [diff] [blame] | 136 | #else |
mark.lam@apple.com | ab6b5eb | 2013-11-08 04:05:27 +0000 | [diff] [blame] | 137 | emitStore(dst, returnValueGPR2, returnValueGPR); |
msaboff@apple.com | a482c54 | 2013-10-04 18:20:40 +0000 | [diff] [blame] | 138 | #endif |
| 139 | return call; |
| 140 | } |
| 141 | |
fpizlo@apple.com | 1cfa0a9 | 2013-10-16 02:19:20 +0000 | [diff] [blame] | 142 | ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheckSetJSValueResultWithProfile(const FunctionPtr& function, int dst) |
| 143 | { |
| 144 | MacroAssembler::Call call = appendCallWithExceptionCheck(function); |
fpizlo@apple.com | ba83364 | 2014-01-06 20:41:32 +0000 | [diff] [blame] | 145 | emitValueProfilingSite(); |
fpizlo@apple.com | 1cfa0a9 | 2013-10-16 02:19:20 +0000 | [diff] [blame] | 146 | #if USE(JSVALUE64) |
mark.lam@apple.com | ab6b5eb | 2013-11-08 04:05:27 +0000 | [diff] [blame] | 147 | emitPutVirtualRegister(dst, returnValueGPR); |
fpizlo@apple.com | 1cfa0a9 | 2013-10-16 02:19:20 +0000 | [diff] [blame] | 148 | #else |
mark.lam@apple.com | ab6b5eb | 2013-11-08 04:05:27 +0000 | [diff] [blame] | 149 | emitStore(dst, returnValueGPR2, returnValueGPR); |
fpizlo@apple.com | 1cfa0a9 | 2013-10-16 02:19:20 +0000 | [diff] [blame] | 150 | #endif |
| 151 | return call; |
| 152 | } |
| 153 | |
mark.lam@apple.com | 03944a0 | 2013-10-14 16:42:22 +0000 | [diff] [blame] | 154 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(C_JITOperation_E operation) |
| 155 | { |
| 156 | setupArgumentsExecState(); |
| 157 | return appendCallWithExceptionCheck(operation); |
| 158 | } |
| 159 | |
| 160 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(C_JITOperation_EO operation, GPRReg arg) |
| 161 | { |
| 162 | setupArgumentsWithExecState(arg); |
| 163 | return appendCallWithExceptionCheck(operation); |
| 164 | } |
| 165 | |
mark.lam@apple.com | 5d7e708 | 2013-10-11 19:03:39 +0000 | [diff] [blame] | 166 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(C_JITOperation_ESt operation, Structure* structure) |
| 167 | { |
| 168 | setupArgumentsWithExecState(TrustedImmPtr(structure)); |
| 169 | return appendCallWithExceptionCheck(operation); |
| 170 | } |
| 171 | |
mark.lam@apple.com | 03944a0 | 2013-10-14 16:42:22 +0000 | [diff] [blame] | 172 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(C_JITOperation_EZ operation, int32_t arg) |
| 173 | { |
| 174 | setupArgumentsWithExecState(TrustedImm32(arg)); |
| 175 | return appendCallWithExceptionCheck(operation); |
| 176 | } |
| 177 | |
msaboff@apple.com | a482c54 | 2013-10-04 18:20:40 +0000 | [diff] [blame] | 178 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(J_JITOperation_E operation, int dst) |
| 179 | { |
| 180 | setupArgumentsExecState(); |
| 181 | return appendCallWithExceptionCheckSetJSValueResult(operation, dst); |
| 182 | } |
| 183 | |
mark.lam@apple.com | 5d7e708 | 2013-10-11 19:03:39 +0000 | [diff] [blame] | 184 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(J_JITOperation_EAapJcpZ operation, int dst, ArrayAllocationProfile* arg1, GPRReg arg2, int32_t arg3) |
| 185 | { |
| 186 | setupArgumentsWithExecState(TrustedImmPtr(arg1), arg2, TrustedImm32(arg3)); |
| 187 | return appendCallWithExceptionCheckSetJSValueResult(operation, dst); |
| 188 | } |
| 189 | |
| 190 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(J_JITOperation_EAapJcpZ operation, int dst, ArrayAllocationProfile* arg1, const JSValue* arg2, int32_t arg3) |
| 191 | { |
| 192 | setupArgumentsWithExecState(TrustedImmPtr(arg1), TrustedImmPtr(arg2), TrustedImm32(arg3)); |
| 193 | return appendCallWithExceptionCheckSetJSValueResult(operation, dst); |
| 194 | } |
| 195 | |
| 196 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(J_JITOperation_EC operation, int dst, JSCell* cell) |
| 197 | { |
| 198 | setupArgumentsWithExecState(TrustedImmPtr(cell)); |
| 199 | return appendCallWithExceptionCheckSetJSValueResult(operation, dst); |
| 200 | } |
| 201 | |
mhahnenberg@apple.com | 2ceb9d7 | 2013-12-20 00:49:58 +0000 | [diff] [blame] | 202 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(V_JITOperation_EC operation, JSCell* cell) |
| 203 | { |
| 204 | setupArgumentsWithExecState(TrustedImmPtr(cell)); |
| 205 | return appendCallWithExceptionCheck(operation); |
| 206 | } |
| 207 | |
msaboff@apple.com | a482c54 | 2013-10-04 18:20:40 +0000 | [diff] [blame] | 208 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(J_JITOperation_EP operation, int dst, void* pointer) |
| 209 | { |
| 210 | setupArgumentsWithExecState(TrustedImmPtr(pointer)); |
| 211 | return appendCallWithExceptionCheckSetJSValueResult(operation, dst); |
| 212 | } |
| 213 | |
fpizlo@apple.com | 1cfa0a9 | 2013-10-16 02:19:20 +0000 | [diff] [blame] | 214 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(WithProfileTag, J_JITOperation_EPc operation, int dst, Instruction* bytecodePC) |
mark.lam@apple.com | 2a90d90 | 2013-10-15 03:03:45 +0000 | [diff] [blame] | 215 | { |
| 216 | setupArgumentsWithExecState(TrustedImmPtr(bytecodePC)); |
fpizlo@apple.com | 1cfa0a9 | 2013-10-16 02:19:20 +0000 | [diff] [blame] | 217 | return appendCallWithExceptionCheckSetJSValueResultWithProfile(operation, dst); |
mark.lam@apple.com | 2a90d90 | 2013-10-15 03:03:45 +0000 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(J_JITOperation_EZ operation, int dst, int32_t arg) |
| 221 | { |
| 222 | setupArgumentsWithExecState(TrustedImm32(arg)); |
| 223 | return appendCallWithExceptionCheckSetJSValueResult(operation, dst); |
| 224 | } |
| 225 | |
msaboff@apple.com | 4b6250f | 2013-10-15 18:33:04 +0000 | [diff] [blame] | 226 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(P_JITOperation_EZ operation, int32_t op) |
| 227 | { |
| 228 | setupArgumentsWithExecState(TrustedImm32(op)); |
| 229 | return appendCallWithExceptionCheck(operation); |
| 230 | } |
| 231 | |
msaboff@apple.com | c8dd3f7 | 2013-10-10 23:10:40 +0000 | [diff] [blame] | 232 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(S_JITOperation_ECC operation, RegisterID regOp1, RegisterID regOp2) |
| 233 | { |
| 234 | setupArgumentsWithExecState(regOp1, regOp2); |
| 235 | return appendCallWithExceptionCheck(operation); |
| 236 | } |
| 237 | |
msaboff@apple.com | c8dd3f7 | 2013-10-10 23:10:40 +0000 | [diff] [blame] | 238 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(S_JITOperation_EOJss operation, RegisterID regOp1, RegisterID regOp2) |
| 239 | { |
| 240 | setupArgumentsWithExecState(regOp1, regOp2); |
| 241 | return appendCallWithExceptionCheck(operation); |
| 242 | } |
| 243 | |
msaboff@apple.com | 4b6250f | 2013-10-15 18:33:04 +0000 | [diff] [blame] | 244 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(V_JITOperation_E operation) |
| 245 | { |
| 246 | setupArgumentsExecState(); |
| 247 | return appendCallWithExceptionCheck(operation); |
| 248 | } |
| 249 | |
msaboff@apple.com | 4b6250f | 2013-10-15 18:33:04 +0000 | [diff] [blame] | 250 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(V_JITOperation_EC operation, RegisterID regOp) |
| 251 | { |
| 252 | setupArgumentsWithExecState(regOp); |
| 253 | return appendCallWithExceptionCheck(operation); |
| 254 | } |
| 255 | |
| 256 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(V_JITOperation_ECC operation, RegisterID regOp1, RegisterID regOp2) |
| 257 | { |
| 258 | setupArgumentsWithExecState(regOp1, regOp2); |
| 259 | return appendCallWithExceptionCheck(operation); |
| 260 | } |
| 261 | |
mark.lam@apple.com | 2a90d90 | 2013-10-15 03:03:45 +0000 | [diff] [blame] | 262 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(V_JITOperation_EPc operation, Instruction* bytecodePC) |
| 263 | { |
| 264 | setupArgumentsWithExecState(TrustedImmPtr(bytecodePC)); |
| 265 | return appendCallWithExceptionCheck(operation); |
| 266 | } |
| 267 | |
msaboff@apple.com | 4b6250f | 2013-10-15 18:33:04 +0000 | [diff] [blame] | 268 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(V_JITOperation_EZ operation, int32_t op) |
| 269 | { |
| 270 | setupArgumentsWithExecState(TrustedImm32(op)); |
| 271 | return appendCallWithExceptionCheck(operation); |
| 272 | } |
| 273 | |
msaboff@apple.com | 2b95ada | 2013-10-09 13:29:00 +0000 | [diff] [blame] | 274 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperationWithCallFrameRollbackOnException(J_JITOperation_E operation) |
| 275 | { |
| 276 | setupArgumentsExecState(); |
| 277 | return appendCallWithCallFrameRollbackOnException(operation); |
| 278 | } |
| 279 | |
msaboff@apple.com | 5ca16c4 | 2013-10-07 18:20:27 +0000 | [diff] [blame] | 280 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperationWithCallFrameRollbackOnException(V_JITOperation_ECb operation, CodeBlock* pointer) |
msaboff@apple.com | a482c54 | 2013-10-04 18:20:40 +0000 | [diff] [blame] | 281 | { |
| 282 | setupArgumentsWithExecState(TrustedImmPtr(pointer)); |
msaboff@apple.com | 5ca16c4 | 2013-10-07 18:20:27 +0000 | [diff] [blame] | 283 | return appendCallWithCallFrameRollbackOnException(operation); |
msaboff@apple.com | a482c54 | 2013-10-04 18:20:40 +0000 | [diff] [blame] | 284 | } |
msaboff@apple.com | 5ca16c4 | 2013-10-07 18:20:27 +0000 | [diff] [blame] | 285 | |
| 286 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperationWithCallFrameRollbackOnException(Z_JITOperation_E operation) |
| 287 | { |
| 288 | setupArgumentsExecState(); |
| 289 | return appendCallWithCallFrameRollbackOnException(operation); |
| 290 | } |
| 291 | |
commit-queue@webkit.org | 54f3f2c | 2013-10-18 17:03:48 +0000 | [diff] [blame] | 292 | |
| 293 | #if USE(JSVALUE64) |
msaboff@apple.com | 75cc932 | 2013-12-06 21:38:26 +0000 | [diff] [blame] | 294 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(F_JITOperation_EJZ operation, GPRReg arg1, int32_t arg3) |
commit-queue@webkit.org | 54f3f2c | 2013-10-18 17:03:48 +0000 | [diff] [blame] | 295 | { |
msaboff@apple.com | 75cc932 | 2013-12-06 21:38:26 +0000 | [diff] [blame] | 296 | setupArgumentsWithExecState(arg1, TrustedImm32(arg3)); |
| 297 | return appendCallWithExceptionCheck(operation); |
| 298 | } |
| 299 | |
| 300 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(F_JITOperation_EFJJ operation, GPRReg arg1, GPRReg arg2, GPRReg arg3) |
| 301 | { |
| 302 | setupArgumentsWithExecState(arg1, arg2, arg3); |
commit-queue@webkit.org | 54f3f2c | 2013-10-18 17:03:48 +0000 | [diff] [blame] | 303 | return appendCallWithExceptionCheck(operation); |
| 304 | } |
| 305 | |
fpizlo@apple.com | d49bfe8 | 2013-10-19 02:20:14 +0000 | [diff] [blame] | 306 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(V_JITOperation_ESsiJJI operation, StructureStubInfo* stubInfo, RegisterID regOp1, RegisterID regOp2, StringImpl* uid) |
commit-queue@webkit.org | 54f3f2c | 2013-10-18 17:03:48 +0000 | [diff] [blame] | 307 | { |
fpizlo@apple.com | d49bfe8 | 2013-10-19 02:20:14 +0000 | [diff] [blame] | 308 | setupArgumentsWithExecState(TrustedImmPtr(stubInfo), regOp1, regOp2, TrustedImmPtr(uid)); |
commit-queue@webkit.org | 54f3f2c | 2013-10-18 17:03:48 +0000 | [diff] [blame] | 309 | return appendCallWithExceptionCheck(operation); |
| 310 | } |
| 311 | |
| 312 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(V_JITOperation_EJJJ operation, RegisterID regOp1, RegisterID regOp2, RegisterID regOp3) |
| 313 | { |
| 314 | setupArgumentsWithExecState(regOp1, regOp2, regOp3); |
| 315 | return appendCallWithExceptionCheck(operation); |
| 316 | } |
| 317 | |
fpizlo@apple.com | d49bfe8 | 2013-10-19 02:20:14 +0000 | [diff] [blame] | 318 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(JIT::WithProfileTag, J_JITOperation_ESsiJI operation, int dst, StructureStubInfo* stubInfo, GPRReg arg1, StringImpl* uid) |
commit-queue@webkit.org | 54f3f2c | 2013-10-18 17:03:48 +0000 | [diff] [blame] | 319 | { |
fpizlo@apple.com | d49bfe8 | 2013-10-19 02:20:14 +0000 | [diff] [blame] | 320 | setupArgumentsWithExecState(TrustedImmPtr(stubInfo), arg1, TrustedImmPtr(uid)); |
commit-queue@webkit.org | 54f3f2c | 2013-10-18 17:03:48 +0000 | [diff] [blame] | 321 | return appendCallWithExceptionCheckSetJSValueResultWithProfile(operation, dst); |
| 322 | } |
| 323 | |
| 324 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(JIT::WithProfileTag, J_JITOperation_EJJ operation, int dst, GPRReg arg1, GPRReg arg2) |
| 325 | { |
| 326 | setupArgumentsWithExecState(arg1, arg2); |
| 327 | return appendCallWithExceptionCheckSetJSValueResultWithProfile(operation, dst); |
| 328 | } |
| 329 | |
| 330 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(J_JITOperation_EAapJ operation, int dst, ArrayAllocationProfile* arg1, GPRReg arg2) |
| 331 | { |
| 332 | setupArgumentsWithExecState(TrustedImmPtr(arg1), arg2); |
| 333 | return appendCallWithExceptionCheckSetJSValueResult(operation, dst); |
| 334 | } |
| 335 | |
| 336 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(J_JITOperation_EJ operation, int dst, GPRReg arg1) |
| 337 | { |
| 338 | setupArgumentsWithExecState(arg1); |
| 339 | return appendCallWithExceptionCheckSetJSValueResult(operation, dst); |
| 340 | } |
| 341 | |
| 342 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(J_JITOperation_EJIdc operation, int dst, GPRReg arg1, const Identifier* arg2) |
| 343 | { |
| 344 | setupArgumentsWithExecState(arg1, TrustedImmPtr(arg2)); |
| 345 | return appendCallWithExceptionCheckSetJSValueResult(operation, dst); |
| 346 | } |
| 347 | |
| 348 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(J_JITOperation_EJJ operation, int dst, GPRReg arg1, GPRReg arg2) |
| 349 | { |
| 350 | setupArgumentsWithExecState(arg1, arg2); |
| 351 | return appendCallWithExceptionCheckSetJSValueResult(operation, dst); |
| 352 | } |
| 353 | |
| 354 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperationNoExceptionCheck(V_JITOperation_EJ operation, GPRReg arg1) |
| 355 | { |
| 356 | setupArgumentsWithExecState(arg1); |
| 357 | updateTopCallFrame(); |
| 358 | return appendCall(operation); |
| 359 | } |
| 360 | |
| 361 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(P_JITOperation_EJS operation, GPRReg arg1, size_t arg2) |
| 362 | { |
| 363 | setupArgumentsWithExecState(arg1, TrustedImmPtr(arg2)); |
| 364 | return appendCallWithExceptionCheck(operation); |
| 365 | } |
| 366 | |
| 367 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(S_JITOperation_EJ operation, RegisterID regOp) |
| 368 | { |
| 369 | setupArgumentsWithExecState(regOp); |
| 370 | return appendCallWithExceptionCheck(operation); |
| 371 | } |
| 372 | |
| 373 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(S_JITOperation_EJJ operation, RegisterID regOp1, RegisterID regOp2) |
| 374 | { |
| 375 | setupArgumentsWithExecState(regOp1, regOp2); |
| 376 | return appendCallWithExceptionCheck(operation); |
| 377 | } |
| 378 | |
| 379 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(V_JITOperation_EIdJZ operation, const Identifier* identOp1, RegisterID regOp2, int32_t op3) |
| 380 | { |
| 381 | setupArgumentsWithExecState(TrustedImmPtr(identOp1), regOp2, TrustedImm32(op3)); |
| 382 | return appendCallWithExceptionCheck(operation); |
| 383 | } |
| 384 | |
| 385 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(V_JITOperation_EJ operation, RegisterID regOp) |
| 386 | { |
| 387 | setupArgumentsWithExecState(regOp); |
| 388 | return appendCallWithExceptionCheck(operation); |
| 389 | } |
| 390 | |
| 391 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(V_JITOperation_EJIdJJ operation, RegisterID regOp1, const Identifier* identOp2, RegisterID regOp3, RegisterID regOp4) |
| 392 | { |
| 393 | setupArgumentsWithExecState(regOp1, TrustedImmPtr(identOp2), regOp3, regOp4); |
| 394 | return appendCallWithExceptionCheck(operation); |
| 395 | } |
| 396 | |
| 397 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(V_JITOperation_EJZ operation, RegisterID regOp1, int32_t op2) |
| 398 | { |
| 399 | setupArgumentsWithExecState(regOp1, TrustedImm32(op2)); |
| 400 | return appendCallWithExceptionCheck(operation); |
| 401 | } |
| 402 | |
| 403 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(V_JITOperation_EJZJ operation, RegisterID regOp1, int32_t op2, RegisterID regOp3) |
| 404 | { |
| 405 | setupArgumentsWithExecState(regOp1, TrustedImm32(op2), regOp3); |
| 406 | return appendCallWithExceptionCheck(operation); |
| 407 | } |
| 408 | |
| 409 | #else // USE(JSVALUE32_64) |
msaboff@apple.com | c8dd3f7 | 2013-10-10 23:10:40 +0000 | [diff] [blame] | 410 | |
| 411 | // EncodedJSValue in JSVALUE32_64 is a 64-bit integer. When being compiled in ARM EABI, it must be aligned even-numbered register (r0, r2 or [sp]). |
| 412 | // To avoid assemblies from using wrong registers, let's occupy r1 or r3 with a dummy argument when necessary. |
| 413 | #if (COMPILER_SUPPORTS(EABI) && CPU(ARM)) || CPU(MIPS) |
| 414 | #define EABI_32BIT_DUMMY_ARG TrustedImm32(0), |
| 415 | #else |
| 416 | #define EABI_32BIT_DUMMY_ARG |
| 417 | #endif |
| 418 | |
| 419 | // JSVALUE32_64 is a 64-bit integer that cannot be put half in an argument register and half on stack when using SH4 architecture. |
commit-queue@webkit.org | 0d080f4 | 2013-10-15 22:23:49 +0000 | [diff] [blame] | 420 | // To avoid this, let's occupy the 4th argument register (r7) with a dummy argument when necessary. This must only be done when there |
| 421 | // is no other 32-bit value argument behind this 64-bit JSValue. |
msaboff@apple.com | c8dd3f7 | 2013-10-10 23:10:40 +0000 | [diff] [blame] | 422 | #if CPU(SH4) |
| 423 | #define SH4_32BIT_DUMMY_ARG TrustedImm32(0), |
| 424 | #else |
| 425 | #define SH4_32BIT_DUMMY_ARG |
| 426 | #endif |
| 427 | |
commit-queue@webkit.org | 54f3f2c | 2013-10-18 17:03:48 +0000 | [diff] [blame] | 428 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperationNoExceptionCheck(V_JITOperation_EJ operation, GPRReg arg1Tag, GPRReg arg1Payload) |
| 429 | { |
commit-queue@webkit.org | da99c7f | 2013-10-22 17:04:59 +0000 | [diff] [blame] | 430 | setupArgumentsWithExecState(EABI_32BIT_DUMMY_ARG arg1Payload, arg1Tag); |
commit-queue@webkit.org | 54f3f2c | 2013-10-18 17:03:48 +0000 | [diff] [blame] | 431 | updateTopCallFrame(); |
| 432 | return appendCall(operation); |
| 433 | } |
| 434 | |
msaboff@apple.com | 75cc932 | 2013-12-06 21:38:26 +0000 | [diff] [blame] | 435 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(F_JITOperation_EJZ operation, GPRReg arg1Tag, GPRReg arg1Payload, int32_t arg2) |
mark.lam@apple.com | 03944a0 | 2013-10-14 16:42:22 +0000 | [diff] [blame] | 436 | { |
commit-queue@webkit.org | 0d080f4 | 2013-10-15 22:23:49 +0000 | [diff] [blame] | 437 | #if CPU(SH4) |
| 438 | // We have to put arg3 in the 4th argument register (r7) as 64-bit value arg2 will be put on stack for sh4 architecure. |
msaboff@apple.com | 75cc932 | 2013-12-06 21:38:26 +0000 | [diff] [blame] | 439 | setupArgumentsWithExecState(arg1Payload, arg1Tag, TrustedImm32(arg2)); |
commit-queue@webkit.org | 0d080f4 | 2013-10-15 22:23:49 +0000 | [diff] [blame] | 440 | #else |
msaboff@apple.com | 75cc932 | 2013-12-06 21:38:26 +0000 | [diff] [blame] | 441 | setupArgumentsWithExecState(EABI_32BIT_DUMMY_ARG arg1Payload, arg1Tag, TrustedImm32(arg2)); |
commit-queue@webkit.org | 0d080f4 | 2013-10-15 22:23:49 +0000 | [diff] [blame] | 442 | #endif |
mark.lam@apple.com | 03944a0 | 2013-10-14 16:42:22 +0000 | [diff] [blame] | 443 | return appendCallWithExceptionCheck(operation); |
| 444 | } |
| 445 | |
msaboff@apple.com | 75cc932 | 2013-12-06 21:38:26 +0000 | [diff] [blame] | 446 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(F_JITOperation_EFJJ operation, GPRReg arg1, GPRReg arg2Tag, GPRReg arg2Payload, GPRReg arg3Tag, GPRReg arg3Payload) |
| 447 | { |
| 448 | setupArgumentsWithExecState(arg1, arg2Payload, arg2Tag, arg3Payload, arg3Tag); |
| 449 | return appendCallWithExceptionCheck(operation); |
| 450 | } |
| 451 | |
mark.lam@apple.com | 5d7e708 | 2013-10-11 19:03:39 +0000 | [diff] [blame] | 452 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(J_JITOperation_EAapJ operation, int dst, ArrayAllocationProfile* arg1, GPRReg arg2Tag, GPRReg arg2Payload) |
| 453 | { |
commit-queue@webkit.org | f857f1f | 2013-10-18 15:23:51 +0000 | [diff] [blame] | 454 | setupArgumentsWithExecState(TrustedImmPtr(arg1), arg2Payload, arg2Tag); |
mark.lam@apple.com | 5d7e708 | 2013-10-11 19:03:39 +0000 | [diff] [blame] | 455 | return appendCallWithExceptionCheckSetJSValueResult(operation, dst); |
| 456 | } |
| 457 | |
mark.lam@apple.com | 03944a0 | 2013-10-14 16:42:22 +0000 | [diff] [blame] | 458 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(J_JITOperation_EJ operation, int dst, GPRReg arg1Tag, GPRReg arg1Payload) |
| 459 | { |
| 460 | setupArgumentsWithExecState(EABI_32BIT_DUMMY_ARG arg1Payload, arg1Tag); |
| 461 | return appendCallWithExceptionCheckSetJSValueResult(operation, dst); |
| 462 | } |
| 463 | |
fpizlo@apple.com | d49bfe8 | 2013-10-19 02:20:14 +0000 | [diff] [blame] | 464 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(JIT::WithProfileTag, J_JITOperation_ESsiJI operation, int dst, StructureStubInfo* stubInfo, GPRReg arg1Tag, GPRReg arg1Payload, StringImpl* uid) |
fpizlo@apple.com | 1cfa0a9 | 2013-10-16 02:19:20 +0000 | [diff] [blame] | 465 | { |
fpizlo@apple.com | d49bfe8 | 2013-10-19 02:20:14 +0000 | [diff] [blame] | 466 | setupArgumentsWithExecState(TrustedImmPtr(stubInfo), arg1Payload, arg1Tag, TrustedImmPtr(uid)); |
fpizlo@apple.com | 1cfa0a9 | 2013-10-16 02:19:20 +0000 | [diff] [blame] | 467 | return appendCallWithExceptionCheckSetJSValueResultWithProfile(operation, dst); |
| 468 | } |
| 469 | |
mark.lam@apple.com | 03944a0 | 2013-10-14 16:42:22 +0000 | [diff] [blame] | 470 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(J_JITOperation_EJIdc operation, int dst, GPRReg arg1Tag, GPRReg arg1Payload, const Identifier* arg2) |
| 471 | { |
| 472 | setupArgumentsWithExecState(EABI_32BIT_DUMMY_ARG arg1Payload, arg1Tag, TrustedImmPtr(arg2)); |
| 473 | return appendCallWithExceptionCheckSetJSValueResult(operation, dst); |
| 474 | } |
| 475 | |
| 476 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(J_JITOperation_EJJ operation, int dst, GPRReg arg1Tag, GPRReg arg1Payload, GPRReg arg2Tag, GPRReg arg2Payload) |
| 477 | { |
| 478 | setupArgumentsWithExecState(EABI_32BIT_DUMMY_ARG arg1Payload, arg1Tag, SH4_32BIT_DUMMY_ARG arg2Payload, arg2Tag); |
| 479 | return appendCallWithExceptionCheckSetJSValueResult(operation, dst); |
| 480 | } |
| 481 | |
mark.lam@apple.com | 6529307 | 2013-10-17 07:20:20 +0000 | [diff] [blame] | 482 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(JIT::WithProfileTag, J_JITOperation_EJJ operation, int dst, GPRReg arg1Tag, GPRReg arg1Payload, GPRReg arg2Tag, GPRReg arg2Payload) |
| 483 | { |
| 484 | setupArgumentsWithExecState(EABI_32BIT_DUMMY_ARG arg1Payload, arg1Tag, SH4_32BIT_DUMMY_ARG arg2Payload, arg2Tag); |
| 485 | return appendCallWithExceptionCheckSetJSValueResultWithProfile(operation, dst); |
| 486 | } |
| 487 | |
mark.lam@apple.com | 2a90d90 | 2013-10-15 03:03:45 +0000 | [diff] [blame] | 488 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(P_JITOperation_EJS operation, GPRReg arg1Tag, GPRReg arg1Payload, size_t arg2) |
| 489 | { |
| 490 | setupArgumentsWithExecState(EABI_32BIT_DUMMY_ARG arg1Payload, arg1Tag, TrustedImmPtr(arg2)); |
| 491 | return appendCallWithExceptionCheck(operation); |
| 492 | } |
| 493 | |
msaboff@apple.com | c8dd3f7 | 2013-10-10 23:10:40 +0000 | [diff] [blame] | 494 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(S_JITOperation_EJ operation, RegisterID argTag, RegisterID argPayload) |
| 495 | { |
| 496 | setupArgumentsWithExecState(EABI_32BIT_DUMMY_ARG argPayload, argTag); |
| 497 | return appendCallWithExceptionCheck(operation); |
| 498 | } |
| 499 | |
| 500 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(S_JITOperation_EJJ operation, RegisterID arg1Tag, RegisterID arg1Payload, RegisterID arg2Tag, RegisterID arg2Payload) |
| 501 | { |
| 502 | setupArgumentsWithExecState(EABI_32BIT_DUMMY_ARG arg1Payload, arg1Tag, SH4_32BIT_DUMMY_ARG arg2Payload, arg2Tag); |
| 503 | return appendCallWithExceptionCheck(operation); |
| 504 | } |
| 505 | |
msaboff@apple.com | 4b6250f | 2013-10-15 18:33:04 +0000 | [diff] [blame] | 506 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(V_JITOperation_ECICC operation, RegisterID regOp1, const Identifier* identOp2, RegisterID regOp3, RegisterID regOp4) |
| 507 | { |
| 508 | setupArgumentsWithExecState(regOp1, TrustedImmPtr(identOp2), regOp3, regOp4); |
| 509 | return appendCallWithExceptionCheck(operation); |
| 510 | } |
| 511 | |
| 512 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(V_JITOperation_EJ operation, RegisterID regOp1Tag, RegisterID regOp1Payload) |
| 513 | { |
commit-queue@webkit.org | da99c7f | 2013-10-22 17:04:59 +0000 | [diff] [blame] | 514 | setupArgumentsWithExecState(EABI_32BIT_DUMMY_ARG regOp1Payload, regOp1Tag); |
msaboff@apple.com | 4b6250f | 2013-10-15 18:33:04 +0000 | [diff] [blame] | 515 | return appendCallWithExceptionCheck(operation); |
| 516 | } |
| 517 | |
| 518 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(V_JITOperation_EIdJZ operation, const Identifier* identOp1, RegisterID regOp2Tag, RegisterID regOp2Payload, int32_t op3) |
| 519 | { |
commit-queue@webkit.org | 0d080f4 | 2013-10-15 22:23:49 +0000 | [diff] [blame] | 520 | setupArgumentsWithExecState(TrustedImmPtr(identOp1), regOp2Payload, regOp2Tag, TrustedImm32(op3)); |
msaboff@apple.com | 4b6250f | 2013-10-15 18:33:04 +0000 | [diff] [blame] | 521 | return appendCallWithExceptionCheck(operation); |
| 522 | } |
| 523 | |
fpizlo@apple.com | d49bfe8 | 2013-10-19 02:20:14 +0000 | [diff] [blame] | 524 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(V_JITOperation_ESsiJJI operation, StructureStubInfo* stubInfo, RegisterID regOp1Tag, RegisterID regOp1Payload, RegisterID regOp2Tag, RegisterID regOp2Payload, StringImpl* uid) |
fpizlo@apple.com | d97d757 | 2013-10-14 18:39:45 +0000 | [diff] [blame] | 525 | { |
fpizlo@apple.com | d49bfe8 | 2013-10-19 02:20:14 +0000 | [diff] [blame] | 526 | setupArgumentsWithExecState(TrustedImmPtr(stubInfo), regOp1Payload, regOp1Tag, regOp2Payload, regOp2Tag, TrustedImmPtr(uid)); |
fpizlo@apple.com | d97d757 | 2013-10-14 18:39:45 +0000 | [diff] [blame] | 527 | return appendCallWithExceptionCheck(operation); |
| 528 | } |
| 529 | |
commit-queue@webkit.org | da99c7f | 2013-10-22 17:04:59 +0000 | [diff] [blame] | 530 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(V_JITOperation_EJJJ operation, RegisterID regOp1Tag, RegisterID regOp1Payload, RegisterID regOp2Tag, RegisterID regOp2Payload, RegisterID regOp3Tag, RegisterID regOp3Payload) |
msaboff@apple.com | 853b04f | 2013-10-17 01:23:56 +0000 | [diff] [blame] | 531 | { |
| 532 | setupArgumentsWithExecState(EABI_32BIT_DUMMY_ARG regOp1Payload, regOp1Tag, SH4_32BIT_DUMMY_ARG regOp2Payload, regOp2Tag, regOp3Payload, regOp3Tag); |
| 533 | return appendCallWithExceptionCheck(operation); |
| 534 | } |
| 535 | |
msaboff@apple.com | 4b6250f | 2013-10-15 18:33:04 +0000 | [diff] [blame] | 536 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(V_JITOperation_EJZ operation, RegisterID regOp1Tag, RegisterID regOp1Payload, int32_t op2) |
| 537 | { |
| 538 | setupArgumentsWithExecState(EABI_32BIT_DUMMY_ARG regOp1Payload, regOp1Tag, TrustedImm32(op2)); |
| 539 | return appendCallWithExceptionCheck(operation); |
| 540 | } |
| 541 | |
| 542 | ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(V_JITOperation_EJZJ operation, RegisterID regOp1Tag, RegisterID regOp1Payload, int32_t op2, RegisterID regOp3Tag, RegisterID regOp3Payload) |
| 543 | { |
commit-queue@webkit.org | e890e76 | 2013-11-25 15:28:45 +0000 | [diff] [blame] | 544 | setupArgumentsWithExecState(EABI_32BIT_DUMMY_ARG regOp1Payload, regOp1Tag, TrustedImm32(op2), EABI_32BIT_DUMMY_ARG regOp3Payload, regOp3Tag); |
msaboff@apple.com | 4b6250f | 2013-10-15 18:33:04 +0000 | [diff] [blame] | 545 | return appendCallWithExceptionCheck(operation); |
| 546 | } |
commit-queue@webkit.org | 54f3f2c | 2013-10-18 17:03:48 +0000 | [diff] [blame] | 547 | |
msaboff@apple.com | c8dd3f7 | 2013-10-10 23:10:40 +0000 | [diff] [blame] | 548 | #undef EABI_32BIT_DUMMY_ARG |
| 549 | #undef SH4_32BIT_DUMMY_ARG |
| 550 | |
| 551 | #endif // USE(JSVALUE32_64) |
| 552 | |
barraclough@apple.com | a2a2e13 | 2008-12-13 23:58:58 +0000 | [diff] [blame] | 553 | ALWAYS_INLINE JIT::Jump JIT::checkStructure(RegisterID reg, Structure* structure) |
barraclough@apple.com | e367b00 | 2008-12-04 05:43:14 +0000 | [diff] [blame] | 554 | { |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 555 | return branchPtr(NotEqual, Address(reg, JSCell::structureOffset()), TrustedImmPtr(structure)); |
barraclough@apple.com | e367b00 | 2008-12-04 05:43:14 +0000 | [diff] [blame] | 556 | } |
| 557 | |
barraclough@apple.com | 4f46a50 | 2008-12-13 01:39:38 +0000 | [diff] [blame] | 558 | ALWAYS_INLINE void JIT::linkSlowCaseIfNotJSCell(Vector<SlowCaseEntry>::iterator& iter, int vReg) |
barraclough@apple.com | e367b00 | 2008-12-04 05:43:14 +0000 | [diff] [blame] | 559 | { |
barraclough@apple.com | 4f46a50 | 2008-12-13 01:39:38 +0000 | [diff] [blame] | 560 | if (!m_codeBlock->isKnownNotImmediate(vReg)) |
| 561 | linkSlowCase(iter); |
barraclough@apple.com | e367b00 | 2008-12-04 05:43:14 +0000 | [diff] [blame] | 562 | } |
| 563 | |
barraclough@apple.com | a2a2e13 | 2008-12-13 23:58:58 +0000 | [diff] [blame] | 564 | ALWAYS_INLINE void JIT::addSlowCase(Jump jump) |
barraclough@apple.com | 249befb | 2008-12-13 03:18:10 +0000 | [diff] [blame] | 565 | { |
ggaren@apple.com | 1ba4981 | 2010-05-19 18:28:54 +0000 | [diff] [blame] | 566 | ASSERT(m_bytecodeOffset != (unsigned)-1); // This method should only be called during hot/cold path generation, so that m_bytecodeOffset is set. |
barraclough@apple.com | 249befb | 2008-12-13 03:18:10 +0000 | [diff] [blame] | 567 | |
ggaren@apple.com | 1ba4981 | 2010-05-19 18:28:54 +0000 | [diff] [blame] | 568 | m_slowCases.append(SlowCaseEntry(jump, m_bytecodeOffset)); |
barraclough@apple.com | 249befb | 2008-12-13 03:18:10 +0000 | [diff] [blame] | 569 | } |
| 570 | |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 571 | ALWAYS_INLINE void JIT::addSlowCase(JumpList jumpList) |
| 572 | { |
ggaren@apple.com | 1ba4981 | 2010-05-19 18:28:54 +0000 | [diff] [blame] | 573 | ASSERT(m_bytecodeOffset != (unsigned)-1); // This method should only be called during hot/cold path generation, so that m_bytecodeOffset is set. |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 574 | |
| 575 | const JumpList::JumpVector& jumpVector = jumpList.jumps(); |
| 576 | size_t size = jumpVector.size(); |
| 577 | for (size_t i = 0; i < size; ++i) |
ggaren@apple.com | 1ba4981 | 2010-05-19 18:28:54 +0000 | [diff] [blame] | 578 | m_slowCases.append(SlowCaseEntry(jumpVector[i], m_bytecodeOffset)); |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 579 | } |
| 580 | |
fpizlo@apple.com | 9b0b31e | 2011-09-19 22:27:38 +0000 | [diff] [blame] | 581 | ALWAYS_INLINE void JIT::addSlowCase() |
| 582 | { |
| 583 | ASSERT(m_bytecodeOffset != (unsigned)-1); // This method should only be called during hot/cold path generation, so that m_bytecodeOffset is set. |
| 584 | |
| 585 | Jump emptyJump; // Doing it this way to make Windows happy. |
| 586 | m_slowCases.append(SlowCaseEntry(emptyJump, m_bytecodeOffset)); |
| 587 | } |
| 588 | |
barraclough@apple.com | a2a2e13 | 2008-12-13 23:58:58 +0000 | [diff] [blame] | 589 | ALWAYS_INLINE void JIT::addJump(Jump jump, int relativeOffset) |
barraclough@apple.com | 249befb | 2008-12-13 03:18:10 +0000 | [diff] [blame] | 590 | { |
ggaren@apple.com | 1ba4981 | 2010-05-19 18:28:54 +0000 | [diff] [blame] | 591 | ASSERT(m_bytecodeOffset != (unsigned)-1); // This method should only be called during hot/cold path generation, so that m_bytecodeOffset is set. |
barraclough@apple.com | 249befb | 2008-12-13 03:18:10 +0000 | [diff] [blame] | 592 | |
ggaren@apple.com | 1ba4981 | 2010-05-19 18:28:54 +0000 | [diff] [blame] | 593 | m_jmpTable.append(JumpTable(jump, m_bytecodeOffset + relativeOffset)); |
barraclough@apple.com | 249befb | 2008-12-13 03:18:10 +0000 | [diff] [blame] | 594 | } |
| 595 | |
barraclough@apple.com | a2a2e13 | 2008-12-13 23:58:58 +0000 | [diff] [blame] | 596 | ALWAYS_INLINE void JIT::emitJumpSlowToHot(Jump jump, int relativeOffset) |
barraclough@apple.com | 249befb | 2008-12-13 03:18:10 +0000 | [diff] [blame] | 597 | { |
ggaren@apple.com | 1ba4981 | 2010-05-19 18:28:54 +0000 | [diff] [blame] | 598 | ASSERT(m_bytecodeOffset != (unsigned)-1); // This method should only be called during hot/cold path generation, so that m_bytecodeOffset is set. |
barraclough@apple.com | 249befb | 2008-12-13 03:18:10 +0000 | [diff] [blame] | 599 | |
ggaren@apple.com | 1ba4981 | 2010-05-19 18:28:54 +0000 | [diff] [blame] | 600 | jump.linkTo(m_labels[m_bytecodeOffset + relativeOffset], this); |
barraclough@apple.com | 249befb | 2008-12-13 03:18:10 +0000 | [diff] [blame] | 601 | } |
| 602 | |
barraclough@apple.com | b8bcc94 | 2011-09-07 17:55:50 +0000 | [diff] [blame] | 603 | ALWAYS_INLINE JIT::Jump JIT::emitJumpIfNotObject(RegisterID structureReg) |
| 604 | { |
weinig@apple.com | 58576b2 | 2011-09-16 21:34:20 +0000 | [diff] [blame] | 605 | return branch8(Below, Address(structureReg, Structure::typeInfoTypeOffset()), TrustedImm32(ObjectType)); |
barraclough@apple.com | b8bcc94 | 2011-09-07 17:55:50 +0000 | [diff] [blame] | 606 | } |
| 607 | |
barraclough@apple.com | 536c0db | 2009-05-12 06:21:56 +0000 | [diff] [blame] | 608 | #if ENABLE(SAMPLING_FLAGS) |
barraclough@apple.com | c32f32e | 2009-05-13 09:10:02 +0000 | [diff] [blame] | 609 | ALWAYS_INLINE void JIT::setSamplingFlag(int32_t flag) |
barraclough@apple.com | 536c0db | 2009-05-12 06:21:56 +0000 | [diff] [blame] | 610 | { |
| 611 | ASSERT(flag >= 1); |
| 612 | ASSERT(flag <= 32); |
barraclough@apple.com | 02dee5d | 2011-04-21 01:03:44 +0000 | [diff] [blame] | 613 | or32(TrustedImm32(1u << (flag - 1)), AbsoluteAddress(SamplingFlags::addressOfFlags())); |
barraclough@apple.com | 536c0db | 2009-05-12 06:21:56 +0000 | [diff] [blame] | 614 | } |
| 615 | |
barraclough@apple.com | c32f32e | 2009-05-13 09:10:02 +0000 | [diff] [blame] | 616 | ALWAYS_INLINE void JIT::clearSamplingFlag(int32_t flag) |
barraclough@apple.com | 536c0db | 2009-05-12 06:21:56 +0000 | [diff] [blame] | 617 | { |
| 618 | ASSERT(flag >= 1); |
| 619 | ASSERT(flag <= 32); |
barraclough@apple.com | 02dee5d | 2011-04-21 01:03:44 +0000 | [diff] [blame] | 620 | and32(TrustedImm32(~(1u << (flag - 1))), AbsoluteAddress(SamplingFlags::addressOfFlags())); |
barraclough@apple.com | c32f32e | 2009-05-13 09:10:02 +0000 | [diff] [blame] | 621 | } |
| 622 | #endif |
| 623 | |
| 624 | #if ENABLE(SAMPLING_COUNTERS) |
barraclough@apple.com | 6d410b0 | 2011-11-10 20:24:06 +0000 | [diff] [blame] | 625 | ALWAYS_INLINE void JIT::emitCount(AbstractSamplingCounter& counter, int32_t count) |
barraclough@apple.com | c32f32e | 2009-05-13 09:10:02 +0000 | [diff] [blame] | 626 | { |
barraclough@apple.com | 6d410b0 | 2011-11-10 20:24:06 +0000 | [diff] [blame] | 627 | add64(TrustedImm32(count), AbsoluteAddress(counter.addressOfCounter())); |
barraclough@apple.com | 536c0db | 2009-05-12 06:21:56 +0000 | [diff] [blame] | 628 | } |
| 629 | #endif |
| 630 | |
| 631 | #if ENABLE(OPCODE_SAMPLING) |
mjs@apple.com | cc66821 | 2010-01-04 11:38:56 +0000 | [diff] [blame] | 632 | #if CPU(X86_64) |
barraclough@apple.com | 536c0db | 2009-05-12 06:21:56 +0000 | [diff] [blame] | 633 | ALWAYS_INLINE void JIT::sampleInstruction(Instruction* instruction, bool inHostFunction) |
| 634 | { |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 635 | move(TrustedImmPtr(m_interpreter->sampler()->sampleSlot()), X86Registers::ecx); |
| 636 | storePtr(TrustedImmPtr(m_interpreter->sampler()->encodeSample(instruction, inHostFunction)), X86Registers::ecx); |
barraclough@apple.com | 536c0db | 2009-05-12 06:21:56 +0000 | [diff] [blame] | 637 | } |
| 638 | #else |
| 639 | ALWAYS_INLINE void JIT::sampleInstruction(Instruction* instruction, bool inHostFunction) |
| 640 | { |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 641 | storePtr(TrustedImmPtr(m_interpreter->sampler()->encodeSample(instruction, inHostFunction)), m_interpreter->sampler()->sampleSlot()); |
barraclough@apple.com | 536c0db | 2009-05-12 06:21:56 +0000 | [diff] [blame] | 642 | } |
| 643 | #endif |
| 644 | #endif |
| 645 | |
| 646 | #if ENABLE(CODEBLOCK_SAMPLING) |
mjs@apple.com | cc66821 | 2010-01-04 11:38:56 +0000 | [diff] [blame] | 647 | #if CPU(X86_64) |
barraclough@apple.com | 536c0db | 2009-05-12 06:21:56 +0000 | [diff] [blame] | 648 | ALWAYS_INLINE void JIT::sampleCodeBlock(CodeBlock* codeBlock) |
| 649 | { |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 650 | move(TrustedImmPtr(m_interpreter->sampler()->codeBlockSlot()), X86Registers::ecx); |
| 651 | storePtr(TrustedImmPtr(codeBlock), X86Registers::ecx); |
barraclough@apple.com | 536c0db | 2009-05-12 06:21:56 +0000 | [diff] [blame] | 652 | } |
| 653 | #else |
| 654 | ALWAYS_INLINE void JIT::sampleCodeBlock(CodeBlock* codeBlock) |
| 655 | { |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 656 | storePtr(TrustedImmPtr(codeBlock), m_interpreter->sampler()->codeBlockSlot()); |
barraclough@apple.com | 536c0db | 2009-05-12 06:21:56 +0000 | [diff] [blame] | 657 | } |
| 658 | #endif |
| 659 | #endif |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 660 | |
msaboff@apple.com | 7535bbd | 2013-09-10 06:01:03 +0000 | [diff] [blame] | 661 | ALWAYS_INLINE bool JIT::isOperandConstantImmediateChar(int src) |
oliver@apple.com | 5230bd3 | 2010-05-06 19:39:54 +0000 | [diff] [blame] | 662 | { |
| 663 | return m_codeBlock->isConstantRegisterIndex(src) && getConstantOperand(src).isString() && asString(getConstantOperand(src).asCell())->length() == 1; |
| 664 | } |
| 665 | |
ggaren@apple.com | c862eac | 2013-01-29 05:48:01 +0000 | [diff] [blame] | 666 | template<typename StructureType> |
| 667 | inline void JIT::emitAllocateJSObject(RegisterID allocator, StructureType structure, RegisterID result, RegisterID scratch) |
commit-queue@webkit.org | c9b19ab | 2011-07-18 18:55:48 +0000 | [diff] [blame] | 668 | { |
ggaren@apple.com | c862eac | 2013-01-29 05:48:01 +0000 | [diff] [blame] | 669 | loadPtr(Address(allocator, MarkedAllocator::offsetOfFreeListHead()), result); |
commit-queue@webkit.org | c9b19ab | 2011-07-18 18:55:48 +0000 | [diff] [blame] | 670 | addSlowCase(branchTestPtr(Zero, result)); |
oliver@apple.com | e843bc0 | 2011-08-05 20:03:19 +0000 | [diff] [blame] | 671 | |
commit-queue@webkit.org | c9b19ab | 2011-07-18 18:55:48 +0000 | [diff] [blame] | 672 | // remove the object from the free list |
ggaren@apple.com | c862eac | 2013-01-29 05:48:01 +0000 | [diff] [blame] | 673 | loadPtr(Address(result), scratch); |
| 674 | storePtr(scratch, Address(allocator, MarkedAllocator::offsetOfFreeListHead())); |
oliver@apple.com | e843bc0 | 2011-08-05 20:03:19 +0000 | [diff] [blame] | 675 | |
commit-queue@webkit.org | c9b19ab | 2011-07-18 18:55:48 +0000 | [diff] [blame] | 676 | // initialize the object's structure |
| 677 | storePtr(structure, Address(result, JSCell::structureOffset())); |
oliver@apple.com | e843bc0 | 2011-08-05 20:03:19 +0000 | [diff] [blame] | 678 | |
commit-queue@webkit.org | c9b19ab | 2011-07-18 18:55:48 +0000 | [diff] [blame] | 679 | // initialize the object's property storage pointer |
fpizlo@apple.com | d8dd053 | 2012-09-13 04:18:52 +0000 | [diff] [blame] | 680 | storePtr(TrustedImmPtr(0), Address(result, JSObject::butterflyOffset())); |
oliver@apple.com | e843bc0 | 2011-08-05 20:03:19 +0000 | [diff] [blame] | 681 | } |
| 682 | |
fpizlo@apple.com | ba83364 | 2014-01-06 20:41:32 +0000 | [diff] [blame] | 683 | inline void JIT::emitValueProfilingSite(ValueProfile* valueProfile) |
fpizlo@apple.com | 95a9f0d | 2011-08-20 02:17:49 +0000 | [diff] [blame] | 684 | { |
fpizlo@apple.com | 086d2af | 2011-12-21 02:29:15 +0000 | [diff] [blame] | 685 | ASSERT(shouldEmitProfiling()); |
| 686 | ASSERT(valueProfile); |
| 687 | |
fpizlo@apple.com | 95a9f0d | 2011-08-20 02:17:49 +0000 | [diff] [blame] | 688 | const RegisterID value = regT0; |
fpizlo@apple.com | 4043e81 | 2011-11-06 11:54:59 +0000 | [diff] [blame] | 689 | #if USE(JSVALUE32_64) |
| 690 | const RegisterID valueTag = regT1; |
| 691 | #endif |
fpizlo@apple.com | 95a9f0d | 2011-08-20 02:17:49 +0000 | [diff] [blame] | 692 | |
fpizlo@apple.com | ba83364 | 2014-01-06 20:41:32 +0000 | [diff] [blame] | 693 | // We're in a simple configuration: only one bucket, so we can just do a direct |
| 694 | // store. |
fpizlo@apple.com | 4043e81 | 2011-11-06 11:54:59 +0000 | [diff] [blame] | 695 | #if USE(JSVALUE64) |
fpizlo@apple.com | ba83364 | 2014-01-06 20:41:32 +0000 | [diff] [blame] | 696 | store64(value, valueProfile->m_buckets); |
fpizlo@apple.com | 4043e81 | 2011-11-06 11:54:59 +0000 | [diff] [blame] | 697 | #else |
fpizlo@apple.com | ba83364 | 2014-01-06 20:41:32 +0000 | [diff] [blame] | 698 | EncodedValueDescriptor* descriptor = bitwise_cast<EncodedValueDescriptor*>(valueProfile->m_buckets); |
| 699 | store32(value, &descriptor->asBits.payload); |
| 700 | store32(valueTag, &descriptor->asBits.tag); |
commit-queue@webkit.org | 387d2ec | 2011-10-09 10:19:23 +0000 | [diff] [blame] | 701 | #endif |
fpizlo@apple.com | 95a9f0d | 2011-08-20 02:17:49 +0000 | [diff] [blame] | 702 | } |
fpizlo@apple.com | 086d2af | 2011-12-21 02:29:15 +0000 | [diff] [blame] | 703 | |
fpizlo@apple.com | ba83364 | 2014-01-06 20:41:32 +0000 | [diff] [blame] | 704 | inline void JIT::emitValueProfilingSite(unsigned bytecodeOffset) |
fpizlo@apple.com | 086d2af | 2011-12-21 02:29:15 +0000 | [diff] [blame] | 705 | { |
| 706 | if (!shouldEmitProfiling()) |
| 707 | return; |
fpizlo@apple.com | ba83364 | 2014-01-06 20:41:32 +0000 | [diff] [blame] | 708 | emitValueProfilingSite(m_codeBlock->valueProfileForBytecodeOffset(bytecodeOffset)); |
fpizlo@apple.com | afcf904 | 2012-01-20 20:22:18 +0000 | [diff] [blame] | 709 | } |
| 710 | |
fpizlo@apple.com | ba83364 | 2014-01-06 20:41:32 +0000 | [diff] [blame] | 711 | inline void JIT::emitValueProfilingSite() |
fpizlo@apple.com | afcf904 | 2012-01-20 20:22:18 +0000 | [diff] [blame] | 712 | { |
fpizlo@apple.com | ba83364 | 2014-01-06 20:41:32 +0000 | [diff] [blame] | 713 | emitValueProfilingSite(m_bytecodeOffset); |
fpizlo@apple.com | 086d2af | 2011-12-21 02:29:15 +0000 | [diff] [blame] | 714 | } |
fpizlo@apple.com | c7be5be0 | 2012-09-17 19:07:32 +0000 | [diff] [blame] | 715 | |
| 716 | inline void JIT::emitArrayProfilingSite(RegisterID structureAndIndexingType, RegisterID scratch, ArrayProfile* arrayProfile) |
| 717 | { |
fpizlo@apple.com | 44e9ef4 | 2012-10-19 07:24:32 +0000 | [diff] [blame] | 718 | UNUSED_PARAM(scratch); // We had found this scratch register useful here before, so I will keep it for now. |
| 719 | |
fpizlo@apple.com | c7be5be0 | 2012-09-17 19:07:32 +0000 | [diff] [blame] | 720 | RegisterID structure = structureAndIndexingType; |
| 721 | RegisterID indexingType = structureAndIndexingType; |
| 722 | |
fpizlo@apple.com | 4d95ce6 | 2013-02-27 03:52:58 +0000 | [diff] [blame] | 723 | if (shouldEmitProfiling()) |
fpizlo@apple.com | c7be5be0 | 2012-09-17 19:07:32 +0000 | [diff] [blame] | 724 | storePtr(structure, arrayProfile->addressOfLastSeenStructure()); |
fpizlo@apple.com | 44e9ef4 | 2012-10-19 07:24:32 +0000 | [diff] [blame] | 725 | |
| 726 | load8(Address(structure, Structure::indexingTypeOffset()), indexingType); |
fpizlo@apple.com | c7be5be0 | 2012-09-17 19:07:32 +0000 | [diff] [blame] | 727 | } |
| 728 | |
| 729 | inline void JIT::emitArrayProfilingSiteForBytecodeIndex(RegisterID structureAndIndexingType, RegisterID scratch, unsigned bytecodeIndex) |
| 730 | { |
fpizlo@apple.com | c7be5be0 | 2012-09-17 19:07:32 +0000 | [diff] [blame] | 731 | emitArrayProfilingSite(structureAndIndexingType, scratch, m_codeBlock->getOrAddArrayProfile(bytecodeIndex)); |
fpizlo@apple.com | c7be5be0 | 2012-09-17 19:07:32 +0000 | [diff] [blame] | 732 | } |
fpizlo@apple.com | 95a9f0d | 2011-08-20 02:17:49 +0000 | [diff] [blame] | 733 | |
fpizlo@apple.com | 69e2784 | 2012-09-19 21:43:10 +0000 | [diff] [blame] | 734 | inline void JIT::emitArrayProfileStoreToHoleSpecialCase(ArrayProfile* arrayProfile) |
| 735 | { |
fpizlo@apple.com | 69e2784 | 2012-09-19 21:43:10 +0000 | [diff] [blame] | 736 | store8(TrustedImm32(1), arrayProfile->addressOfMayStoreToHole()); |
fpizlo@apple.com | 0e9910a | 2012-10-09 23:39:53 +0000 | [diff] [blame] | 737 | } |
| 738 | |
fpizlo@apple.com | 304fbca | 2012-12-17 21:38:51 +0000 | [diff] [blame] | 739 | inline void JIT::emitArrayProfileOutOfBoundsSpecialCase(ArrayProfile* arrayProfile) |
| 740 | { |
fpizlo@apple.com | 304fbca | 2012-12-17 21:38:51 +0000 | [diff] [blame] | 741 | store8(TrustedImm32(1), arrayProfile->addressOfOutOfBounds()); |
fpizlo@apple.com | 304fbca | 2012-12-17 21:38:51 +0000 | [diff] [blame] | 742 | } |
| 743 | |
fpizlo@apple.com | 75c91a7 | 2012-11-08 22:28:25 +0000 | [diff] [blame] | 744 | static inline bool arrayProfileSaw(ArrayModes arrayModes, IndexingType capability) |
fpizlo@apple.com | 0e9910a | 2012-10-09 23:39:53 +0000 | [diff] [blame] | 745 | { |
fpizlo@apple.com | 75c91a7 | 2012-11-08 22:28:25 +0000 | [diff] [blame] | 746 | return arrayModesInclude(arrayModes, capability); |
fpizlo@apple.com | 0e9910a | 2012-10-09 23:39:53 +0000 | [diff] [blame] | 747 | } |
| 748 | |
| 749 | inline JITArrayMode JIT::chooseArrayMode(ArrayProfile* profile) |
| 750 | { |
oliver@apple.com | d205666 | 2013-07-25 04:00:37 +0000 | [diff] [blame] | 751 | ConcurrentJITLocker locker(m_codeBlock->m_lock); |
oliver@apple.com | c14eb7d | 2013-07-25 03:58:47 +0000 | [diff] [blame] | 752 | profile->computeUpdatedPrediction(locker, m_codeBlock); |
| 753 | ArrayModes arrayModes = profile->observedArrayModes(locker); |
fpizlo@apple.com | 75c91a7 | 2012-11-08 22:28:25 +0000 | [diff] [blame] | 754 | if (arrayProfileSaw(arrayModes, DoubleShape)) |
| 755 | return JITDouble; |
| 756 | if (arrayProfileSaw(arrayModes, Int32Shape)) |
| 757 | return JITInt32; |
| 758 | if (arrayProfileSaw(arrayModes, ArrayStorageShape)) |
fpizlo@apple.com | 0e9910a | 2012-10-09 23:39:53 +0000 | [diff] [blame] | 759 | return JITArrayStorage; |
| 760 | return JITContiguous; |
fpizlo@apple.com | 69e2784 | 2012-09-19 21:43:10 +0000 | [diff] [blame] | 761 | } |
| 762 | |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 763 | #if USE(JSVALUE32_64) |
| 764 | |
ggaren@apple.com | e1e4591 | 2011-11-14 19:44:32 +0000 | [diff] [blame] | 765 | inline void JIT::emitLoadTag(int index, RegisterID tag) |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 766 | { |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 767 | if (m_codeBlock->isConstantRegisterIndex(index)) { |
| 768 | move(Imm32(getConstantOperand(index).tag()), tag); |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 769 | return; |
| 770 | } |
| 771 | |
| 772 | load32(tagFor(index), tag); |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 773 | } |
| 774 | |
ggaren@apple.com | e1e4591 | 2011-11-14 19:44:32 +0000 | [diff] [blame] | 775 | inline void JIT::emitLoadPayload(int index, RegisterID payload) |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 776 | { |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 777 | if (m_codeBlock->isConstantRegisterIndex(index)) { |
| 778 | move(Imm32(getConstantOperand(index).payload()), payload); |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 779 | return; |
| 780 | } |
| 781 | |
| 782 | load32(payloadFor(index), payload); |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 783 | } |
| 784 | |
| 785 | inline void JIT::emitLoad(const JSValue& v, RegisterID tag, RegisterID payload) |
| 786 | { |
| 787 | move(Imm32(v.payload()), payload); |
| 788 | move(Imm32(v.tag()), tag); |
| 789 | } |
| 790 | |
ggaren@apple.com | e1e4591 | 2011-11-14 19:44:32 +0000 | [diff] [blame] | 791 | inline void JIT::emitLoad(int index, RegisterID tag, RegisterID payload, RegisterID base) |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 792 | { |
oliver@apple.com | 903b0c0 | 2013-01-24 01:40:37 +0000 | [diff] [blame] | 793 | RELEASE_ASSERT(tag != payload); |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 794 | |
| 795 | if (base == callFrameRegister) { |
oliver@apple.com | 903b0c0 | 2013-01-24 01:40:37 +0000 | [diff] [blame] | 796 | RELEASE_ASSERT(payload != base); |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 797 | emitLoadPayload(index, payload); |
| 798 | emitLoadTag(index, tag); |
| 799 | return; |
| 800 | } |
| 801 | |
| 802 | if (payload == base) { // avoid stomping base |
| 803 | load32(tagFor(index, base), tag); |
| 804 | load32(payloadFor(index, base), payload); |
| 805 | return; |
| 806 | } |
| 807 | |
| 808 | load32(payloadFor(index, base), payload); |
| 809 | load32(tagFor(index, base), tag); |
| 810 | } |
| 811 | |
ggaren@apple.com | e1e4591 | 2011-11-14 19:44:32 +0000 | [diff] [blame] | 812 | inline void JIT::emitLoad2(int index1, RegisterID tag1, RegisterID payload1, int index2, RegisterID tag2, RegisterID payload2) |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 813 | { |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 814 | emitLoad(index2, tag2, payload2); |
| 815 | emitLoad(index1, tag1, payload1); |
| 816 | } |
| 817 | |
ggaren@apple.com | e1e4591 | 2011-11-14 19:44:32 +0000 | [diff] [blame] | 818 | inline void JIT::emitLoadDouble(int index, FPRegisterID value) |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 819 | { |
| 820 | if (m_codeBlock->isConstantRegisterIndex(index)) { |
oliver@apple.com | ba10bec | 2011-03-08 23:17:32 +0000 | [diff] [blame] | 821 | WriteBarrier<Unknown>& inConstantPool = m_codeBlock->constantRegister(index); |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 822 | loadDouble(&inConstantPool, value); |
| 823 | } else |
| 824 | loadDouble(addressFor(index), value); |
| 825 | } |
| 826 | |
ggaren@apple.com | e1e4591 | 2011-11-14 19:44:32 +0000 | [diff] [blame] | 827 | inline void JIT::emitLoadInt32ToDouble(int index, FPRegisterID value) |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 828 | { |
| 829 | if (m_codeBlock->isConstantRegisterIndex(index)) { |
oliver@apple.com | ba10bec | 2011-03-08 23:17:32 +0000 | [diff] [blame] | 830 | WriteBarrier<Unknown>& inConstantPool = m_codeBlock->constantRegister(index); |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 831 | char* bytePointer = reinterpret_cast<char*>(&inConstantPool); |
| 832 | convertInt32ToDouble(AbsoluteAddress(bytePointer + OBJECT_OFFSETOF(JSValue, u.asBits.payload)), value); |
| 833 | } else |
| 834 | convertInt32ToDouble(payloadFor(index), value); |
| 835 | } |
| 836 | |
ggaren@apple.com | e1e4591 | 2011-11-14 19:44:32 +0000 | [diff] [blame] | 837 | inline void JIT::emitStore(int index, RegisterID tag, RegisterID payload, RegisterID base) |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 838 | { |
| 839 | store32(payload, payloadFor(index, base)); |
| 840 | store32(tag, tagFor(index, base)); |
| 841 | } |
| 842 | |
ggaren@apple.com | e1e4591 | 2011-11-14 19:44:32 +0000 | [diff] [blame] | 843 | inline void JIT::emitStoreInt32(int index, RegisterID payload, bool indexIsInt32) |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 844 | { |
| 845 | store32(payload, payloadFor(index, callFrameRegister)); |
| 846 | if (!indexIsInt32) |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 847 | store32(TrustedImm32(JSValue::Int32Tag), tagFor(index, callFrameRegister)); |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 848 | } |
| 849 | |
ggaren@apple.com | e1e4591 | 2011-11-14 19:44:32 +0000 | [diff] [blame] | 850 | inline void JIT::emitStoreInt32(int index, TrustedImm32 payload, bool indexIsInt32) |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 851 | { |
| 852 | store32(payload, payloadFor(index, callFrameRegister)); |
| 853 | if (!indexIsInt32) |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 854 | store32(TrustedImm32(JSValue::Int32Tag), tagFor(index, callFrameRegister)); |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 855 | } |
| 856 | |
ggaren@apple.com | e1e4591 | 2011-11-14 19:44:32 +0000 | [diff] [blame] | 857 | inline void JIT::emitStoreCell(int index, RegisterID payload, bool indexIsCell) |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 858 | { |
| 859 | store32(payload, payloadFor(index, callFrameRegister)); |
| 860 | if (!indexIsCell) |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 861 | store32(TrustedImm32(JSValue::CellTag), tagFor(index, callFrameRegister)); |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 862 | } |
| 863 | |
ggaren@apple.com | e1e4591 | 2011-11-14 19:44:32 +0000 | [diff] [blame] | 864 | inline void JIT::emitStoreBool(int index, RegisterID payload, bool indexIsBool) |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 865 | { |
barraclough@apple.com | 5139edc | 2011-04-07 23:47:06 +0000 | [diff] [blame] | 866 | store32(payload, payloadFor(index, callFrameRegister)); |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 867 | if (!indexIsBool) |
barraclough@apple.com | 5139edc | 2011-04-07 23:47:06 +0000 | [diff] [blame] | 868 | store32(TrustedImm32(JSValue::BooleanTag), tagFor(index, callFrameRegister)); |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 869 | } |
| 870 | |
ggaren@apple.com | e1e4591 | 2011-11-14 19:44:32 +0000 | [diff] [blame] | 871 | inline void JIT::emitStoreDouble(int index, FPRegisterID value) |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 872 | { |
| 873 | storeDouble(value, addressFor(index)); |
| 874 | } |
| 875 | |
ggaren@apple.com | e1e4591 | 2011-11-14 19:44:32 +0000 | [diff] [blame] | 876 | inline void JIT::emitStore(int index, const JSValue constant, RegisterID base) |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 877 | { |
| 878 | store32(Imm32(constant.payload()), payloadFor(index, base)); |
| 879 | store32(Imm32(constant.tag()), tagFor(index, base)); |
| 880 | } |
| 881 | |
msaboff@apple.com | 7535bbd | 2013-09-10 06:01:03 +0000 | [diff] [blame] | 882 | ALWAYS_INLINE void JIT::emitInitRegister(int dst) |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 883 | { |
| 884 | emitStore(dst, jsUndefined()); |
| 885 | } |
| 886 | |
ggaren@apple.com | e1e4591 | 2011-11-14 19:44:32 +0000 | [diff] [blame] | 887 | inline void JIT::emitJumpSlowCaseIfNotJSCell(int virtualRegisterIndex) |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 888 | { |
oliver@apple.com | fc502ee | 2010-05-20 00:30:35 +0000 | [diff] [blame] | 889 | if (!m_codeBlock->isKnownNotImmediate(virtualRegisterIndex)) { |
| 890 | if (m_codeBlock->isConstantRegisterIndex(virtualRegisterIndex)) |
| 891 | addSlowCase(jump()); |
| 892 | else |
| 893 | addSlowCase(emitJumpIfNotJSCell(virtualRegisterIndex)); |
| 894 | } |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 895 | } |
| 896 | |
ggaren@apple.com | e1e4591 | 2011-11-14 19:44:32 +0000 | [diff] [blame] | 897 | inline void JIT::emitJumpSlowCaseIfNotJSCell(int virtualRegisterIndex, RegisterID tag) |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 898 | { |
oliver@apple.com | fc502ee | 2010-05-20 00:30:35 +0000 | [diff] [blame] | 899 | if (!m_codeBlock->isKnownNotImmediate(virtualRegisterIndex)) { |
| 900 | if (m_codeBlock->isConstantRegisterIndex(virtualRegisterIndex)) |
| 901 | addSlowCase(jump()); |
| 902 | else |
oliver@apple.com | be4e067 | 2011-03-28 17:14:57 +0000 | [diff] [blame] | 903 | addSlowCase(branch32(NotEqual, tag, TrustedImm32(JSValue::CellTag))); |
oliver@apple.com | fc502ee | 2010-05-20 00:30:35 +0000 | [diff] [blame] | 904 | } |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 905 | } |
| 906 | |
msaboff@apple.com | 7535bbd | 2013-09-10 06:01:03 +0000 | [diff] [blame] | 907 | ALWAYS_INLINE bool JIT::isOperandConstantImmediateInt(int src) |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 908 | { |
| 909 | return m_codeBlock->isConstantRegisterIndex(src) && getConstantOperand(src).isInt32(); |
| 910 | } |
| 911 | |
msaboff@apple.com | 7535bbd | 2013-09-10 06:01:03 +0000 | [diff] [blame] | 912 | ALWAYS_INLINE bool JIT::getOperandConstantImmediateInt(int op1, int op2, int& op, int32_t& constant) |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 913 | { |
| 914 | if (isOperandConstantImmediateInt(op1)) { |
| 915 | constant = getConstantOperand(op1).asInt32(); |
| 916 | op = op2; |
| 917 | return true; |
| 918 | } |
| 919 | |
| 920 | if (isOperandConstantImmediateInt(op2)) { |
| 921 | constant = getConstantOperand(op2).asInt32(); |
| 922 | op = op1; |
| 923 | return true; |
| 924 | } |
| 925 | |
| 926 | return false; |
| 927 | } |
| 928 | |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 929 | #else // USE(JSVALUE32_64) |
| 930 | |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 931 | // get arg puts an arg from the SF register array into a h/w register |
| 932 | ALWAYS_INLINE void JIT::emitGetVirtualRegister(int src, RegisterID dst) |
| 933 | { |
ggaren@apple.com | 1ba4981 | 2010-05-19 18:28:54 +0000 | [diff] [blame] | 934 | ASSERT(m_bytecodeOffset != (unsigned)-1); // This method should only be called during hot/cold path generation, so that m_bytecodeOffset is set. |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 935 | |
| 936 | // TODO: we want to reuse values that are already in registers if we can - add a register allocator! |
| 937 | if (m_codeBlock->isConstantRegisterIndex(src)) { |
| 938 | JSValue value = m_codeBlock->getConstant(src); |
oliver@apple.com | b2a14ec | 2012-03-08 01:07:34 +0000 | [diff] [blame] | 939 | if (!value.isNumber()) |
yuqiang.xian@intel.com | 5b1cb73 | 2012-10-19 05:46:10 +0000 | [diff] [blame] | 940 | move(TrustedImm64(JSValue::encode(value)), dst); |
oliver@apple.com | b2a14ec | 2012-03-08 01:07:34 +0000 | [diff] [blame] | 941 | else |
yuqiang.xian@intel.com | 5b1cb73 | 2012-10-19 05:46:10 +0000 | [diff] [blame] | 942 | move(Imm64(JSValue::encode(value)), dst); |
barraclough@apple.com | 4836c7a | 2011-05-01 22:20:59 +0000 | [diff] [blame] | 943 | return; |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 944 | } |
| 945 | |
yuqiang.xian@intel.com | 5b1cb73 | 2012-10-19 05:46:10 +0000 | [diff] [blame] | 946 | load64(Address(callFrameRegister, src * sizeof(Register)), dst); |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 947 | } |
| 948 | |
msaboff@apple.com | 62aa8b7 | 2013-09-26 22:53:54 +0000 | [diff] [blame] | 949 | ALWAYS_INLINE void JIT::emitGetVirtualRegister(VirtualRegister src, RegisterID dst) |
| 950 | { |
| 951 | emitGetVirtualRegister(src.offset(), dst); |
| 952 | } |
| 953 | |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 954 | ALWAYS_INLINE void JIT::emitGetVirtualRegisters(int src1, RegisterID dst1, int src2, RegisterID dst2) |
| 955 | { |
fpizlo@apple.com | 9a5ab80 | 2013-11-12 03:28:41 +0000 | [diff] [blame] | 956 | emitGetVirtualRegister(src1, dst1); |
| 957 | emitGetVirtualRegister(src2, dst2); |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 958 | } |
| 959 | |
msaboff@apple.com | 62aa8b7 | 2013-09-26 22:53:54 +0000 | [diff] [blame] | 960 | ALWAYS_INLINE void JIT::emitGetVirtualRegisters(VirtualRegister src1, RegisterID dst1, VirtualRegister src2, RegisterID dst2) |
| 961 | { |
| 962 | emitGetVirtualRegisters(src1.offset(), dst1, src2.offset(), dst2); |
| 963 | } |
| 964 | |
msaboff@apple.com | 7535bbd | 2013-09-10 06:01:03 +0000 | [diff] [blame] | 965 | ALWAYS_INLINE int32_t JIT::getConstantOperandImmediateInt(int src) |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 966 | { |
| 967 | return getConstantOperand(src).asInt32(); |
| 968 | } |
| 969 | |
msaboff@apple.com | 7535bbd | 2013-09-10 06:01:03 +0000 | [diff] [blame] | 970 | ALWAYS_INLINE bool JIT::isOperandConstantImmediateInt(int src) |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 971 | { |
| 972 | return m_codeBlock->isConstantRegisterIndex(src) && getConstantOperand(src).isInt32(); |
| 973 | } |
| 974 | |
msaboff@apple.com | 7535bbd | 2013-09-10 06:01:03 +0000 | [diff] [blame] | 975 | ALWAYS_INLINE void JIT::emitPutVirtualRegister(int dst, RegisterID from) |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 976 | { |
yuqiang.xian@intel.com | 5b1cb73 | 2012-10-19 05:46:10 +0000 | [diff] [blame] | 977 | store64(from, Address(callFrameRegister, dst * sizeof(Register))); |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 978 | } |
| 979 | |
msaboff@apple.com | 62aa8b7 | 2013-09-26 22:53:54 +0000 | [diff] [blame] | 980 | ALWAYS_INLINE void JIT::emitPutVirtualRegister(VirtualRegister dst, RegisterID from) |
| 981 | { |
| 982 | emitPutVirtualRegister(dst.offset(), from); |
| 983 | } |
| 984 | |
msaboff@apple.com | 7535bbd | 2013-09-10 06:01:03 +0000 | [diff] [blame] | 985 | ALWAYS_INLINE void JIT::emitInitRegister(int dst) |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 986 | { |
yuqiang.xian@intel.com | 5b1cb73 | 2012-10-19 05:46:10 +0000 | [diff] [blame] | 987 | store64(TrustedImm64(JSValue::encode(jsUndefined())), Address(callFrameRegister, dst * sizeof(Register))); |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 988 | } |
| 989 | |
| 990 | ALWAYS_INLINE JIT::Jump JIT::emitJumpIfJSCell(RegisterID reg) |
| 991 | { |
yuqiang.xian@intel.com | 5b1cb73 | 2012-10-19 05:46:10 +0000 | [diff] [blame] | 992 | return branchTest64(Zero, reg, tagMaskRegister); |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 993 | } |
| 994 | |
| 995 | ALWAYS_INLINE JIT::Jump JIT::emitJumpIfBothJSCells(RegisterID reg1, RegisterID reg2, RegisterID scratch) |
| 996 | { |
| 997 | move(reg1, scratch); |
yuqiang.xian@intel.com | 5b1cb73 | 2012-10-19 05:46:10 +0000 | [diff] [blame] | 998 | or64(reg2, scratch); |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 999 | return emitJumpIfJSCell(scratch); |
| 1000 | } |
| 1001 | |
| 1002 | ALWAYS_INLINE void JIT::emitJumpSlowCaseIfJSCell(RegisterID reg) |
| 1003 | { |
| 1004 | addSlowCase(emitJumpIfJSCell(reg)); |
| 1005 | } |
| 1006 | |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 1007 | ALWAYS_INLINE void JIT::emitJumpSlowCaseIfNotJSCell(RegisterID reg) |
| 1008 | { |
| 1009 | addSlowCase(emitJumpIfNotJSCell(reg)); |
| 1010 | } |
| 1011 | |
| 1012 | ALWAYS_INLINE void JIT::emitJumpSlowCaseIfNotJSCell(RegisterID reg, int vReg) |
| 1013 | { |
| 1014 | if (!m_codeBlock->isKnownNotImmediate(vReg)) |
| 1015 | emitJumpSlowCaseIfNotJSCell(reg); |
| 1016 | } |
| 1017 | |
ggaren@apple.com | e1e4591 | 2011-11-14 19:44:32 +0000 | [diff] [blame] | 1018 | inline void JIT::emitLoadDouble(int index, FPRegisterID value) |
oliver@apple.com | 8d18163 | 2009-09-25 02:40:59 +0000 | [diff] [blame] | 1019 | { |
| 1020 | if (m_codeBlock->isConstantRegisterIndex(index)) { |
oliver@apple.com | ba10bec | 2011-03-08 23:17:32 +0000 | [diff] [blame] | 1021 | WriteBarrier<Unknown>& inConstantPool = m_codeBlock->constantRegister(index); |
oliver@apple.com | 8d18163 | 2009-09-25 02:40:59 +0000 | [diff] [blame] | 1022 | loadDouble(&inConstantPool, value); |
| 1023 | } else |
| 1024 | loadDouble(addressFor(index), value); |
| 1025 | } |
| 1026 | |
ggaren@apple.com | e1e4591 | 2011-11-14 19:44:32 +0000 | [diff] [blame] | 1027 | inline void JIT::emitLoadInt32ToDouble(int index, FPRegisterID value) |
oliver@apple.com | 8d18163 | 2009-09-25 02:40:59 +0000 | [diff] [blame] | 1028 | { |
| 1029 | if (m_codeBlock->isConstantRegisterIndex(index)) { |
barraclough@apple.com | 8af7a53 | 2011-03-13 22:11:13 +0000 | [diff] [blame] | 1030 | ASSERT(isOperandConstantImmediateInt(index)); |
| 1031 | convertInt32ToDouble(Imm32(getConstantOperand(index).asInt32()), value); |
oliver@apple.com | 8d18163 | 2009-09-25 02:40:59 +0000 | [diff] [blame] | 1032 | } else |
| 1033 | convertInt32ToDouble(addressFor(index), value); |
| 1034 | } |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 1035 | |
| 1036 | ALWAYS_INLINE JIT::Jump JIT::emitJumpIfImmediateInteger(RegisterID reg) |
| 1037 | { |
yuqiang.xian@intel.com | 5b1cb73 | 2012-10-19 05:46:10 +0000 | [diff] [blame] | 1038 | return branch64(AboveOrEqual, reg, tagTypeNumberRegister); |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 1039 | } |
| 1040 | |
| 1041 | ALWAYS_INLINE JIT::Jump JIT::emitJumpIfNotImmediateInteger(RegisterID reg) |
| 1042 | { |
yuqiang.xian@intel.com | 5b1cb73 | 2012-10-19 05:46:10 +0000 | [diff] [blame] | 1043 | return branch64(Below, reg, tagTypeNumberRegister); |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 1044 | } |
| 1045 | |
| 1046 | ALWAYS_INLINE JIT::Jump JIT::emitJumpIfNotImmediateIntegers(RegisterID reg1, RegisterID reg2, RegisterID scratch) |
| 1047 | { |
| 1048 | move(reg1, scratch); |
yuqiang.xian@intel.com | 5b1cb73 | 2012-10-19 05:46:10 +0000 | [diff] [blame] | 1049 | and64(reg2, scratch); |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 1050 | return emitJumpIfNotImmediateInteger(scratch); |
| 1051 | } |
| 1052 | |
| 1053 | ALWAYS_INLINE void JIT::emitJumpSlowCaseIfNotImmediateInteger(RegisterID reg) |
| 1054 | { |
| 1055 | addSlowCase(emitJumpIfNotImmediateInteger(reg)); |
| 1056 | } |
| 1057 | |
| 1058 | ALWAYS_INLINE void JIT::emitJumpSlowCaseIfNotImmediateIntegers(RegisterID reg1, RegisterID reg2, RegisterID scratch) |
| 1059 | { |
| 1060 | addSlowCase(emitJumpIfNotImmediateIntegers(reg1, reg2, scratch)); |
| 1061 | } |
| 1062 | |
oliver@apple.com | 8d18163 | 2009-09-25 02:40:59 +0000 | [diff] [blame] | 1063 | ALWAYS_INLINE void JIT::emitJumpSlowCaseIfNotImmediateNumber(RegisterID reg) |
| 1064 | { |
| 1065 | addSlowCase(emitJumpIfNotImmediateNumber(reg)); |
| 1066 | } |
| 1067 | |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 1068 | ALWAYS_INLINE void JIT::emitFastArithReTagImmediate(RegisterID src, RegisterID dest) |
| 1069 | { |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 1070 | emitFastArithIntToImmNoCheck(src, dest); |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 1071 | } |
| 1072 | |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 1073 | ALWAYS_INLINE void JIT::emitTagAsBoolImmediate(RegisterID reg) |
| 1074 | { |
barraclough@apple.com | 560dde7 | 2011-04-11 22:18:30 +0000 | [diff] [blame] | 1075 | or32(TrustedImm32(static_cast<int32_t>(ValueFalse)), reg); |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 1076 | } |
| 1077 | |
ggaren@apple.com | 540d71a6 | 2009-07-30 20:57:44 +0000 | [diff] [blame] | 1078 | #endif // USE(JSVALUE32_64) |
| 1079 | |
| 1080 | } // namespace JSC |
| 1081 | |
barraclough@apple.com | e367b00 | 2008-12-04 05:43:14 +0000 | [diff] [blame] | 1082 | #endif // ENABLE(JIT) |
| 1083 | |
mark.lam@apple.com | a4fe7ab | 2012-11-09 03:03:44 +0000 | [diff] [blame] | 1084 | #endif // JITInlines_h |
| 1085 | |