| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // |
| 3 // Copyright IBM Corp. 2012, 2013. All rights reserved. |
| 4 // |
| 2 // Use of this source code is governed by a BSD-style license that can be | 5 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 6 // found in the LICENSE file. |
| 4 | 7 |
| 5 #include "src/v8.h" | 8 #include "src/v8.h" |
| 6 | 9 |
| 7 #if V8_TARGET_ARCH_ARM | 10 #if V8_TARGET_ARCH_PPC |
| 8 | 11 |
| 9 #include "src/base/bits.h" | 12 #include "src/base/bits.h" |
| 10 #include "src/bootstrapper.h" | 13 #include "src/bootstrapper.h" |
| 11 #include "src/code-stubs.h" | 14 #include "src/code-stubs.h" |
| 12 #include "src/codegen.h" | 15 #include "src/codegen.h" |
| 13 #include "src/ic/handler-compiler.h" | 16 #include "src/ic/handler-compiler.h" |
| 17 #include "src/ic/ic.h" |
| 14 #include "src/isolate.h" | 18 #include "src/isolate.h" |
| 15 #include "src/jsregexp.h" | 19 #include "src/jsregexp.h" |
| 16 #include "src/regexp-macro-assembler.h" | 20 #include "src/regexp-macro-assembler.h" |
| 17 #include "src/runtime.h" | 21 #include "src/runtime.h" |
| 18 | 22 |
| 19 namespace v8 { | 23 namespace v8 { |
| 20 namespace internal { | 24 namespace internal { |
| 21 | 25 |
| 22 | 26 |
| 23 static void InitializeArrayConstructorDescriptor( | 27 static void InitializeArrayConstructorDescriptor( |
| 24 Isolate* isolate, CodeStubDescriptor* descriptor, | 28 Isolate* isolate, CodeStubDescriptor* descriptor, |
| 25 int constant_stack_parameter_count) { | 29 int constant_stack_parameter_count) { |
| 26 Address deopt_handler = Runtime::FunctionForId( | 30 Address deopt_handler = |
| 27 Runtime::kArrayConstructor)->entry; | 31 Runtime::FunctionForId(Runtime::kArrayConstructor)->entry; |
| 28 | 32 |
| 29 if (constant_stack_parameter_count == 0) { | 33 if (constant_stack_parameter_count == 0) { |
| 30 descriptor->Initialize(deopt_handler, constant_stack_parameter_count, | 34 descriptor->Initialize(deopt_handler, constant_stack_parameter_count, |
| 31 JS_FUNCTION_STUB_MODE); | 35 JS_FUNCTION_STUB_MODE); |
| 32 } else { | 36 } else { |
| 33 descriptor->Initialize(r0, deopt_handler, constant_stack_parameter_count, | 37 descriptor->Initialize(r3, deopt_handler, constant_stack_parameter_count, |
| 34 JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS); | 38 JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS); |
| 35 } | 39 } |
| 36 } | 40 } |
| 37 | 41 |
| 38 | 42 |
| 39 static void InitializeInternalArrayConstructorDescriptor( | 43 static void InitializeInternalArrayConstructorDescriptor( |
| 40 Isolate* isolate, CodeStubDescriptor* descriptor, | 44 Isolate* isolate, CodeStubDescriptor* descriptor, |
| 41 int constant_stack_parameter_count) { | 45 int constant_stack_parameter_count) { |
| 42 Address deopt_handler = Runtime::FunctionForId( | 46 Address deopt_handler = |
| 43 Runtime::kInternalArrayConstructor)->entry; | 47 Runtime::FunctionForId(Runtime::kInternalArrayConstructor)->entry; |
| 44 | 48 |
| 45 if (constant_stack_parameter_count == 0) { | 49 if (constant_stack_parameter_count == 0) { |
| 46 descriptor->Initialize(deopt_handler, constant_stack_parameter_count, | 50 descriptor->Initialize(deopt_handler, constant_stack_parameter_count, |
| 47 JS_FUNCTION_STUB_MODE); | 51 JS_FUNCTION_STUB_MODE); |
| 48 } else { | 52 } else { |
| 49 descriptor->Initialize(r0, deopt_handler, constant_stack_parameter_count, | 53 descriptor->Initialize(r3, deopt_handler, constant_stack_parameter_count, |
| 50 JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS); | 54 JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS); |
| 51 } | 55 } |
| 52 } | 56 } |
| 53 | 57 |
| 54 | 58 |
| 55 void ArrayNoArgumentConstructorStub::InitializeDescriptor( | 59 void ArrayNoArgumentConstructorStub::InitializeDescriptor( |
| 56 CodeStubDescriptor* descriptor) { | 60 CodeStubDescriptor* descriptor) { |
| 57 InitializeArrayConstructorDescriptor(isolate(), descriptor, 0); | 61 InitializeArrayConstructorDescriptor(isolate(), descriptor, 0); |
| 58 } | 62 } |
| 59 | 63 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 84 | 88 |
| 85 void InternalArrayNArgumentsConstructorStub::InitializeDescriptor( | 89 void InternalArrayNArgumentsConstructorStub::InitializeDescriptor( |
| 86 CodeStubDescriptor* descriptor) { | 90 CodeStubDescriptor* descriptor) { |
| 87 InitializeInternalArrayConstructorDescriptor(isolate(), descriptor, -1); | 91 InitializeInternalArrayConstructorDescriptor(isolate(), descriptor, -1); |
| 88 } | 92 } |
| 89 | 93 |
| 90 | 94 |
| 91 #define __ ACCESS_MASM(masm) | 95 #define __ ACCESS_MASM(masm) |
| 92 | 96 |
| 93 | 97 |
| 94 static void EmitIdenticalObjectComparison(MacroAssembler* masm, | 98 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow, |
| 95 Label* slow, | |
| 96 Condition cond); | 99 Condition cond); |
| 97 static void EmitSmiNonsmiComparison(MacroAssembler* masm, | 100 static void EmitSmiNonsmiComparison(MacroAssembler* masm, Register lhs, |
| 98 Register lhs, | 101 Register rhs, Label* lhs_not_nan, |
| 99 Register rhs, | 102 Label* slow, bool strict); |
| 100 Label* lhs_not_nan, | 103 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm, Register lhs, |
| 101 Label* slow, | |
| 102 bool strict); | |
| 103 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm, | |
| 104 Register lhs, | |
| 105 Register rhs); | 104 Register rhs); |
| 106 | 105 |
| 107 | 106 |
| 108 void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm, | 107 void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm, |
| 109 ExternalReference miss) { | 108 ExternalReference miss) { |
| 110 // Update the static counter each time a new code stub is generated. | 109 // Update the static counter each time a new code stub is generated. |
| 111 isolate()->counters()->code_stubs()->Increment(); | 110 isolate()->counters()->code_stubs()->Increment(); |
| 112 | 111 |
| 113 CallInterfaceDescriptor descriptor = GetCallInterfaceDescriptor(); | 112 CallInterfaceDescriptor descriptor = GetCallInterfaceDescriptor(); |
| 114 int param_count = descriptor.GetEnvironmentParameterCount(); | 113 int param_count = descriptor.GetEnvironmentParameterCount(); |
| 115 { | 114 { |
| 116 // Call the runtime system in a fresh internal frame. | 115 // Call the runtime system in a fresh internal frame. |
| 117 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 116 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
| 118 DCHECK(param_count == 0 || | 117 DCHECK(param_count == 0 || |
| 119 r0.is(descriptor.GetEnvironmentParameterRegister(param_count - 1))); | 118 r3.is(descriptor.GetEnvironmentParameterRegister(param_count - 1))); |
| 120 // Push arguments | 119 // Push arguments |
| 121 for (int i = 0; i < param_count; ++i) { | 120 for (int i = 0; i < param_count; ++i) { |
| 122 __ push(descriptor.GetEnvironmentParameterRegister(i)); | 121 __ push(descriptor.GetEnvironmentParameterRegister(i)); |
| 123 } | 122 } |
| 124 __ CallExternalReference(miss, param_count); | 123 __ CallExternalReference(miss, param_count); |
| 125 } | 124 } |
| 126 | 125 |
| 127 __ Ret(); | 126 __ Ret(); |
| 128 } | 127 } |
| 129 | 128 |
| 130 | 129 |
| 131 void DoubleToIStub::Generate(MacroAssembler* masm) { | 130 void DoubleToIStub::Generate(MacroAssembler* masm) { |
| 132 Label out_of_range, only_low, negate, done; | 131 Label out_of_range, only_low, negate, done, fastpath_done; |
| 133 Register input_reg = source(); | 132 Register input_reg = source(); |
| 134 Register result_reg = destination(); | 133 Register result_reg = destination(); |
| 135 DCHECK(is_truncating()); | 134 DCHECK(is_truncating()); |
| 136 | 135 |
| 137 int double_offset = offset(); | 136 int double_offset = offset(); |
| 138 // Account for saved regs if input is sp. | |
| 139 if (input_reg.is(sp)) double_offset += 3 * kPointerSize; | |
| 140 | 137 |
| 138 // Immediate values for this stub fit in instructions, so it's safe to use ip. |
| 141 Register scratch = GetRegisterThatIsNotOneOf(input_reg, result_reg); | 139 Register scratch = GetRegisterThatIsNotOneOf(input_reg, result_reg); |
| 142 Register scratch_low = | 140 Register scratch_low = |
| 143 GetRegisterThatIsNotOneOf(input_reg, result_reg, scratch); | 141 GetRegisterThatIsNotOneOf(input_reg, result_reg, scratch); |
| 144 Register scratch_high = | 142 Register scratch_high = |
| 145 GetRegisterThatIsNotOneOf(input_reg, result_reg, scratch, scratch_low); | 143 GetRegisterThatIsNotOneOf(input_reg, result_reg, scratch, scratch_low); |
| 146 LowDwVfpRegister double_scratch = kScratchDoubleReg; | 144 DoubleRegister double_scratch = kScratchDoubleReg; |
| 147 | 145 |
| 148 __ Push(scratch_high, scratch_low, scratch); | 146 __ push(scratch); |
| 147 // Account for saved regs if input is sp. |
| 148 if (input_reg.is(sp)) double_offset += kPointerSize; |
| 149 | 149 |
| 150 if (!skip_fastpath()) { | 150 if (!skip_fastpath()) { |
| 151 // Load double input. | 151 // Load double input. |
| 152 __ vldr(double_scratch, MemOperand(input_reg, double_offset)); | 152 __ lfd(double_scratch, MemOperand(input_reg, double_offset)); |
| 153 __ vmov(scratch_low, scratch_high, double_scratch); | |
| 154 | 153 |
| 155 // Do fast-path convert from double to int. | 154 // Do fast-path convert from double to int. |
| 156 __ vcvt_s32_f64(double_scratch.low(), double_scratch); | 155 __ ConvertDoubleToInt64(double_scratch, |
| 157 __ vmov(result_reg, double_scratch.low()); | 156 #if !V8_TARGET_ARCH_PPC64 |
| 157 scratch, |
| 158 #endif |
| 159 result_reg, d0); |
| 158 | 160 |
| 159 // If result is not saturated (0x7fffffff or 0x80000000), we are done. | 161 // Test for overflow |
| 160 __ sub(scratch, result_reg, Operand(1)); | 162 #if V8_TARGET_ARCH_PPC64 |
| 161 __ cmp(scratch, Operand(0x7ffffffe)); | 163 __ TestIfInt32(result_reg, scratch, r0); |
| 162 __ b(lt, &done); | 164 #else |
| 163 } else { | 165 __ TestIfInt32(scratch, result_reg, r0); |
| 164 // We've already done MacroAssembler::TryFastTruncatedDoubleToILoad, so we | 166 #endif |
| 165 // know exponent > 31, so we can skip the vcvt_s32_f64 which will saturate. | 167 __ beq(&fastpath_done); |
| 166 if (double_offset == 0) { | |
| 167 __ ldm(ia, input_reg, scratch_low.bit() | scratch_high.bit()); | |
| 168 } else { | |
| 169 __ ldr(scratch_low, MemOperand(input_reg, double_offset)); | |
| 170 __ ldr(scratch_high, MemOperand(input_reg, double_offset + kIntSize)); | |
| 171 } | |
| 172 } | 168 } |
| 173 | 169 |
| 174 __ Ubfx(scratch, scratch_high, | 170 __ Push(scratch_high, scratch_low); |
| 175 HeapNumber::kExponentShift, HeapNumber::kExponentBits); | 171 // Account for saved regs if input is sp. |
| 172 if (input_reg.is(sp)) double_offset += 2 * kPointerSize; |
| 173 |
| 174 __ lwz(scratch_high, |
| 175 MemOperand(input_reg, double_offset + Register::kExponentOffset)); |
| 176 __ lwz(scratch_low, |
| 177 MemOperand(input_reg, double_offset + Register::kMantissaOffset)); |
| 178 |
| 179 __ ExtractBitMask(scratch, scratch_high, HeapNumber::kExponentMask); |
| 176 // Load scratch with exponent - 1. This is faster than loading | 180 // Load scratch with exponent - 1. This is faster than loading |
| 177 // with exponent because Bias + 1 = 1024 which is an *ARM* immediate value. | 181 // with exponent because Bias + 1 = 1024 which is a *PPC* immediate value. |
| 178 STATIC_ASSERT(HeapNumber::kExponentBias + 1 == 1024); | 182 STATIC_ASSERT(HeapNumber::kExponentBias + 1 == 1024); |
| 179 __ sub(scratch, scratch, Operand(HeapNumber::kExponentBias + 1)); | 183 __ subi(scratch, scratch, Operand(HeapNumber::kExponentBias + 1)); |
| 180 // If exponent is greater than or equal to 84, the 32 less significant | 184 // If exponent is greater than or equal to 84, the 32 less significant |
| 181 // bits are 0s (2^84 = 1, 52 significant bits, 32 uncoded bits), | 185 // bits are 0s (2^84 = 1, 52 significant bits, 32 uncoded bits), |
| 182 // the result is 0. | 186 // the result is 0. |
| 183 // Compare exponent with 84 (compare exponent - 1 with 83). | 187 // Compare exponent with 84 (compare exponent - 1 with 83). |
| 184 __ cmp(scratch, Operand(83)); | 188 __ cmpi(scratch, Operand(83)); |
| 185 __ b(ge, &out_of_range); | 189 __ bge(&out_of_range); |
| 186 | 190 |
| 187 // If we reach this code, 31 <= exponent <= 83. | 191 // If we reach this code, 31 <= exponent <= 83. |
| 188 // So, we don't have to handle cases where 0 <= exponent <= 20 for | 192 // So, we don't have to handle cases where 0 <= exponent <= 20 for |
| 189 // which we would need to shift right the high part of the mantissa. | 193 // which we would need to shift right the high part of the mantissa. |
| 190 // Scratch contains exponent - 1. | 194 // Scratch contains exponent - 1. |
| 191 // Load scratch with 52 - exponent (load with 51 - (exponent - 1)). | 195 // Load scratch with 52 - exponent (load with 51 - (exponent - 1)). |
| 192 __ rsb(scratch, scratch, Operand(51), SetCC); | 196 __ subfic(scratch, scratch, Operand(51)); |
| 193 __ b(ls, &only_low); | 197 __ cmpi(scratch, Operand::Zero()); |
| 198 __ ble(&only_low); |
| 194 // 21 <= exponent <= 51, shift scratch_low and scratch_high | 199 // 21 <= exponent <= 51, shift scratch_low and scratch_high |
| 195 // to generate the result. | 200 // to generate the result. |
| 196 __ mov(scratch_low, Operand(scratch_low, LSR, scratch)); | 201 __ srw(scratch_low, scratch_low, scratch); |
| 197 // Scratch contains: 52 - exponent. | 202 // Scratch contains: 52 - exponent. |
| 198 // We needs: exponent - 20. | 203 // We needs: exponent - 20. |
| 199 // So we use: 32 - scratch = 32 - 52 + exponent = exponent - 20. | 204 // So we use: 32 - scratch = 32 - 52 + exponent = exponent - 20. |
| 200 __ rsb(scratch, scratch, Operand(32)); | 205 __ subfic(scratch, scratch, Operand(32)); |
| 201 __ Ubfx(result_reg, scratch_high, | 206 __ ExtractBitMask(result_reg, scratch_high, HeapNumber::kMantissaMask); |
| 202 0, HeapNumber::kMantissaBitsInTopWord); | |
| 203 // Set the implicit 1 before the mantissa part in scratch_high. | 207 // Set the implicit 1 before the mantissa part in scratch_high. |
| 204 __ orr(result_reg, result_reg, | 208 STATIC_ASSERT(HeapNumber::kMantissaBitsInTopWord >= 16); |
| 205 Operand(1 << HeapNumber::kMantissaBitsInTopWord)); | 209 __ oris(result_reg, result_reg, |
| 206 __ orr(result_reg, scratch_low, Operand(result_reg, LSL, scratch)); | 210 Operand(1 << ((HeapNumber::kMantissaBitsInTopWord) - 16))); |
| 211 __ slw(r0, result_reg, scratch); |
| 212 __ orx(result_reg, scratch_low, r0); |
| 207 __ b(&negate); | 213 __ b(&negate); |
| 208 | 214 |
| 209 __ bind(&out_of_range); | 215 __ bind(&out_of_range); |
| 210 __ mov(result_reg, Operand::Zero()); | 216 __ mov(result_reg, Operand::Zero()); |
| 211 __ b(&done); | 217 __ b(&done); |
| 212 | 218 |
| 213 __ bind(&only_low); | 219 __ bind(&only_low); |
| 214 // 52 <= exponent <= 83, shift only scratch_low. | 220 // 52 <= exponent <= 83, shift only scratch_low. |
| 215 // On entry, scratch contains: 52 - exponent. | 221 // On entry, scratch contains: 52 - exponent. |
| 216 __ rsb(scratch, scratch, Operand::Zero()); | 222 __ neg(scratch, scratch); |
| 217 __ mov(result_reg, Operand(scratch_low, LSL, scratch)); | 223 __ slw(result_reg, scratch_low, scratch); |
| 218 | 224 |
| 219 __ bind(&negate); | 225 __ bind(&negate); |
| 220 // If input was positive, scratch_high ASR 31 equals 0 and | 226 // If input was positive, scratch_high ASR 31 equals 0 and |
| 221 // scratch_high LSR 31 equals zero. | 227 // scratch_high LSR 31 equals zero. |
| 222 // New result = (result eor 0) + 0 = result. | 228 // New result = (result eor 0) + 0 = result. |
| 223 // If the input was negative, we have to negate the result. | 229 // If the input was negative, we have to negate the result. |
| 224 // Input_high ASR 31 equals 0xffffffff and scratch_high LSR 31 equals 1. | 230 // Input_high ASR 31 equals 0xffffffff and scratch_high LSR 31 equals 1. |
| 225 // New result = (result eor 0xffffffff) + 1 = 0 - result. | 231 // New result = (result eor 0xffffffff) + 1 = 0 - result. |
| 226 __ eor(result_reg, result_reg, Operand(scratch_high, ASR, 31)); | 232 __ srawi(r0, scratch_high, 31); |
| 227 __ add(result_reg, result_reg, Operand(scratch_high, LSR, 31)); | 233 #if V8_TARGET_ARCH_PPC64 |
| 234 __ srdi(r0, r0, Operand(32)); |
| 235 #endif |
| 236 __ xor_(result_reg, result_reg, r0); |
| 237 __ srwi(r0, scratch_high, Operand(31)); |
| 238 __ add(result_reg, result_reg, r0); |
| 228 | 239 |
| 229 __ bind(&done); | 240 __ bind(&done); |
| 241 __ Pop(scratch_high, scratch_low); |
| 230 | 242 |
| 231 __ Pop(scratch_high, scratch_low, scratch); | 243 __ bind(&fastpath_done); |
| 244 __ pop(scratch); |
| 245 |
| 232 __ Ret(); | 246 __ Ret(); |
| 233 } | 247 } |
| 234 | 248 |
| 235 | 249 |
| 250 #if 0 // more unused code, kept for easy compare to ARM |
| 236 void WriteInt32ToHeapNumberStub::GenerateFixedRegStubsAheadOfTime( | 251 void WriteInt32ToHeapNumberStub::GenerateFixedRegStubsAheadOfTime( |
| 237 Isolate* isolate) { | 252 Isolate* isolate) { |
| 238 WriteInt32ToHeapNumberStub stub1(isolate, r1, r0, r2); | 253 WriteInt32ToHeapNumberStub stub1(isolate, r1, r0, r2); |
| 239 WriteInt32ToHeapNumberStub stub2(isolate, r2, r0, r3); | 254 WriteInt32ToHeapNumberStub stub2(isolate, r2, r0, r3); |
| 240 stub1.GetCode(); | 255 stub1.GetCode(); |
| 241 stub2.GetCode(); | 256 stub2.GetCode(); |
| 242 } | 257 } |
| 243 | 258 |
| 244 | 259 |
| 245 // See comment for class. | 260 // See comment for class. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 // a double because it uses a sign bit instead of using two's complement. | 294 // a double because it uses a sign bit instead of using two's complement. |
| 280 // The actual mantissa bits stored are all 0 because the implicit most | 295 // The actual mantissa bits stored are all 0 because the implicit most |
| 281 // significant 1 bit is not stored. | 296 // significant 1 bit is not stored. |
| 282 non_smi_exponent += 1 << HeapNumber::kExponentShift; | 297 non_smi_exponent += 1 << HeapNumber::kExponentShift; |
| 283 __ mov(ip, Operand(HeapNumber::kSignMask | non_smi_exponent)); | 298 __ mov(ip, Operand(HeapNumber::kSignMask | non_smi_exponent)); |
| 284 __ str(ip, FieldMemOperand(the_heap_number(), HeapNumber::kExponentOffset)); | 299 __ str(ip, FieldMemOperand(the_heap_number(), HeapNumber::kExponentOffset)); |
| 285 __ mov(ip, Operand::Zero()); | 300 __ mov(ip, Operand::Zero()); |
| 286 __ str(ip, FieldMemOperand(the_heap_number(), HeapNumber::kMantissaOffset)); | 301 __ str(ip, FieldMemOperand(the_heap_number(), HeapNumber::kMantissaOffset)); |
| 287 __ Ret(); | 302 __ Ret(); |
| 288 } | 303 } |
| 289 | 304 #endif // roohack |
| 290 | 305 |
| 291 // Handle the case where the lhs and rhs are the same object. | 306 // Handle the case where the lhs and rhs are the same object. |
| 292 // Equality is almost reflexive (everything but NaN), so this is a test | 307 // Equality is almost reflexive (everything but NaN), so this is a test |
| 293 // for "identity and not NaN". | 308 // for "identity and not NaN". |
| 294 static void EmitIdenticalObjectComparison(MacroAssembler* masm, | 309 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow, |
| 295 Label* slow, | |
| 296 Condition cond) { | 310 Condition cond) { |
| 297 Label not_identical; | 311 Label not_identical; |
| 298 Label heap_number, return_equal; | 312 Label heap_number, return_equal; |
| 299 __ cmp(r0, r1); | 313 __ cmp(r3, r4); |
| 300 __ b(ne, ¬_identical); | 314 __ bne(¬_identical); |
| 301 | 315 |
| 302 // Test for NaN. Sadly, we can't just compare to Factory::nan_value(), | 316 // Test for NaN. Sadly, we can't just compare to Factory::nan_value(), |
| 303 // so we do the second best thing - test it ourselves. | 317 // so we do the second best thing - test it ourselves. |
| 304 // They are both equal and they are not both Smis so both of them are not | 318 // They are both equal and they are not both Smis so both of them are not |
| 305 // Smis. If it's not a heap number, then return equal. | 319 // Smis. If it's not a heap number, then return equal. |
| 306 if (cond == lt || cond == gt) { | 320 if (cond == lt || cond == gt) { |
| 307 __ CompareObjectType(r0, r4, r4, FIRST_SPEC_OBJECT_TYPE); | 321 __ CompareObjectType(r3, r7, r7, FIRST_SPEC_OBJECT_TYPE); |
| 308 __ b(ge, slow); | 322 __ bge(slow); |
| 309 } else { | 323 } else { |
| 310 __ CompareObjectType(r0, r4, r4, HEAP_NUMBER_TYPE); | 324 __ CompareObjectType(r3, r7, r7, HEAP_NUMBER_TYPE); |
| 311 __ b(eq, &heap_number); | 325 __ beq(&heap_number); |
| 312 // Comparing JS objects with <=, >= is complicated. | 326 // Comparing JS objects with <=, >= is complicated. |
| 313 if (cond != eq) { | 327 if (cond != eq) { |
| 314 __ cmp(r4, Operand(FIRST_SPEC_OBJECT_TYPE)); | 328 __ cmpi(r7, Operand(FIRST_SPEC_OBJECT_TYPE)); |
| 315 __ b(ge, slow); | 329 __ bge(slow); |
| 316 // Normally here we fall through to return_equal, but undefined is | 330 // Normally here we fall through to return_equal, but undefined is |
| 317 // special: (undefined == undefined) == true, but | 331 // special: (undefined == undefined) == true, but |
| 318 // (undefined <= undefined) == false! See ECMAScript 11.8.5. | 332 // (undefined <= undefined) == false! See ECMAScript 11.8.5. |
| 319 if (cond == le || cond == ge) { | 333 if (cond == le || cond == ge) { |
| 320 __ cmp(r4, Operand(ODDBALL_TYPE)); | 334 __ cmpi(r7, Operand(ODDBALL_TYPE)); |
| 321 __ b(ne, &return_equal); | 335 __ bne(&return_equal); |
| 322 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex); | 336 __ LoadRoot(r5, Heap::kUndefinedValueRootIndex); |
| 323 __ cmp(r0, r2); | 337 __ cmp(r3, r5); |
| 324 __ b(ne, &return_equal); | 338 __ bne(&return_equal); |
| 325 if (cond == le) { | 339 if (cond == le) { |
| 326 // undefined <= undefined should fail. | 340 // undefined <= undefined should fail. |
| 327 __ mov(r0, Operand(GREATER)); | 341 __ li(r3, Operand(GREATER)); |
| 328 } else { | 342 } else { |
| 329 // undefined >= undefined should fail. | 343 // undefined >= undefined should fail. |
| 330 __ mov(r0, Operand(LESS)); | 344 __ li(r3, Operand(LESS)); |
| 331 } | 345 } |
| 332 __ Ret(); | 346 __ Ret(); |
| 333 } | 347 } |
| 334 } | 348 } |
| 335 } | 349 } |
| 336 | 350 |
| 337 __ bind(&return_equal); | 351 __ bind(&return_equal); |
| 338 if (cond == lt) { | 352 if (cond == lt) { |
| 339 __ mov(r0, Operand(GREATER)); // Things aren't less than themselves. | 353 __ li(r3, Operand(GREATER)); // Things aren't less than themselves. |
| 340 } else if (cond == gt) { | 354 } else if (cond == gt) { |
| 341 __ mov(r0, Operand(LESS)); // Things aren't greater than themselves. | 355 __ li(r3, Operand(LESS)); // Things aren't greater than themselves. |
| 342 } else { | 356 } else { |
| 343 __ mov(r0, Operand(EQUAL)); // Things are <=, >=, ==, === themselves. | 357 __ li(r3, Operand(EQUAL)); // Things are <=, >=, ==, === themselves. |
| 344 } | 358 } |
| 345 __ Ret(); | 359 __ Ret(); |
| 346 | 360 |
| 347 // For less and greater we don't have to check for NaN since the result of | 361 // For less and greater we don't have to check for NaN since the result of |
| 348 // x < x is false regardless. For the others here is some code to check | 362 // x < x is false regardless. For the others here is some code to check |
| 349 // for NaN. | 363 // for NaN. |
| 350 if (cond != lt && cond != gt) { | 364 if (cond != lt && cond != gt) { |
| 351 __ bind(&heap_number); | 365 __ bind(&heap_number); |
| 352 // It is a heap number, so return non-equal if it's NaN and equal if it's | 366 // It is a heap number, so return non-equal if it's NaN and equal if it's |
| 353 // not NaN. | 367 // not NaN. |
| 354 | 368 |
| 355 // The representation of NaN values has all exponent bits (52..62) set, | 369 // The representation of NaN values has all exponent bits (52..62) set, |
| 356 // and not all mantissa bits (0..51) clear. | 370 // and not all mantissa bits (0..51) clear. |
| 357 // Read top bits of double representation (second word of value). | 371 // Read top bits of double representation (second word of value). |
| 358 __ ldr(r2, FieldMemOperand(r0, HeapNumber::kExponentOffset)); | 372 __ lwz(r5, FieldMemOperand(r3, HeapNumber::kExponentOffset)); |
| 359 // Test that exponent bits are all set. | 373 // Test that exponent bits are all set. |
| 360 __ Sbfx(r3, r2, HeapNumber::kExponentShift, HeapNumber::kExponentBits); | 374 STATIC_ASSERT(HeapNumber::kExponentMask == 0x7ff00000u); |
| 361 // NaNs have all-one exponents so they sign extend to -1. | 375 __ ExtractBitMask(r6, r5, HeapNumber::kExponentMask); |
| 362 __ cmp(r3, Operand(-1)); | 376 __ cmpli(r6, Operand(0x7ff)); |
| 363 __ b(ne, &return_equal); | 377 __ bne(&return_equal); |
| 364 | 378 |
| 365 // Shift out flag and all exponent bits, retaining only mantissa. | 379 // Shift out flag and all exponent bits, retaining only mantissa. |
| 366 __ mov(r2, Operand(r2, LSL, HeapNumber::kNonMantissaBitsInTopWord)); | 380 __ slwi(r5, r5, Operand(HeapNumber::kNonMantissaBitsInTopWord)); |
| 367 // Or with all low-bits of mantissa. | 381 // Or with all low-bits of mantissa. |
| 368 __ ldr(r3, FieldMemOperand(r0, HeapNumber::kMantissaOffset)); | 382 __ lwz(r6, FieldMemOperand(r3, HeapNumber::kMantissaOffset)); |
| 369 __ orr(r0, r3, Operand(r2), SetCC); | 383 __ orx(r3, r6, r5); |
| 370 // For equal we already have the right value in r0: Return zero (equal) | 384 __ cmpi(r3, Operand::Zero()); |
| 385 // For equal we already have the right value in r3: Return zero (equal) |
| 371 // if all bits in mantissa are zero (it's an Infinity) and non-zero if | 386 // if all bits in mantissa are zero (it's an Infinity) and non-zero if |
| 372 // not (it's a NaN). For <= and >= we need to load r0 with the failing | 387 // not (it's a NaN). For <= and >= we need to load r0 with the failing |
| 373 // value if it's a NaN. | 388 // value if it's a NaN. |
| 374 if (cond != eq) { | 389 if (cond != eq) { |
| 390 Label not_equal; |
| 391 __ bne(¬_equal); |
| 375 // All-zero means Infinity means equal. | 392 // All-zero means Infinity means equal. |
| 376 __ Ret(eq); | 393 __ Ret(); |
| 394 __ bind(¬_equal); |
| 377 if (cond == le) { | 395 if (cond == le) { |
| 378 __ mov(r0, Operand(GREATER)); // NaN <= NaN should fail. | 396 __ li(r3, Operand(GREATER)); // NaN <= NaN should fail. |
| 379 } else { | 397 } else { |
| 380 __ mov(r0, Operand(LESS)); // NaN >= NaN should fail. | 398 __ li(r3, Operand(LESS)); // NaN >= NaN should fail. |
| 381 } | 399 } |
| 382 } | 400 } |
| 383 __ Ret(); | 401 __ Ret(); |
| 384 } | 402 } |
| 385 // No fall through here. | 403 // No fall through here. |
| 386 | 404 |
| 387 __ bind(¬_identical); | 405 __ bind(¬_identical); |
| 388 } | 406 } |
| 389 | 407 |
| 390 | 408 |
| 391 // See comment at call site. | 409 // See comment at call site. |
| 392 static void EmitSmiNonsmiComparison(MacroAssembler* masm, | 410 static void EmitSmiNonsmiComparison(MacroAssembler* masm, Register lhs, |
| 393 Register lhs, | 411 Register rhs, Label* lhs_not_nan, |
| 394 Register rhs, | 412 Label* slow, bool strict) { |
| 395 Label* lhs_not_nan, | 413 DCHECK((lhs.is(r3) && rhs.is(r4)) || (lhs.is(r4) && rhs.is(r3))); |
| 396 Label* slow, | |
| 397 bool strict) { | |
| 398 DCHECK((lhs.is(r0) && rhs.is(r1)) || | |
| 399 (lhs.is(r1) && rhs.is(r0))); | |
| 400 | 414 |
| 401 Label rhs_is_smi; | 415 Label rhs_is_smi; |
| 402 __ JumpIfSmi(rhs, &rhs_is_smi); | 416 __ JumpIfSmi(rhs, &rhs_is_smi); |
| 403 | 417 |
| 404 // Lhs is a Smi. Check whether the rhs is a heap number. | 418 // Lhs is a Smi. Check whether the rhs is a heap number. |
| 405 __ CompareObjectType(rhs, r4, r4, HEAP_NUMBER_TYPE); | 419 __ CompareObjectType(rhs, r6, r7, HEAP_NUMBER_TYPE); |
| 406 if (strict) { | 420 if (strict) { |
| 407 // If rhs is not a number and lhs is a Smi then strict equality cannot | 421 // If rhs is not a number and lhs is a Smi then strict equality cannot |
| 408 // succeed. Return non-equal | 422 // succeed. Return non-equal |
| 409 // If rhs is r0 then there is already a non zero value in it. | 423 // If rhs is r3 then there is already a non zero value in it. |
| 410 if (!rhs.is(r0)) { | 424 Label skip; |
| 411 __ mov(r0, Operand(NOT_EQUAL), LeaveCC, ne); | 425 __ beq(&skip); |
| 426 if (!rhs.is(r3)) { |
| 427 __ mov(r3, Operand(NOT_EQUAL)); |
| 412 } | 428 } |
| 413 __ Ret(ne); | 429 __ Ret(); |
| 430 __ bind(&skip); |
| 414 } else { | 431 } else { |
| 415 // Smi compared non-strictly with a non-Smi non-heap-number. Call | 432 // Smi compared non-strictly with a non-Smi non-heap-number. Call |
| 416 // the runtime. | 433 // the runtime. |
| 417 __ b(ne, slow); | 434 __ bne(slow); |
| 418 } | 435 } |
| 419 | 436 |
| 420 // Lhs is a smi, rhs is a number. | 437 // Lhs is a smi, rhs is a number. |
| 421 // Convert lhs to a double in d7. | 438 // Convert lhs to a double in d7. |
| 422 __ SmiToDouble(d7, lhs); | 439 __ SmiToDouble(d7, lhs); |
| 423 // Load the double from rhs, tagged HeapNumber r0, to d6. | 440 // Load the double from rhs, tagged HeapNumber r3, to d6. |
| 424 __ vldr(d6, rhs, HeapNumber::kValueOffset - kHeapObjectTag); | 441 __ lfd(d6, FieldMemOperand(rhs, HeapNumber::kValueOffset)); |
| 425 | 442 |
| 426 // We now have both loaded as doubles but we can skip the lhs nan check | 443 // We now have both loaded as doubles but we can skip the lhs nan check |
| 427 // since it's a smi. | 444 // since it's a smi. |
| 428 __ jmp(lhs_not_nan); | 445 __ b(lhs_not_nan); |
| 429 | 446 |
| 430 __ bind(&rhs_is_smi); | 447 __ bind(&rhs_is_smi); |
| 431 // Rhs is a smi. Check whether the non-smi lhs is a heap number. | 448 // Rhs is a smi. Check whether the non-smi lhs is a heap number. |
| 432 __ CompareObjectType(lhs, r4, r4, HEAP_NUMBER_TYPE); | 449 __ CompareObjectType(lhs, r7, r7, HEAP_NUMBER_TYPE); |
| 433 if (strict) { | 450 if (strict) { |
| 434 // If lhs is not a number and rhs is a smi then strict equality cannot | 451 // If lhs is not a number and rhs is a smi then strict equality cannot |
| 435 // succeed. Return non-equal. | 452 // succeed. Return non-equal. |
| 436 // If lhs is r0 then there is already a non zero value in it. | 453 // If lhs is r3 then there is already a non zero value in it. |
| 437 if (!lhs.is(r0)) { | 454 Label skip; |
| 438 __ mov(r0, Operand(NOT_EQUAL), LeaveCC, ne); | 455 __ beq(&skip); |
| 456 if (!lhs.is(r3)) { |
| 457 __ mov(r3, Operand(NOT_EQUAL)); |
| 439 } | 458 } |
| 440 __ Ret(ne); | 459 __ Ret(); |
| 460 __ bind(&skip); |
| 441 } else { | 461 } else { |
| 442 // Smi compared non-strictly with a non-smi non-heap-number. Call | 462 // Smi compared non-strictly with a non-smi non-heap-number. Call |
| 443 // the runtime. | 463 // the runtime. |
| 444 __ b(ne, slow); | 464 __ bne(slow); |
| 445 } | 465 } |
| 446 | 466 |
| 447 // Rhs is a smi, lhs is a heap number. | 467 // Rhs is a smi, lhs is a heap number. |
| 448 // Load the double from lhs, tagged HeapNumber r1, to d7. | 468 // Load the double from lhs, tagged HeapNumber r4, to d7. |
| 449 __ vldr(d7, lhs, HeapNumber::kValueOffset - kHeapObjectTag); | 469 __ lfd(d7, FieldMemOperand(lhs, HeapNumber::kValueOffset)); |
| 450 // Convert rhs to a double in d6 . | 470 // Convert rhs to a double in d6. |
| 451 __ SmiToDouble(d6, rhs); | 471 __ SmiToDouble(d6, rhs); |
| 452 // Fall through to both_loaded_as_doubles. | 472 // Fall through to both_loaded_as_doubles. |
| 453 } | 473 } |
| 454 | 474 |
| 455 | 475 |
| 456 // See comment at call site. | 476 // See comment at call site. |
| 457 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm, | 477 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm, Register lhs, |
| 458 Register lhs, | |
| 459 Register rhs) { | 478 Register rhs) { |
| 460 DCHECK((lhs.is(r0) && rhs.is(r1)) || | 479 DCHECK((lhs.is(r3) && rhs.is(r4)) || (lhs.is(r4) && rhs.is(r3))); |
| 461 (lhs.is(r1) && rhs.is(r0))); | |
| 462 | 480 |
| 463 // If either operand is a JS object or an oddball value, then they are | 481 // If either operand is a JS object or an oddball value, then they are |
| 464 // not equal since their pointers are different. | 482 // not equal since their pointers are different. |
| 465 // There is no test for undetectability in strict equality. | 483 // There is no test for undetectability in strict equality. |
| 466 STATIC_ASSERT(LAST_TYPE == LAST_SPEC_OBJECT_TYPE); | 484 STATIC_ASSERT(LAST_TYPE == LAST_SPEC_OBJECT_TYPE); |
| 467 Label first_non_object; | 485 Label first_non_object; |
| 468 // Get the type of the first operand into r2 and compare it with | 486 // Get the type of the first operand into r5 and compare it with |
| 469 // FIRST_SPEC_OBJECT_TYPE. | 487 // FIRST_SPEC_OBJECT_TYPE. |
| 470 __ CompareObjectType(rhs, r2, r2, FIRST_SPEC_OBJECT_TYPE); | 488 __ CompareObjectType(rhs, r5, r5, FIRST_SPEC_OBJECT_TYPE); |
| 471 __ b(lt, &first_non_object); | 489 __ blt(&first_non_object); |
| 472 | 490 |
| 473 // Return non-zero (r0 is not zero) | 491 // Return non-zero (r3 is not zero) |
| 474 Label return_not_equal; | 492 Label return_not_equal; |
| 475 __ bind(&return_not_equal); | 493 __ bind(&return_not_equal); |
| 476 __ Ret(); | 494 __ Ret(); |
| 477 | 495 |
| 478 __ bind(&first_non_object); | 496 __ bind(&first_non_object); |
| 479 // Check for oddballs: true, false, null, undefined. | 497 // Check for oddballs: true, false, null, undefined. |
| 480 __ cmp(r2, Operand(ODDBALL_TYPE)); | 498 __ cmpi(r5, Operand(ODDBALL_TYPE)); |
| 481 __ b(eq, &return_not_equal); | 499 __ beq(&return_not_equal); |
| 482 | 500 |
| 483 __ CompareObjectType(lhs, r3, r3, FIRST_SPEC_OBJECT_TYPE); | 501 __ CompareObjectType(lhs, r6, r6, FIRST_SPEC_OBJECT_TYPE); |
| 484 __ b(ge, &return_not_equal); | 502 __ bge(&return_not_equal); |
| 485 | 503 |
| 486 // Check for oddballs: true, false, null, undefined. | 504 // Check for oddballs: true, false, null, undefined. |
| 487 __ cmp(r3, Operand(ODDBALL_TYPE)); | 505 __ cmpi(r6, Operand(ODDBALL_TYPE)); |
| 488 __ b(eq, &return_not_equal); | 506 __ beq(&return_not_equal); |
| 489 | 507 |
| 490 // Now that we have the types we might as well check for | 508 // Now that we have the types we might as well check for |
| 491 // internalized-internalized. | 509 // internalized-internalized. |
| 492 STATIC_ASSERT(kInternalizedTag == 0 && kStringTag == 0); | 510 STATIC_ASSERT(kInternalizedTag == 0 && kStringTag == 0); |
| 493 __ orr(r2, r2, Operand(r3)); | 511 __ orx(r5, r5, r6); |
| 494 __ tst(r2, Operand(kIsNotStringMask | kIsNotInternalizedMask)); | 512 __ andi(r0, r5, Operand(kIsNotStringMask | kIsNotInternalizedMask)); |
| 495 __ b(eq, &return_not_equal); | 513 __ beq(&return_not_equal, cr0); |
| 496 } | 514 } |
| 497 | 515 |
| 498 | 516 |
| 499 // See comment at call site. | 517 // See comment at call site. |
| 500 static void EmitCheckForTwoHeapNumbers(MacroAssembler* masm, | 518 static void EmitCheckForTwoHeapNumbers(MacroAssembler* masm, Register lhs, |
| 501 Register lhs, | |
| 502 Register rhs, | 519 Register rhs, |
| 503 Label* both_loaded_as_doubles, | 520 Label* both_loaded_as_doubles, |
| 504 Label* not_heap_numbers, | 521 Label* not_heap_numbers, Label* slow) { |
| 505 Label* slow) { | 522 DCHECK((lhs.is(r3) && rhs.is(r4)) || (lhs.is(r4) && rhs.is(r3))); |
| 506 DCHECK((lhs.is(r0) && rhs.is(r1)) || | |
| 507 (lhs.is(r1) && rhs.is(r0))); | |
| 508 | 523 |
| 509 __ CompareObjectType(rhs, r3, r2, HEAP_NUMBER_TYPE); | 524 __ CompareObjectType(rhs, r6, r5, HEAP_NUMBER_TYPE); |
| 510 __ b(ne, not_heap_numbers); | 525 __ bne(not_heap_numbers); |
| 511 __ ldr(r2, FieldMemOperand(lhs, HeapObject::kMapOffset)); | 526 __ LoadP(r5, FieldMemOperand(lhs, HeapObject::kMapOffset)); |
| 512 __ cmp(r2, r3); | 527 __ cmp(r5, r6); |
| 513 __ b(ne, slow); // First was a heap number, second wasn't. Go slow case. | 528 __ bne(slow); // First was a heap number, second wasn't. Go slow case. |
| 514 | 529 |
| 515 // Both are heap numbers. Load them up then jump to the code we have | 530 // Both are heap numbers. Load them up then jump to the code we have |
| 516 // for that. | 531 // for that. |
| 517 __ vldr(d6, rhs, HeapNumber::kValueOffset - kHeapObjectTag); | 532 __ lfd(d6, FieldMemOperand(rhs, HeapNumber::kValueOffset)); |
| 518 __ vldr(d7, lhs, HeapNumber::kValueOffset - kHeapObjectTag); | 533 __ lfd(d7, FieldMemOperand(lhs, HeapNumber::kValueOffset)); |
| 519 __ jmp(both_loaded_as_doubles); | 534 |
| 535 __ b(both_loaded_as_doubles); |
| 520 } | 536 } |
| 521 | 537 |
| 522 | 538 |
| 523 // Fast negative check for internalized-to-internalized equality. | 539 // Fast negative check for internalized-to-internalized equality. |
| 524 static void EmitCheckForInternalizedStringsOrObjects(MacroAssembler* masm, | 540 static void EmitCheckForInternalizedStringsOrObjects(MacroAssembler* masm, |
| 525 Register lhs, | 541 Register lhs, Register rhs, |
| 526 Register rhs, | |
| 527 Label* possible_strings, | 542 Label* possible_strings, |
| 528 Label* not_both_strings) { | 543 Label* not_both_strings) { |
| 529 DCHECK((lhs.is(r0) && rhs.is(r1)) || | 544 DCHECK((lhs.is(r3) && rhs.is(r4)) || (lhs.is(r4) && rhs.is(r3))); |
| 530 (lhs.is(r1) && rhs.is(r0))); | |
| 531 | 545 |
| 532 // r2 is object type of rhs. | 546 // r5 is object type of rhs. |
| 533 Label object_test; | 547 Label object_test; |
| 534 STATIC_ASSERT(kInternalizedTag == 0 && kStringTag == 0); | 548 STATIC_ASSERT(kInternalizedTag == 0 && kStringTag == 0); |
| 535 __ tst(r2, Operand(kIsNotStringMask)); | 549 __ andi(r0, r5, Operand(kIsNotStringMask)); |
| 536 __ b(ne, &object_test); | 550 __ bne(&object_test, cr0); |
| 537 __ tst(r2, Operand(kIsNotInternalizedMask)); | 551 __ andi(r0, r5, Operand(kIsNotInternalizedMask)); |
| 538 __ b(ne, possible_strings); | 552 __ bne(possible_strings, cr0); |
| 539 __ CompareObjectType(lhs, r3, r3, FIRST_NONSTRING_TYPE); | 553 __ CompareObjectType(lhs, r6, r6, FIRST_NONSTRING_TYPE); |
| 540 __ b(ge, not_both_strings); | 554 __ bge(not_both_strings); |
| 541 __ tst(r3, Operand(kIsNotInternalizedMask)); | 555 __ andi(r0, r6, Operand(kIsNotInternalizedMask)); |
| 542 __ b(ne, possible_strings); | 556 __ bne(possible_strings, cr0); |
| 543 | 557 |
| 544 // Both are internalized. We already checked they weren't the same pointer | 558 // Both are internalized. We already checked they weren't the same pointer |
| 545 // so they are not equal. | 559 // so they are not equal. |
| 546 __ mov(r0, Operand(NOT_EQUAL)); | 560 __ li(r3, Operand(NOT_EQUAL)); |
| 547 __ Ret(); | 561 __ Ret(); |
| 548 | 562 |
| 549 __ bind(&object_test); | 563 __ bind(&object_test); |
| 550 __ cmp(r2, Operand(FIRST_SPEC_OBJECT_TYPE)); | 564 __ cmpi(r5, Operand(FIRST_SPEC_OBJECT_TYPE)); |
| 551 __ b(lt, not_both_strings); | 565 __ blt(not_both_strings); |
| 552 __ CompareObjectType(lhs, r2, r3, FIRST_SPEC_OBJECT_TYPE); | 566 __ CompareObjectType(lhs, r5, r6, FIRST_SPEC_OBJECT_TYPE); |
| 553 __ b(lt, not_both_strings); | 567 __ blt(not_both_strings); |
| 554 // If both objects are undetectable, they are equal. Otherwise, they | 568 // If both objects are undetectable, they are equal. Otherwise, they |
| 555 // are not equal, since they are different objects and an object is not | 569 // are not equal, since they are different objects and an object is not |
| 556 // equal to undefined. | 570 // equal to undefined. |
| 557 __ ldr(r3, FieldMemOperand(rhs, HeapObject::kMapOffset)); | 571 __ LoadP(r6, FieldMemOperand(rhs, HeapObject::kMapOffset)); |
| 558 __ ldrb(r2, FieldMemOperand(r2, Map::kBitFieldOffset)); | 572 __ lbz(r5, FieldMemOperand(r5, Map::kBitFieldOffset)); |
| 559 __ ldrb(r3, FieldMemOperand(r3, Map::kBitFieldOffset)); | 573 __ lbz(r6, FieldMemOperand(r6, Map::kBitFieldOffset)); |
| 560 __ and_(r0, r2, Operand(r3)); | 574 __ and_(r3, r5, r6); |
| 561 __ and_(r0, r0, Operand(1 << Map::kIsUndetectable)); | 575 __ andi(r3, r3, Operand(1 << Map::kIsUndetectable)); |
| 562 __ eor(r0, r0, Operand(1 << Map::kIsUndetectable)); | 576 __ xori(r3, r3, Operand(1 << Map::kIsUndetectable)); |
| 563 __ Ret(); | 577 __ Ret(); |
| 564 } | 578 } |
| 565 | 579 |
| 566 | 580 |
| 567 static void CompareICStub_CheckInputType(MacroAssembler* masm, Register input, | 581 static void CompareICStub_CheckInputType(MacroAssembler* masm, Register input, |
| 568 Register scratch, | 582 Register scratch, |
| 569 CompareIC::State expected, | 583 CompareICState::State expected, |
| 570 Label* fail) { | 584 Label* fail) { |
| 571 Label ok; | 585 Label ok; |
| 572 if (expected == CompareIC::SMI) { | 586 if (expected == CompareICState::SMI) { |
| 573 __ JumpIfNotSmi(input, fail); | 587 __ JumpIfNotSmi(input, fail); |
| 574 } else if (expected == CompareIC::NUMBER) { | 588 } else if (expected == CompareICState::NUMBER) { |
| 575 __ JumpIfSmi(input, &ok); | 589 __ JumpIfSmi(input, &ok); |
| 576 __ CheckMap(input, scratch, Heap::kHeapNumberMapRootIndex, fail, | 590 __ CheckMap(input, scratch, Heap::kHeapNumberMapRootIndex, fail, |
| 577 DONT_DO_SMI_CHECK); | 591 DONT_DO_SMI_CHECK); |
| 578 } | 592 } |
| 579 // We could be strict about internalized/non-internalized here, but as long as | 593 // We could be strict about internalized/non-internalized here, but as long as |
| 580 // hydrogen doesn't care, the stub doesn't have to care either. | 594 // hydrogen doesn't care, the stub doesn't have to care either. |
| 581 __ bind(&ok); | 595 __ bind(&ok); |
| 582 } | 596 } |
| 583 | 597 |
| 584 | 598 |
| 585 // On entry r1 and r2 are the values to be compared. | 599 // On entry r4 and r5 are the values to be compared. |
| 586 // On exit r0 is 0, positive or negative to indicate the result of | 600 // On exit r3 is 0, positive or negative to indicate the result of |
| 587 // the comparison. | 601 // the comparison. |
| 588 void CompareICStub::GenerateGeneric(MacroAssembler* masm) { | 602 void CompareICStub::GenerateGeneric(MacroAssembler* masm) { |
| 589 Register lhs = r1; | 603 Register lhs = r4; |
| 590 Register rhs = r0; | 604 Register rhs = r3; |
| 591 Condition cc = GetCondition(); | 605 Condition cc = GetCondition(); |
| 592 | 606 |
| 593 Label miss; | 607 Label miss; |
| 594 CompareICStub_CheckInputType(masm, lhs, r2, left(), &miss); | 608 CompareICStub_CheckInputType(masm, lhs, r5, left(), &miss); |
| 595 CompareICStub_CheckInputType(masm, rhs, r3, right(), &miss); | 609 CompareICStub_CheckInputType(masm, rhs, r6, right(), &miss); |
| 596 | 610 |
| 597 Label slow; // Call builtin. | 611 Label slow; // Call builtin. |
| 598 Label not_smis, both_loaded_as_doubles, lhs_not_nan; | 612 Label not_smis, both_loaded_as_doubles, lhs_not_nan; |
| 599 | 613 |
| 600 Label not_two_smis, smi_done; | 614 Label not_two_smis, smi_done; |
| 601 __ orr(r2, r1, r0); | 615 __ orx(r5, r4, r3); |
| 602 __ JumpIfNotSmi(r2, ¬_two_smis); | 616 __ JumpIfNotSmi(r5, ¬_two_smis); |
| 603 __ mov(r1, Operand(r1, ASR, 1)); | 617 __ SmiUntag(r4); |
| 604 __ sub(r0, r1, Operand(r0, ASR, 1)); | 618 __ SmiUntag(r3); |
| 619 __ sub(r3, r4, r3); |
| 605 __ Ret(); | 620 __ Ret(); |
| 606 __ bind(¬_two_smis); | 621 __ bind(¬_two_smis); |
| 607 | 622 |
| 608 // NOTICE! This code is only reached after a smi-fast-case check, so | 623 // NOTICE! This code is only reached after a smi-fast-case check, so |
| 609 // it is certain that at least one operand isn't a smi. | 624 // it is certain that at least one operand isn't a smi. |
| 610 | 625 |
| 611 // Handle the case where the objects are identical. Either returns the answer | 626 // Handle the case where the objects are identical. Either returns the answer |
| 612 // or goes to slow. Only falls through if the objects were not identical. | 627 // or goes to slow. Only falls through if the objects were not identical. |
| 613 EmitIdenticalObjectComparison(masm, &slow, cc); | 628 EmitIdenticalObjectComparison(masm, &slow, cc); |
| 614 | 629 |
| 615 // If either is a Smi (we know that not both are), then they can only | 630 // If either is a Smi (we know that not both are), then they can only |
| 616 // be strictly equal if the other is a HeapNumber. | 631 // be strictly equal if the other is a HeapNumber. |
| 617 STATIC_ASSERT(kSmiTag == 0); | 632 STATIC_ASSERT(kSmiTag == 0); |
| 618 DCHECK_EQ(0, Smi::FromInt(0)); | 633 DCHECK_EQ(0, Smi::FromInt(0)); |
| 619 __ and_(r2, lhs, Operand(rhs)); | 634 __ and_(r5, lhs, rhs); |
| 620 __ JumpIfNotSmi(r2, ¬_smis); | 635 __ JumpIfNotSmi(r5, ¬_smis); |
| 621 // One operand is a smi. EmitSmiNonsmiComparison generates code that can: | 636 // One operand is a smi. EmitSmiNonsmiComparison generates code that can: |
| 622 // 1) Return the answer. | 637 // 1) Return the answer. |
| 623 // 2) Go to slow. | 638 // 2) Go to slow. |
| 624 // 3) Fall through to both_loaded_as_doubles. | 639 // 3) Fall through to both_loaded_as_doubles. |
| 625 // 4) Jump to lhs_not_nan. | 640 // 4) Jump to lhs_not_nan. |
| 626 // In cases 3 and 4 we have found out we were dealing with a number-number | 641 // In cases 3 and 4 we have found out we were dealing with a number-number |
| 627 // comparison. If VFP3 is supported the double values of the numbers have | 642 // comparison. The double values of the numbers have been loaded |
| 628 // been loaded into d7 and d6. Otherwise, the double values have been loaded | 643 // into d7 and d6. |
| 629 // into r0, r1, r2, and r3. | |
| 630 EmitSmiNonsmiComparison(masm, lhs, rhs, &lhs_not_nan, &slow, strict()); | 644 EmitSmiNonsmiComparison(masm, lhs, rhs, &lhs_not_nan, &slow, strict()); |
| 631 | 645 |
| 632 __ bind(&both_loaded_as_doubles); | 646 __ bind(&both_loaded_as_doubles); |
| 633 // The arguments have been converted to doubles and stored in d6 and d7, if | 647 // The arguments have been converted to doubles and stored in d6 and d7 |
| 634 // VFP3 is supported, or in r0, r1, r2, and r3. | |
| 635 __ bind(&lhs_not_nan); | 648 __ bind(&lhs_not_nan); |
| 636 Label no_nan; | 649 Label no_nan; |
| 637 // ARMv7 VFP3 instructions to implement double precision comparison. | 650 __ fcmpu(d7, d6); |
| 638 __ VFPCompareAndSetFlags(d7, d6); | 651 |
| 639 Label nan; | 652 Label nan, equal, less_than; |
| 640 __ b(vs, &nan); | 653 __ bunordered(&nan); |
| 641 __ mov(r0, Operand(EQUAL), LeaveCC, eq); | 654 __ beq(&equal); |
| 642 __ mov(r0, Operand(LESS), LeaveCC, lt); | 655 __ blt(&less_than); |
| 643 __ mov(r0, Operand(GREATER), LeaveCC, gt); | 656 __ li(r3, Operand(GREATER)); |
| 657 __ Ret(); |
| 658 __ bind(&equal); |
| 659 __ li(r3, Operand(EQUAL)); |
| 660 __ Ret(); |
| 661 __ bind(&less_than); |
| 662 __ li(r3, Operand(LESS)); |
| 644 __ Ret(); | 663 __ Ret(); |
| 645 | 664 |
| 646 __ bind(&nan); | 665 __ bind(&nan); |
| 647 // If one of the sides was a NaN then the v flag is set. Load r0 with | 666 // If one of the sides was a NaN then the v flag is set. Load r3 with |
| 648 // whatever it takes to make the comparison fail, since comparisons with NaN | 667 // whatever it takes to make the comparison fail, since comparisons with NaN |
| 649 // always fail. | 668 // always fail. |
| 650 if (cc == lt || cc == le) { | 669 if (cc == lt || cc == le) { |
| 651 __ mov(r0, Operand(GREATER)); | 670 __ li(r3, Operand(GREATER)); |
| 652 } else { | 671 } else { |
| 653 __ mov(r0, Operand(LESS)); | 672 __ li(r3, Operand(LESS)); |
| 654 } | 673 } |
| 655 __ Ret(); | 674 __ Ret(); |
| 656 | 675 |
| 657 __ bind(¬_smis); | 676 __ bind(¬_smis); |
| 658 // At this point we know we are dealing with two different objects, | 677 // At this point we know we are dealing with two different objects, |
| 659 // and neither of them is a Smi. The objects are in rhs_ and lhs_. | 678 // and neither of them is a Smi. The objects are in rhs_ and lhs_. |
| 660 if (strict()) { | 679 if (strict()) { |
| 661 // This returns non-equal for some object types, or falls through if it | 680 // This returns non-equal for some object types, or falls through if it |
| 662 // was not lucky. | 681 // was not lucky. |
| 663 EmitStrictTwoHeapObjectCompare(masm, lhs, rhs); | 682 EmitStrictTwoHeapObjectCompare(masm, lhs, rhs); |
| 664 } | 683 } |
| 665 | 684 |
| 666 Label check_for_internalized_strings; | 685 Label check_for_internalized_strings; |
| 667 Label flat_string_check; | 686 Label flat_string_check; |
| 668 // Check for heap-number-heap-number comparison. Can jump to slow case, | 687 // Check for heap-number-heap-number comparison. Can jump to slow case, |
| 669 // or load both doubles into r0, r1, r2, r3 and jump to the code that handles | 688 // or load both doubles into r3, r4, r5, r6 and jump to the code that handles |
| 670 // that case. If the inputs are not doubles then jumps to | 689 // that case. If the inputs are not doubles then jumps to |
| 671 // check_for_internalized_strings. | 690 // check_for_internalized_strings. |
| 672 // In this case r2 will contain the type of rhs_. Never falls through. | 691 // In this case r5 will contain the type of rhs_. Never falls through. |
| 673 EmitCheckForTwoHeapNumbers(masm, | 692 EmitCheckForTwoHeapNumbers(masm, lhs, rhs, &both_loaded_as_doubles, |
| 674 lhs, | |
| 675 rhs, | |
| 676 &both_loaded_as_doubles, | |
| 677 &check_for_internalized_strings, | 693 &check_for_internalized_strings, |
| 678 &flat_string_check); | 694 &flat_string_check); |
| 679 | 695 |
| 680 __ bind(&check_for_internalized_strings); | 696 __ bind(&check_for_internalized_strings); |
| 681 // In the strict case the EmitStrictTwoHeapObjectCompare already took care of | 697 // In the strict case the EmitStrictTwoHeapObjectCompare already took care of |
| 682 // internalized strings. | 698 // internalized strings. |
| 683 if (cc == eq && !strict()) { | 699 if (cc == eq && !strict()) { |
| 684 // Returns an answer for two internalized strings or two detectable objects. | 700 // Returns an answer for two internalized strings or two detectable objects. |
| 685 // Otherwise jumps to string case or not both strings case. | 701 // Otherwise jumps to string case or not both strings case. |
| 686 // Assumes that r2 is the type of rhs_ on entry. | 702 // Assumes that r5 is the type of rhs_ on entry. |
| 687 EmitCheckForInternalizedStringsOrObjects( | 703 EmitCheckForInternalizedStringsOrObjects(masm, lhs, rhs, &flat_string_check, |
| 688 masm, lhs, rhs, &flat_string_check, &slow); | 704 &slow); |
| 689 } | 705 } |
| 690 | 706 |
| 691 // Check for both being sequential one-byte strings, | 707 // Check for both being sequential one-byte strings, |
| 692 // and inline if that is the case. | 708 // and inline if that is the case. |
| 693 __ bind(&flat_string_check); | 709 __ bind(&flat_string_check); |
| 694 | 710 |
| 695 __ JumpIfNonSmisNotBothSequentialOneByteStrings(lhs, rhs, r2, r3, &slow); | 711 __ JumpIfNonSmisNotBothSequentialOneByteStrings(lhs, rhs, r5, r6, &slow); |
| 696 | 712 |
| 697 __ IncrementCounter(isolate()->counters()->string_compare_native(), 1, r2, | 713 __ IncrementCounter(isolate()->counters()->string_compare_native(), 1, r5, |
| 698 r3); | 714 r6); |
| 699 if (cc == eq) { | 715 if (cc == eq) { |
| 700 StringHelper::GenerateFlatOneByteStringEquals(masm, lhs, rhs, r2, r3, r4); | 716 StringHelper::GenerateFlatOneByteStringEquals(masm, lhs, rhs, r5, r6); |
| 701 } else { | 717 } else { |
| 702 StringHelper::GenerateCompareFlatOneByteStrings(masm, lhs, rhs, r2, r3, r4, | 718 StringHelper::GenerateCompareFlatOneByteStrings(masm, lhs, rhs, r5, r6, r7); |
| 703 r5); | |
| 704 } | 719 } |
| 705 // Never falls through to here. | 720 // Never falls through to here. |
| 706 | 721 |
| 707 __ bind(&slow); | 722 __ bind(&slow); |
| 708 | 723 |
| 709 __ Push(lhs, rhs); | 724 __ Push(lhs, rhs); |
| 710 // Figure out which native to call and setup the arguments. | 725 // Figure out which native to call and setup the arguments. |
| 711 Builtins::JavaScript native; | 726 Builtins::JavaScript native; |
| 712 if (cc == eq) { | 727 if (cc == eq) { |
| 713 native = strict() ? Builtins::STRICT_EQUALS : Builtins::EQUALS; | 728 native = strict() ? Builtins::STRICT_EQUALS : Builtins::EQUALS; |
| 714 } else { | 729 } else { |
| 715 native = Builtins::COMPARE; | 730 native = Builtins::COMPARE; |
| 716 int ncr; // NaN compare result | 731 int ncr; // NaN compare result |
| 717 if (cc == lt || cc == le) { | 732 if (cc == lt || cc == le) { |
| 718 ncr = GREATER; | 733 ncr = GREATER; |
| 719 } else { | 734 } else { |
| 720 DCHECK(cc == gt || cc == ge); // remaining cases | 735 DCHECK(cc == gt || cc == ge); // remaining cases |
| 721 ncr = LESS; | 736 ncr = LESS; |
| 722 } | 737 } |
| 723 __ mov(r0, Operand(Smi::FromInt(ncr))); | 738 __ LoadSmiLiteral(r3, Smi::FromInt(ncr)); |
| 724 __ push(r0); | 739 __ push(r3); |
| 725 } | 740 } |
| 726 | 741 |
| 727 // Call the native; it returns -1 (less), 0 (equal), or 1 (greater) | 742 // Call the native; it returns -1 (less), 0 (equal), or 1 (greater) |
| 728 // tagged as a small integer. | 743 // tagged as a small integer. |
| 729 __ InvokeBuiltin(native, JUMP_FUNCTION); | 744 __ InvokeBuiltin(native, JUMP_FUNCTION); |
| 730 | 745 |
| 731 __ bind(&miss); | 746 __ bind(&miss); |
| 732 GenerateMiss(masm); | 747 GenerateMiss(masm); |
| 733 } | 748 } |
| 734 | 749 |
| 735 | 750 |
| 736 void StoreBufferOverflowStub::Generate(MacroAssembler* masm) { | 751 void StoreBufferOverflowStub::Generate(MacroAssembler* masm) { |
| 737 // We don't allow a GC during a store buffer overflow so there is no need to | 752 // We don't allow a GC during a store buffer overflow so there is no need to |
| 738 // store the registers in any particular way, but we do have to store and | 753 // store the registers in any particular way, but we do have to store and |
| 739 // restore them. | 754 // restore them. |
| 740 __ stm(db_w, sp, kCallerSaved | lr.bit()); | 755 __ mflr(r0); |
| 741 | 756 __ MultiPush(kJSCallerSaved | r0.bit()); |
| 742 const Register scratch = r1; | |
| 743 | |
| 744 if (save_doubles()) { | 757 if (save_doubles()) { |
| 745 __ SaveFPRegs(sp, scratch); | 758 __ SaveFPRegs(sp, 0, DoubleRegister::kNumVolatileRegisters); |
| 746 } | 759 } |
| 747 const int argument_count = 1; | 760 const int argument_count = 1; |
| 748 const int fp_argument_count = 0; | 761 const int fp_argument_count = 0; |
| 762 const Register scratch = r4; |
| 749 | 763 |
| 750 AllowExternalCallThatCantCauseGC scope(masm); | 764 AllowExternalCallThatCantCauseGC scope(masm); |
| 751 __ PrepareCallCFunction(argument_count, fp_argument_count, scratch); | 765 __ PrepareCallCFunction(argument_count, fp_argument_count, scratch); |
| 752 __ mov(r0, Operand(ExternalReference::isolate_address(isolate()))); | 766 __ mov(r3, Operand(ExternalReference::isolate_address(isolate()))); |
| 753 __ CallCFunction( | 767 __ CallCFunction(ExternalReference::store_buffer_overflow_function(isolate()), |
| 754 ExternalReference::store_buffer_overflow_function(isolate()), | 768 argument_count); |
| 755 argument_count); | |
| 756 if (save_doubles()) { | 769 if (save_doubles()) { |
| 757 __ RestoreFPRegs(sp, scratch); | 770 __ RestoreFPRegs(sp, 0, DoubleRegister::kNumVolatileRegisters); |
| 758 } | 771 } |
| 759 __ ldm(ia_w, sp, kCallerSaved | pc.bit()); // Also pop pc to get Ret(0). | 772 __ MultiPop(kJSCallerSaved | r0.bit()); |
| 773 __ mtlr(r0); |
| 774 __ Ret(); |
| 760 } | 775 } |
| 761 | 776 |
| 762 | 777 |
| 763 void MathPowStub::Generate(MacroAssembler* masm) { | 778 void MathPowStub::Generate(MacroAssembler* masm) { |
| 764 const Register base = r1; | 779 const Register base = r4; |
| 765 const Register exponent = MathPowTaggedDescriptor::exponent(); | 780 const Register exponent = MathPowTaggedDescriptor::exponent(); |
| 766 DCHECK(exponent.is(r2)); | 781 DCHECK(exponent.is(r5)); |
| 767 const Register heapnumbermap = r5; | 782 const Register heapnumbermap = r8; |
| 768 const Register heapnumber = r0; | 783 const Register heapnumber = r3; |
| 769 const DwVfpRegister double_base = d0; | 784 const DoubleRegister double_base = d1; |
| 770 const DwVfpRegister double_exponent = d1; | 785 const DoubleRegister double_exponent = d2; |
| 771 const DwVfpRegister double_result = d2; | 786 const DoubleRegister double_result = d3; |
| 772 const DwVfpRegister double_scratch = d3; | 787 const DoubleRegister double_scratch = d0; |
| 773 const SwVfpRegister single_scratch = s6; | 788 const Register scratch = r11; |
| 774 const Register scratch = r9; | 789 const Register scratch2 = r10; |
| 775 const Register scratch2 = r4; | |
| 776 | 790 |
| 777 Label call_runtime, done, int_exponent; | 791 Label call_runtime, done, int_exponent; |
| 778 if (exponent_type() == ON_STACK) { | 792 if (exponent_type() == ON_STACK) { |
| 779 Label base_is_smi, unpack_exponent; | 793 Label base_is_smi, unpack_exponent; |
| 780 // The exponent and base are supplied as arguments on the stack. | 794 // The exponent and base are supplied as arguments on the stack. |
| 781 // This can only happen if the stub is called from non-optimized code. | 795 // This can only happen if the stub is called from non-optimized code. |
| 782 // Load input parameters from stack to double registers. | 796 // Load input parameters from stack to double registers. |
| 783 __ ldr(base, MemOperand(sp, 1 * kPointerSize)); | 797 __ LoadP(base, MemOperand(sp, 1 * kPointerSize)); |
| 784 __ ldr(exponent, MemOperand(sp, 0 * kPointerSize)); | 798 __ LoadP(exponent, MemOperand(sp, 0 * kPointerSize)); |
| 785 | 799 |
| 786 __ LoadRoot(heapnumbermap, Heap::kHeapNumberMapRootIndex); | 800 __ LoadRoot(heapnumbermap, Heap::kHeapNumberMapRootIndex); |
| 787 | 801 |
| 788 __ UntagAndJumpIfSmi(scratch, base, &base_is_smi); | 802 __ UntagAndJumpIfSmi(scratch, base, &base_is_smi); |
| 789 __ ldr(scratch, FieldMemOperand(base, JSObject::kMapOffset)); | 803 __ LoadP(scratch, FieldMemOperand(base, JSObject::kMapOffset)); |
| 790 __ cmp(scratch, heapnumbermap); | 804 __ cmp(scratch, heapnumbermap); |
| 791 __ b(ne, &call_runtime); | 805 __ bne(&call_runtime); |
| 792 | 806 |
| 793 __ vldr(double_base, FieldMemOperand(base, HeapNumber::kValueOffset)); | 807 __ lfd(double_base, FieldMemOperand(base, HeapNumber::kValueOffset)); |
| 794 __ jmp(&unpack_exponent); | 808 __ b(&unpack_exponent); |
| 795 | 809 |
| 796 __ bind(&base_is_smi); | 810 __ bind(&base_is_smi); |
| 797 __ vmov(single_scratch, scratch); | 811 __ ConvertIntToDouble(scratch, double_base); |
| 798 __ vcvt_f64_s32(double_base, single_scratch); | |
| 799 __ bind(&unpack_exponent); | 812 __ bind(&unpack_exponent); |
| 800 | 813 |
| 801 __ UntagAndJumpIfSmi(scratch, exponent, &int_exponent); | 814 __ UntagAndJumpIfSmi(scratch, exponent, &int_exponent); |
| 815 __ LoadP(scratch, FieldMemOperand(exponent, JSObject::kMapOffset)); |
| 816 __ cmp(scratch, heapnumbermap); |
| 817 __ bne(&call_runtime); |
| 802 | 818 |
| 803 __ ldr(scratch, FieldMemOperand(exponent, JSObject::kMapOffset)); | 819 __ lfd(double_exponent, |
| 804 __ cmp(scratch, heapnumbermap); | 820 FieldMemOperand(exponent, HeapNumber::kValueOffset)); |
| 805 __ b(ne, &call_runtime); | |
| 806 __ vldr(double_exponent, | |
| 807 FieldMemOperand(exponent, HeapNumber::kValueOffset)); | |
| 808 } else if (exponent_type() == TAGGED) { | 821 } else if (exponent_type() == TAGGED) { |
| 809 // Base is already in double_base. | 822 // Base is already in double_base. |
| 810 __ UntagAndJumpIfSmi(scratch, exponent, &int_exponent); | 823 __ UntagAndJumpIfSmi(scratch, exponent, &int_exponent); |
| 811 | 824 |
| 812 __ vldr(double_exponent, | 825 __ lfd(double_exponent, |
| 813 FieldMemOperand(exponent, HeapNumber::kValueOffset)); | 826 FieldMemOperand(exponent, HeapNumber::kValueOffset)); |
| 814 } | 827 } |
| 815 | 828 |
| 816 if (exponent_type() != INTEGER) { | 829 if (exponent_type() != INTEGER) { |
| 817 Label int_exponent_convert; | |
| 818 // Detect integer exponents stored as double. | 830 // Detect integer exponents stored as double. |
| 819 __ vcvt_u32_f64(single_scratch, double_exponent); | 831 __ TryDoubleToInt32Exact(scratch, double_exponent, scratch2, |
| 820 // We do not check for NaN or Infinity here because comparing numbers on | 832 double_scratch); |
| 821 // ARM correctly distinguishes NaNs. We end up calling the built-in. | 833 __ beq(&int_exponent); |
| 822 __ vcvt_f64_u32(double_scratch, single_scratch); | |
| 823 __ VFPCompareAndSetFlags(double_scratch, double_exponent); | |
| 824 __ b(eq, &int_exponent_convert); | |
| 825 | 834 |
| 826 if (exponent_type() == ON_STACK) { | 835 if (exponent_type() == ON_STACK) { |
| 827 // Detect square root case. Crankshaft detects constant +/-0.5 at | 836 // Detect square root case. Crankshaft detects constant +/-0.5 at |
| 828 // compile time and uses DoMathPowHalf instead. We then skip this check | 837 // compile time and uses DoMathPowHalf instead. We then skip this check |
| 829 // for non-constant cases of +/-0.5 as these hardly occur. | 838 // for non-constant cases of +/-0.5 as these hardly occur. |
| 830 Label not_plus_half; | 839 Label not_plus_half, not_minus_inf1, not_minus_inf2; |
| 831 | 840 |
| 832 // Test for 0.5. | 841 // Test for 0.5. |
| 833 __ vmov(double_scratch, 0.5, scratch); | 842 __ LoadDoubleLiteral(double_scratch, 0.5, scratch); |
| 834 __ VFPCompareAndSetFlags(double_exponent, double_scratch); | 843 __ fcmpu(double_exponent, double_scratch); |
| 835 __ b(ne, ¬_plus_half); | 844 __ bne(¬_plus_half); |
| 836 | 845 |
| 837 // Calculates square root of base. Check for the special case of | 846 // Calculates square root of base. Check for the special case of |
| 838 // Math.pow(-Infinity, 0.5) == Infinity (ECMA spec, 15.8.2.13). | 847 // Math.pow(-Infinity, 0.5) == Infinity (ECMA spec, 15.8.2.13). |
| 839 __ vmov(double_scratch, -V8_INFINITY, scratch); | 848 __ LoadDoubleLiteral(double_scratch, -V8_INFINITY, scratch); |
| 840 __ VFPCompareAndSetFlags(double_base, double_scratch); | 849 __ fcmpu(double_base, double_scratch); |
| 841 __ vneg(double_result, double_scratch, eq); | 850 __ bne(¬_minus_inf1); |
| 842 __ b(eq, &done); | 851 __ fneg(double_result, double_scratch); |
| 852 __ b(&done); |
| 853 __ bind(¬_minus_inf1); |
| 843 | 854 |
| 844 // Add +0 to convert -0 to +0. | 855 // Add +0 to convert -0 to +0. |
| 845 __ vadd(double_scratch, double_base, kDoubleRegZero); | 856 __ fadd(double_scratch, double_base, kDoubleRegZero); |
| 846 __ vsqrt(double_result, double_scratch); | 857 __ fsqrt(double_result, double_scratch); |
| 847 __ jmp(&done); | 858 __ b(&done); |
| 848 | 859 |
| 849 __ bind(¬_plus_half); | 860 __ bind(¬_plus_half); |
| 850 __ vmov(double_scratch, -0.5, scratch); | 861 __ LoadDoubleLiteral(double_scratch, -0.5, scratch); |
| 851 __ VFPCompareAndSetFlags(double_exponent, double_scratch); | 862 __ fcmpu(double_exponent, double_scratch); |
| 852 __ b(ne, &call_runtime); | 863 __ bne(&call_runtime); |
| 853 | 864 |
| 854 // Calculates square root of base. Check for the special case of | 865 // Calculates square root of base. Check for the special case of |
| 855 // Math.pow(-Infinity, -0.5) == 0 (ECMA spec, 15.8.2.13). | 866 // Math.pow(-Infinity, -0.5) == 0 (ECMA spec, 15.8.2.13). |
| 856 __ vmov(double_scratch, -V8_INFINITY, scratch); | 867 __ LoadDoubleLiteral(double_scratch, -V8_INFINITY, scratch); |
| 857 __ VFPCompareAndSetFlags(double_base, double_scratch); | 868 __ fcmpu(double_base, double_scratch); |
| 858 __ vmov(double_result, kDoubleRegZero, eq); | 869 __ bne(¬_minus_inf2); |
| 859 __ b(eq, &done); | 870 __ fmr(double_result, kDoubleRegZero); |
| 871 __ b(&done); |
| 872 __ bind(¬_minus_inf2); |
| 860 | 873 |
| 861 // Add +0 to convert -0 to +0. | 874 // Add +0 to convert -0 to +0. |
| 862 __ vadd(double_scratch, double_base, kDoubleRegZero); | 875 __ fadd(double_scratch, double_base, kDoubleRegZero); |
| 863 __ vmov(double_result, 1.0, scratch); | 876 __ LoadDoubleLiteral(double_result, 1.0, scratch); |
| 864 __ vsqrt(double_scratch, double_scratch); | 877 __ fsqrt(double_scratch, double_scratch); |
| 865 __ vdiv(double_result, double_result, double_scratch); | 878 __ fdiv(double_result, double_result, double_scratch); |
| 866 __ jmp(&done); | 879 __ b(&done); |
| 867 } | 880 } |
| 868 | 881 |
| 869 __ push(lr); | 882 __ mflr(r0); |
| 883 __ push(r0); |
| 870 { | 884 { |
| 871 AllowExternalCallThatCantCauseGC scope(masm); | 885 AllowExternalCallThatCantCauseGC scope(masm); |
| 872 __ PrepareCallCFunction(0, 2, scratch); | 886 __ PrepareCallCFunction(0, 2, scratch); |
| 873 __ MovToFloatParameters(double_base, double_exponent); | 887 __ MovToFloatParameters(double_base, double_exponent); |
| 874 __ CallCFunction( | 888 __ CallCFunction( |
| 875 ExternalReference::power_double_double_function(isolate()), | 889 ExternalReference::power_double_double_function(isolate()), 0, 2); |
| 876 0, 2); | |
| 877 } | 890 } |
| 878 __ pop(lr); | 891 __ pop(r0); |
| 892 __ mtlr(r0); |
| 879 __ MovFromFloatResult(double_result); | 893 __ MovFromFloatResult(double_result); |
| 880 __ jmp(&done); | 894 __ b(&done); |
| 881 | |
| 882 __ bind(&int_exponent_convert); | |
| 883 __ vcvt_u32_f64(single_scratch, double_exponent); | |
| 884 __ vmov(scratch, single_scratch); | |
| 885 } | 895 } |
| 886 | 896 |
| 887 // Calculate power with integer exponent. | 897 // Calculate power with integer exponent. |
| 888 __ bind(&int_exponent); | 898 __ bind(&int_exponent); |
| 889 | 899 |
| 890 // Get two copies of exponent in the registers scratch and exponent. | 900 // Get two copies of exponent in the registers scratch and exponent. |
| 891 if (exponent_type() == INTEGER) { | 901 if (exponent_type() == INTEGER) { |
| 892 __ mov(scratch, exponent); | 902 __ mr(scratch, exponent); |
| 893 } else { | 903 } else { |
| 894 // Exponent has previously been stored into scratch as untagged integer. | 904 // Exponent has previously been stored into scratch as untagged integer. |
| 895 __ mov(exponent, scratch); | 905 __ mr(exponent, scratch); |
| 896 } | 906 } |
| 897 __ vmov(double_scratch, double_base); // Back up base. | 907 __ fmr(double_scratch, double_base); // Back up base. |
| 898 __ vmov(double_result, 1.0, scratch2); | 908 __ li(scratch2, Operand(1)); |
| 909 __ ConvertIntToDouble(scratch2, double_result); |
| 899 | 910 |
| 900 // Get absolute value of exponent. | 911 // Get absolute value of exponent. |
| 901 __ cmp(scratch, Operand::Zero()); | 912 Label positive_exponent; |
| 902 __ mov(scratch2, Operand::Zero(), LeaveCC, mi); | 913 __ cmpi(scratch, Operand::Zero()); |
| 903 __ sub(scratch, scratch2, scratch, LeaveCC, mi); | 914 __ bge(&positive_exponent); |
| 915 __ neg(scratch, scratch); |
| 916 __ bind(&positive_exponent); |
| 904 | 917 |
| 905 Label while_true; | 918 Label while_true, no_carry, loop_end; |
| 906 __ bind(&while_true); | 919 __ bind(&while_true); |
| 907 __ mov(scratch, Operand(scratch, ASR, 1), SetCC); | 920 __ andi(scratch2, scratch, Operand(1)); |
| 908 __ vmul(double_result, double_result, double_scratch, cs); | 921 __ beq(&no_carry, cr0); |
| 909 __ vmul(double_scratch, double_scratch, double_scratch, ne); | 922 __ fmul(double_result, double_result, double_scratch); |
| 910 __ b(ne, &while_true); | 923 __ bind(&no_carry); |
| 924 __ ShiftRightArithImm(scratch, scratch, 1, SetRC); |
| 925 __ beq(&loop_end, cr0); |
| 926 __ fmul(double_scratch, double_scratch, double_scratch); |
| 927 __ b(&while_true); |
| 928 __ bind(&loop_end); |
| 911 | 929 |
| 912 __ cmp(exponent, Operand::Zero()); | 930 __ cmpi(exponent, Operand::Zero()); |
| 913 __ b(ge, &done); | 931 __ bge(&done); |
| 914 __ vmov(double_scratch, 1.0, scratch); | 932 |
| 915 __ vdiv(double_result, double_scratch, double_result); | 933 __ li(scratch2, Operand(1)); |
| 934 __ ConvertIntToDouble(scratch2, double_scratch); |
| 935 __ fdiv(double_result, double_scratch, double_result); |
| 916 // Test whether result is zero. Bail out to check for subnormal result. | 936 // Test whether result is zero. Bail out to check for subnormal result. |
| 917 // Due to subnormals, x^-y == (1/x)^y does not hold in all cases. | 937 // Due to subnormals, x^-y == (1/x)^y does not hold in all cases. |
| 918 __ VFPCompareAndSetFlags(double_result, 0.0); | 938 __ fcmpu(double_result, kDoubleRegZero); |
| 919 __ b(ne, &done); | 939 __ bne(&done); |
| 920 // double_exponent may not containe the exponent value if the input was a | 940 // double_exponent may not containe the exponent value if the input was a |
| 921 // smi. We set it with exponent value before bailing out. | 941 // smi. We set it with exponent value before bailing out. |
| 922 __ vmov(single_scratch, exponent); | 942 __ ConvertIntToDouble(exponent, double_exponent); |
| 923 __ vcvt_f64_s32(double_exponent, single_scratch); | |
| 924 | 943 |
| 925 // Returning or bailing out. | 944 // Returning or bailing out. |
| 926 Counters* counters = isolate()->counters(); | 945 Counters* counters = isolate()->counters(); |
| 927 if (exponent_type() == ON_STACK) { | 946 if (exponent_type() == ON_STACK) { |
| 928 // The arguments are still on the stack. | 947 // The arguments are still on the stack. |
| 929 __ bind(&call_runtime); | 948 __ bind(&call_runtime); |
| 930 __ TailCallRuntime(Runtime::kMathPowRT, 2, 1); | 949 __ TailCallRuntime(Runtime::kMathPowRT, 2, 1); |
| 931 | 950 |
| 932 // The stub is called from non-optimized code, which expects the result | 951 // The stub is called from non-optimized code, which expects the result |
| 933 // as heap number in exponent. | 952 // as heap number in exponent. |
| 934 __ bind(&done); | 953 __ bind(&done); |
| 935 __ AllocateHeapNumber( | 954 __ AllocateHeapNumber(heapnumber, scratch, scratch2, heapnumbermap, |
| 936 heapnumber, scratch, scratch2, heapnumbermap, &call_runtime); | 955 &call_runtime); |
| 937 __ vstr(double_result, | 956 __ stfd(double_result, |
| 938 FieldMemOperand(heapnumber, HeapNumber::kValueOffset)); | 957 FieldMemOperand(heapnumber, HeapNumber::kValueOffset)); |
| 939 DCHECK(heapnumber.is(r0)); | 958 DCHECK(heapnumber.is(r3)); |
| 940 __ IncrementCounter(counters->math_pow(), 1, scratch, scratch2); | 959 __ IncrementCounter(counters->math_pow(), 1, scratch, scratch2); |
| 941 __ Ret(2); | 960 __ Ret(2); |
| 942 } else { | 961 } else { |
| 943 __ push(lr); | 962 __ mflr(r0); |
| 963 __ push(r0); |
| 944 { | 964 { |
| 945 AllowExternalCallThatCantCauseGC scope(masm); | 965 AllowExternalCallThatCantCauseGC scope(masm); |
| 946 __ PrepareCallCFunction(0, 2, scratch); | 966 __ PrepareCallCFunction(0, 2, scratch); |
| 947 __ MovToFloatParameters(double_base, double_exponent); | 967 __ MovToFloatParameters(double_base, double_exponent); |
| 948 __ CallCFunction( | 968 __ CallCFunction( |
| 949 ExternalReference::power_double_double_function(isolate()), | 969 ExternalReference::power_double_double_function(isolate()), 0, 2); |
| 950 0, 2); | |
| 951 } | 970 } |
| 952 __ pop(lr); | 971 __ pop(r0); |
| 972 __ mtlr(r0); |
| 953 __ MovFromFloatResult(double_result); | 973 __ MovFromFloatResult(double_result); |
| 954 | 974 |
| 955 __ bind(&done); | 975 __ bind(&done); |
| 956 __ IncrementCounter(counters->math_pow(), 1, scratch, scratch2); | 976 __ IncrementCounter(counters->math_pow(), 1, scratch, scratch2); |
| 957 __ Ret(); | 977 __ Ret(); |
| 958 } | 978 } |
| 959 } | 979 } |
| 960 | 980 |
| 961 | 981 |
| 962 bool CEntryStub::NeedsImmovableCode() { | 982 bool CEntryStub::NeedsImmovableCode() { return true; } |
| 963 return true; | |
| 964 } | |
| 965 | 983 |
| 966 | 984 |
| 967 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { | 985 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { |
| 968 CEntryStub::GenerateAheadOfTime(isolate); | 986 CEntryStub::GenerateAheadOfTime(isolate); |
| 969 WriteInt32ToHeapNumberStub::GenerateFixedRegStubsAheadOfTime(isolate); | 987 // WriteInt32ToHeapNumberStub::GenerateFixedRegStubsAheadOfTime(isolate); |
| 970 StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime(isolate); | 988 StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime(isolate); |
| 971 StubFailureTrampolineStub::GenerateAheadOfTime(isolate); | 989 StubFailureTrampolineStub::GenerateAheadOfTime(isolate); |
| 972 ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); | 990 ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); |
| 973 CreateAllocationSiteStub::GenerateAheadOfTime(isolate); | 991 CreateAllocationSiteStub::GenerateAheadOfTime(isolate); |
| 974 BinaryOpICStub::GenerateAheadOfTime(isolate); | 992 BinaryOpICStub::GenerateAheadOfTime(isolate); |
| 975 BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(isolate); | 993 BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(isolate); |
| 976 } | 994 } |
| 977 | 995 |
| 978 | 996 |
| 979 void CodeStub::GenerateFPStubs(Isolate* isolate) { | 997 void CodeStub::GenerateFPStubs(Isolate* isolate) { |
| 980 // Generate if not already in cache. | 998 // Generate if not already in cache. |
| 981 SaveFPRegsMode mode = kSaveFPRegs; | 999 SaveFPRegsMode mode = kSaveFPRegs; |
| 982 CEntryStub(isolate, 1, mode).GetCode(); | 1000 CEntryStub(isolate, 1, mode).GetCode(); |
| 983 StoreBufferOverflowStub(isolate, mode).GetCode(); | 1001 StoreBufferOverflowStub(isolate, mode).GetCode(); |
| 984 isolate->set_fp_stubs_generated(true); | 1002 isolate->set_fp_stubs_generated(true); |
| 985 } | 1003 } |
| 986 | 1004 |
| 987 | 1005 |
| 988 void CEntryStub::GenerateAheadOfTime(Isolate* isolate) { | 1006 void CEntryStub::GenerateAheadOfTime(Isolate* isolate) { |
| 989 CEntryStub stub(isolate, 1, kDontSaveFPRegs); | 1007 CEntryStub stub(isolate, 1, kDontSaveFPRegs); |
| 990 stub.GetCode(); | 1008 stub.GetCode(); |
| 991 } | 1009 } |
| 992 | 1010 |
| 993 | 1011 |
| 994 void CEntryStub::Generate(MacroAssembler* masm) { | 1012 void CEntryStub::Generate(MacroAssembler* masm) { |
| 995 // Called from JavaScript; parameters are on stack as if calling JS function. | 1013 // Called from JavaScript; parameters are on stack as if calling JS function. |
| 996 // r0: number of arguments including receiver | 1014 // r3: number of arguments including receiver |
| 997 // r1: pointer to builtin function | 1015 // r4: pointer to builtin function |
| 998 // fp: frame pointer (restored after C call) | 1016 // fp: frame pointer (restored after C call) |
| 999 // sp: stack pointer (restored as callee's sp after C call) | 1017 // sp: stack pointer (restored as callee's sp after C call) |
| 1000 // cp: current context (C callee-saved) | 1018 // cp: current context (C callee-saved) |
| 1001 | 1019 |
| 1002 ProfileEntryHookStub::MaybeCallEntryHook(masm); | 1020 ProfileEntryHookStub::MaybeCallEntryHook(masm); |
| 1003 | 1021 |
| 1004 __ mov(r5, Operand(r1)); | 1022 __ mr(r15, r4); |
| 1005 | 1023 |
| 1006 // Compute the argv pointer in a callee-saved register. | 1024 // Compute the argv pointer. |
| 1007 __ add(r1, sp, Operand(r0, LSL, kPointerSizeLog2)); | 1025 __ ShiftLeftImm(r4, r3, Operand(kPointerSizeLog2)); |
| 1008 __ sub(r1, r1, Operand(kPointerSize)); | 1026 __ add(r4, r4, sp); |
| 1027 __ subi(r4, r4, Operand(kPointerSize)); |
| 1009 | 1028 |
| 1010 // Enter the exit frame that transitions from JavaScript to C++. | 1029 // Enter the exit frame that transitions from JavaScript to C++. |
| 1011 FrameScope scope(masm, StackFrame::MANUAL); | 1030 FrameScope scope(masm, StackFrame::MANUAL); |
| 1012 __ EnterExitFrame(save_doubles()); | 1031 |
| 1032 // Need at least one extra slot for return address location. |
| 1033 int arg_stack_space = 1; |
| 1034 |
| 1035 // PPC LINUX ABI: |
| 1036 #if V8_TARGET_ARCH_PPC64 && !ABI_RETURNS_OBJECT_PAIRS_IN_REGS |
| 1037 // Pass buffer for return value on stack if necessary |
| 1038 if (result_size() > 1) { |
| 1039 DCHECK_EQ(2, result_size()); |
| 1040 arg_stack_space += 2; |
| 1041 } |
| 1042 #endif |
| 1043 |
| 1044 __ EnterExitFrame(save_doubles(), arg_stack_space); |
| 1013 | 1045 |
| 1014 // Store a copy of argc in callee-saved registers for later. | 1046 // Store a copy of argc in callee-saved registers for later. |
| 1015 __ mov(r4, Operand(r0)); | 1047 __ mr(r14, r3); |
| 1016 | 1048 |
| 1017 // r0, r4: number of arguments including receiver (C callee-saved) | 1049 // r3, r14: number of arguments including receiver (C callee-saved) |
| 1018 // r1: pointer to the first argument (C callee-saved) | 1050 // r4: pointer to the first argument |
| 1019 // r5: pointer to builtin function (C callee-saved) | 1051 // r15: pointer to builtin function (C callee-saved) |
| 1020 | 1052 |
| 1021 // Result returned in r0 or r0+r1 by default. | 1053 // Result returned in registers or stack, depending on result size and ABI. |
| 1022 | 1054 |
| 1023 #if V8_HOST_ARCH_ARM | 1055 Register isolate_reg = r5; |
| 1024 int frame_alignment = MacroAssembler::ActivationFrameAlignment(); | 1056 #if V8_TARGET_ARCH_PPC64 && !ABI_RETURNS_OBJECT_PAIRS_IN_REGS |
| 1025 int frame_alignment_mask = frame_alignment - 1; | 1057 if (result_size() > 1) { |
| 1026 if (FLAG_debug_code) { | 1058 // The return value is 16-byte non-scalar value. |
| 1027 if (frame_alignment > kPointerSize) { | 1059 // Use frame storage reserved by calling function to pass return |
| 1028 Label alignment_as_expected; | 1060 // buffer as implicit first argument. |
| 1029 DCHECK(base::bits::IsPowerOfTwo32(frame_alignment)); | 1061 __ mr(r5, r4); |
| 1030 __ tst(sp, Operand(frame_alignment_mask)); | 1062 __ mr(r4, r3); |
| 1031 __ b(eq, &alignment_as_expected); | 1063 __ addi(r3, sp, Operand((kStackFrameExtraParamSlot + 1) * kPointerSize)); |
| 1032 // Don't use Check here, as it will call Runtime_Abort re-entering here. | 1064 isolate_reg = r6; |
| 1033 __ stop("Unexpected alignment"); | |
| 1034 __ bind(&alignment_as_expected); | |
| 1035 } | |
| 1036 } | 1065 } |
| 1037 #endif | 1066 #endif |
| 1038 | 1067 |
| 1039 // Call C built-in. | 1068 // Call C built-in. |
| 1040 // r0 = argc, r1 = argv | 1069 __ mov(isolate_reg, Operand(ExternalReference::isolate_address(isolate()))); |
| 1041 __ mov(r2, Operand(ExternalReference::isolate_address(isolate()))); | 1070 |
| 1071 #if ABI_USES_FUNCTION_DESCRIPTORS && !defined(USE_SIMULATOR) |
| 1072 // Native AIX/PPC64 Linux use a function descriptor. |
| 1073 __ LoadP(ToRegister(ABI_TOC_REGISTER), MemOperand(r15, kPointerSize)); |
| 1074 __ LoadP(ip, MemOperand(r15, 0)); // Instruction address |
| 1075 Register target = ip; |
| 1076 #elif ABI_TOC_ADDRESSABILITY_VIA_IP |
| 1077 __ Move(ip, r15); |
| 1078 Register target = ip; |
| 1079 #else |
| 1080 Register target = r15; |
| 1081 #endif |
| 1042 | 1082 |
| 1043 // To let the GC traverse the return address of the exit frames, we need to | 1083 // To let the GC traverse the return address of the exit frames, we need to |
| 1044 // know where the return address is. The CEntryStub is unmovable, so | 1084 // know where the return address is. The CEntryStub is unmovable, so |
| 1045 // we can store the address on the stack to be able to find it again and | 1085 // we can store the address on the stack to be able to find it again and |
| 1046 // we never have to restore it, because it will not change. | 1086 // we never have to restore it, because it will not change. |
| 1047 // Compute the return address in lr to return to after the jump below. Pc is | 1087 // Compute the return address in lr to return to after the jump below. Pc is |
| 1048 // already at '+ 8' from the current instruction but return is after three | 1088 // already at '+ 8' from the current instruction but return is after three |
| 1049 // instructions so add another 4 to pc to get the return address. | 1089 // instructions so add another 4 to pc to get the return address. |
| 1050 { | 1090 { |
| 1051 // Prevent literal pool emission before return address. | 1091 Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm); |
| 1052 Assembler::BlockConstPoolScope block_const_pool(masm); | 1092 Label here; |
| 1053 __ add(lr, pc, Operand(4)); | 1093 __ b(&here, SetLK); |
| 1054 __ str(lr, MemOperand(sp, 0)); | 1094 __ bind(&here); |
| 1055 __ Call(r5); | 1095 __ mflr(r8); |
| 1056 } | 1096 |
| 1057 | 1097 // Constant used below is dependent on size of Call() macro instructions |
| 1058 __ VFPEnsureFPSCRState(r2); | 1098 __ addi(r0, r8, Operand(20)); |
| 1099 |
| 1100 __ StoreP(r0, MemOperand(sp, kStackFrameExtraParamSlot * kPointerSize)); |
| 1101 __ Call(target); |
| 1102 } |
| 1103 |
| 1104 // roohack - do we need to (re)set FPU state? |
| 1105 |
| 1106 #if V8_TARGET_ARCH_PPC64 && !ABI_RETURNS_OBJECT_PAIRS_IN_REGS |
| 1107 // If return value is on the stack, pop it to registers. |
| 1108 if (result_size() > 1) { |
| 1109 __ LoadP(r4, MemOperand(r3, kPointerSize)); |
| 1110 __ LoadP(r3, MemOperand(r3)); |
| 1111 } |
| 1112 #endif |
| 1059 | 1113 |
| 1060 // Runtime functions should not return 'the hole'. Allowing it to escape may | 1114 // Runtime functions should not return 'the hole'. Allowing it to escape may |
| 1061 // lead to crashes in the IC code later. | 1115 // lead to crashes in the IC code later. |
| 1062 if (FLAG_debug_code) { | 1116 if (FLAG_debug_code) { |
| 1063 Label okay; | 1117 Label okay; |
| 1064 __ CompareRoot(r0, Heap::kTheHoleValueRootIndex); | 1118 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex); |
| 1065 __ b(ne, &okay); | 1119 __ bne(&okay); |
| 1066 __ stop("The hole escaped"); | 1120 __ stop("The hole escaped"); |
| 1067 __ bind(&okay); | 1121 __ bind(&okay); |
| 1068 } | 1122 } |
| 1069 | 1123 |
| 1070 // Check result for exception sentinel. | 1124 // Check result for exception sentinel. |
| 1071 Label exception_returned; | 1125 Label exception_returned; |
| 1072 __ CompareRoot(r0, Heap::kExceptionRootIndex); | 1126 __ CompareRoot(r3, Heap::kExceptionRootIndex); |
| 1073 __ b(eq, &exception_returned); | 1127 __ beq(&exception_returned); |
| 1074 | 1128 |
| 1075 ExternalReference pending_exception_address( | 1129 ExternalReference pending_exception_address(Isolate::kPendingExceptionAddress, |
| 1076 Isolate::kPendingExceptionAddress, isolate()); | 1130 isolate()); |
| 1077 | 1131 |
| 1078 // Check that there is no pending exception, otherwise we | 1132 // Check that there is no pending exception, otherwise we |
| 1079 // should have returned the exception sentinel. | 1133 // should have returned the exception sentinel. |
| 1080 if (FLAG_debug_code) { | 1134 if (FLAG_debug_code) { |
| 1081 Label okay; | 1135 Label okay; |
| 1082 __ mov(r2, Operand(pending_exception_address)); | 1136 __ mov(r5, Operand(pending_exception_address)); |
| 1083 __ ldr(r2, MemOperand(r2)); | 1137 __ LoadP(r5, MemOperand(r5)); |
| 1084 __ CompareRoot(r2, Heap::kTheHoleValueRootIndex); | 1138 __ CompareRoot(r5, Heap::kTheHoleValueRootIndex); |
| 1085 // Cannot use check here as it attempts to generate call into runtime. | 1139 // Cannot use check here as it attempts to generate call into runtime. |
| 1086 __ b(eq, &okay); | 1140 __ beq(&okay); |
| 1087 __ stop("Unexpected pending exception"); | 1141 __ stop("Unexpected pending exception"); |
| 1088 __ bind(&okay); | 1142 __ bind(&okay); |
| 1089 } | 1143 } |
| 1090 | 1144 |
| 1091 // Exit C frame and return. | 1145 // Exit C frame and return. |
| 1092 // r0:r1: result | 1146 // r3:r4: result |
| 1093 // sp: stack pointer | 1147 // sp: stack pointer |
| 1094 // fp: frame pointer | 1148 // fp: frame pointer |
| 1095 // Callee-saved register r4 still holds argc. | 1149 // r14: still holds argc (callee-saved). |
| 1096 __ LeaveExitFrame(save_doubles(), r4, true); | 1150 __ LeaveExitFrame(save_doubles(), r14, true); |
| 1097 __ mov(pc, lr); | 1151 __ blr(); |
| 1098 | 1152 |
| 1099 // Handling of exception. | 1153 // Handling of exception. |
| 1100 __ bind(&exception_returned); | 1154 __ bind(&exception_returned); |
| 1101 | 1155 |
| 1102 // Retrieve the pending exception. | 1156 // Retrieve the pending exception. |
| 1103 __ mov(r2, Operand(pending_exception_address)); | 1157 __ mov(r5, Operand(pending_exception_address)); |
| 1104 __ ldr(r0, MemOperand(r2)); | 1158 __ LoadP(r3, MemOperand(r5)); |
| 1105 | 1159 |
| 1106 // Clear the pending exception. | 1160 // Clear the pending exception. |
| 1107 __ LoadRoot(r3, Heap::kTheHoleValueRootIndex); | 1161 __ LoadRoot(r6, Heap::kTheHoleValueRootIndex); |
| 1108 __ str(r3, MemOperand(r2)); | 1162 __ StoreP(r6, MemOperand(r5)); |
| 1109 | 1163 |
| 1110 // Special handling of termination exceptions which are uncatchable | 1164 // Special handling of termination exceptions which are uncatchable |
| 1111 // by javascript code. | 1165 // by javascript code. |
| 1112 Label throw_termination_exception; | 1166 Label throw_termination_exception; |
| 1113 __ CompareRoot(r0, Heap::kTerminationExceptionRootIndex); | 1167 __ CompareRoot(r3, Heap::kTerminationExceptionRootIndex); |
| 1114 __ b(eq, &throw_termination_exception); | 1168 __ beq(&throw_termination_exception); |
| 1115 | 1169 |
| 1116 // Handle normal exception. | 1170 // Handle normal exception. |
| 1117 __ Throw(r0); | 1171 __ Throw(r3); |
| 1118 | 1172 |
| 1119 __ bind(&throw_termination_exception); | 1173 __ bind(&throw_termination_exception); |
| 1120 __ ThrowUncatchable(r0); | 1174 __ ThrowUncatchable(r3); |
| 1121 } | 1175 } |
| 1122 | 1176 |
| 1123 | 1177 |
| 1124 void JSEntryStub::Generate(MacroAssembler* masm) { | 1178 void JSEntryStub::Generate(MacroAssembler* masm) { |
| 1125 // r0: code entry | 1179 // r3: code entry |
| 1126 // r1: function | 1180 // r4: function |
| 1127 // r2: receiver | 1181 // r5: receiver |
| 1128 // r3: argc | 1182 // r6: argc |
| 1129 // [sp+0]: argv | 1183 // [sp+0]: argv |
| 1130 | 1184 |
| 1131 Label invoke, handler_entry, exit; | 1185 Label invoke, handler_entry, exit; |
| 1132 | 1186 |
| 1187 // Called from C |
| 1188 #if ABI_USES_FUNCTION_DESCRIPTORS |
| 1189 __ function_descriptor(); |
| 1190 #endif |
| 1191 |
| 1133 ProfileEntryHookStub::MaybeCallEntryHook(masm); | 1192 ProfileEntryHookStub::MaybeCallEntryHook(masm); |
| 1134 | 1193 |
| 1135 // Called from C, so do not pop argc and args on exit (preserve sp) | 1194 // PPC LINUX ABI: |
| 1136 // No need to save register-passed args | 1195 // preserve LR in pre-reserved slot in caller's frame |
| 1137 // Save callee-saved registers (incl. cp and fp), sp, and lr | 1196 __ mflr(r0); |
| 1138 __ stm(db_w, sp, kCalleeSaved | lr.bit()); | 1197 __ StoreP(r0, MemOperand(sp, kStackFrameLRSlot * kPointerSize)); |
| 1139 | 1198 |
| 1140 // Save callee-saved vfp registers. | 1199 // Save callee saved registers on the stack. |
| 1141 __ vstm(db_w, sp, kFirstCalleeSavedDoubleReg, kLastCalleeSavedDoubleReg); | 1200 __ MultiPush(kCalleeSaved); |
| 1142 // Set up the reserved register for 0.0. | 1201 |
| 1143 __ vmov(kDoubleRegZero, 0.0); | 1202 // Floating point regs FPR0 - FRP13 are volatile |
| 1144 __ VFPEnsureFPSCRState(r4); | 1203 // FPR14-FPR31 are non-volatile, but sub-calls will save them for us |
| 1145 | 1204 |
| 1146 // Get address of argv, see stm above. | 1205 // int offset_to_argv = kPointerSize * 22; // matches (22*4) above |
| 1147 // r0: code entry | 1206 // __ lwz(r7, MemOperand(sp, offset_to_argv)); |
| 1148 // r1: function | |
| 1149 // r2: receiver | |
| 1150 // r3: argc | |
| 1151 | |
| 1152 // Set up argv in r4. | |
| 1153 int offset_to_argv = (kNumCalleeSaved + 1) * kPointerSize; | |
| 1154 offset_to_argv += kNumDoubleCalleeSaved * kDoubleSize; | |
| 1155 __ ldr(r4, MemOperand(sp, offset_to_argv)); | |
| 1156 | 1207 |
| 1157 // Push a frame with special values setup to mark it as an entry frame. | 1208 // Push a frame with special values setup to mark it as an entry frame. |
| 1158 // r0: code entry | 1209 // r3: code entry |
| 1159 // r1: function | 1210 // r4: function |
| 1160 // r2: receiver | 1211 // r5: receiver |
| 1161 // r3: argc | 1212 // r6: argc |
| 1162 // r4: argv | 1213 // r7: argv |
| 1214 __ li(r0, Operand(-1)); // Push a bad frame pointer to fail if it is used. |
| 1215 __ push(r0); |
| 1216 #if V8_OOL_CONSTANT_POOL |
| 1217 __ mov(kConstantPoolRegister, |
| 1218 Operand(isolate()->factory()->empty_constant_pool_array())); |
| 1219 __ push(kConstantPoolRegister); |
| 1220 #endif |
| 1163 int marker = type(); | 1221 int marker = type(); |
| 1164 if (FLAG_enable_ool_constant_pool) { | 1222 __ LoadSmiLiteral(r0, Smi::FromInt(marker)); |
| 1165 __ mov(r8, Operand(isolate()->factory()->empty_constant_pool_array())); | 1223 __ push(r0); |
| 1166 } | 1224 __ push(r0); |
| 1167 __ mov(r7, Operand(Smi::FromInt(marker))); | 1225 // Save copies of the top frame descriptor on the stack. |
| 1168 __ mov(r6, Operand(Smi::FromInt(marker))); | 1226 __ mov(r8, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); |
| 1169 __ mov(r5, | 1227 __ LoadP(r0, MemOperand(r8)); |
| 1170 Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); | 1228 __ push(r0); |
| 1171 __ ldr(r5, MemOperand(r5)); | |
| 1172 __ mov(ip, Operand(-1)); // Push a bad frame pointer to fail if it is used. | |
| 1173 __ stm(db_w, sp, r5.bit() | r6.bit() | r7.bit() | | |
| 1174 (FLAG_enable_ool_constant_pool ? r8.bit() : 0) | | |
| 1175 ip.bit()); | |
| 1176 | 1229 |
| 1177 // Set up frame pointer for the frame to be pushed. | 1230 // Set up frame pointer for the frame to be pushed. |
| 1178 __ add(fp, sp, Operand(-EntryFrameConstants::kCallerFPOffset)); | 1231 __ addi(fp, sp, Operand(-EntryFrameConstants::kCallerFPOffset)); |
| 1179 | 1232 |
| 1180 // If this is the outermost JS call, set js_entry_sp value. | 1233 // If this is the outermost JS call, set js_entry_sp value. |
| 1181 Label non_outermost_js; | 1234 Label non_outermost_js; |
| 1182 ExternalReference js_entry_sp(Isolate::kJSEntrySPAddress, isolate()); | 1235 ExternalReference js_entry_sp(Isolate::kJSEntrySPAddress, isolate()); |
| 1183 __ mov(r5, Operand(ExternalReference(js_entry_sp))); | 1236 __ mov(r8, Operand(ExternalReference(js_entry_sp))); |
| 1184 __ ldr(r6, MemOperand(r5)); | 1237 __ LoadP(r9, MemOperand(r8)); |
| 1185 __ cmp(r6, Operand::Zero()); | 1238 __ cmpi(r9, Operand::Zero()); |
| 1186 __ b(ne, &non_outermost_js); | 1239 __ bne(&non_outermost_js); |
| 1187 __ str(fp, MemOperand(r5)); | 1240 __ StoreP(fp, MemOperand(r8)); |
| 1188 __ mov(ip, Operand(Smi::FromInt(StackFrame::OUTERMOST_JSENTRY_FRAME))); | 1241 __ LoadSmiLiteral(ip, Smi::FromInt(StackFrame::OUTERMOST_JSENTRY_FRAME)); |
| 1189 Label cont; | 1242 Label cont; |
| 1190 __ b(&cont); | 1243 __ b(&cont); |
| 1191 __ bind(&non_outermost_js); | 1244 __ bind(&non_outermost_js); |
| 1192 __ mov(ip, Operand(Smi::FromInt(StackFrame::INNER_JSENTRY_FRAME))); | 1245 __ LoadSmiLiteral(ip, Smi::FromInt(StackFrame::INNER_JSENTRY_FRAME)); |
| 1193 __ bind(&cont); | 1246 __ bind(&cont); |
| 1194 __ push(ip); | 1247 __ push(ip); // frame-type |
| 1195 | 1248 |
| 1196 // Jump to a faked try block that does the invoke, with a faked catch | 1249 // Jump to a faked try block that does the invoke, with a faked catch |
| 1197 // block that sets the pending exception. | 1250 // block that sets the pending exception. |
| 1198 __ jmp(&invoke); | 1251 __ b(&invoke); |
| 1199 | 1252 |
| 1200 // Block literal pool emission whilst taking the position of the handler | 1253 __ bind(&handler_entry); |
| 1201 // entry. This avoids making the assumption that literal pools are always | 1254 handler_offset_ = handler_entry.pos(); |
| 1202 // emitted after an instruction is emitted, rather than before. | 1255 // Caught exception: Store result (exception) in the pending exception |
| 1203 { | 1256 // field in the JSEnv and return a failure sentinel. Coming in here the |
| 1204 Assembler::BlockConstPoolScope block_const_pool(masm); | 1257 // fp will be invalid because the PushTryHandler below sets it to 0 to |
| 1205 __ bind(&handler_entry); | 1258 // signal the existence of the JSEntry frame. |
| 1206 handler_offset_ = handler_entry.pos(); | 1259 __ mov(ip, Operand(ExternalReference(Isolate::kPendingExceptionAddress, |
| 1207 // Caught exception: Store result (exception) in the pending exception | 1260 isolate()))); |
| 1208 // field in the JSEnv and return a failure sentinel. Coming in here the | 1261 |
| 1209 // fp will be invalid because the PushTryHandler below sets it to 0 to | 1262 __ StoreP(r3, MemOperand(ip)); |
| 1210 // signal the existence of the JSEntry frame. | 1263 __ LoadRoot(r3, Heap::kExceptionRootIndex); |
| 1211 __ mov(ip, Operand(ExternalReference(Isolate::kPendingExceptionAddress, | |
| 1212 isolate()))); | |
| 1213 } | |
| 1214 __ str(r0, MemOperand(ip)); | |
| 1215 __ LoadRoot(r0, Heap::kExceptionRootIndex); | |
| 1216 __ b(&exit); | 1264 __ b(&exit); |
| 1217 | 1265 |
| 1218 // Invoke: Link this frame into the handler chain. There's only one | 1266 // Invoke: Link this frame into the handler chain. There's only one |
| 1219 // handler block in this code object, so its index is 0. | 1267 // handler block in this code object, so its index is 0. |
| 1220 __ bind(&invoke); | 1268 __ bind(&invoke); |
| 1221 // Must preserve r0-r4, r5-r6 are available. | 1269 // Must preserve r0-r4, r5-r7 are available. (needs update for PPC) |
| 1222 __ PushTryHandler(StackHandler::JS_ENTRY, 0); | 1270 __ PushTryHandler(StackHandler::JS_ENTRY, 0); |
| 1223 // If an exception not caught by another handler occurs, this handler | 1271 // If an exception not caught by another handler occurs, this handler |
| 1224 // returns control to the code after the bl(&invoke) above, which | 1272 // returns control to the code after the b(&invoke) above, which |
| 1225 // restores all kCalleeSaved registers (including cp and fp) to their | 1273 // restores all kCalleeSaved registers (including cp and fp) to their |
| 1226 // saved values before returning a failure to C. | 1274 // saved values before returning a failure to C. |
| 1227 | 1275 |
| 1228 // Clear any pending exceptions. | 1276 // Clear any pending exceptions. |
| 1229 __ mov(r5, Operand(isolate()->factory()->the_hole_value())); | 1277 __ mov(r8, Operand(isolate()->factory()->the_hole_value())); |
| 1230 __ mov(ip, Operand(ExternalReference(Isolate::kPendingExceptionAddress, | 1278 __ mov(ip, Operand(ExternalReference(Isolate::kPendingExceptionAddress, |
| 1231 isolate()))); | 1279 isolate()))); |
| 1232 __ str(r5, MemOperand(ip)); | 1280 __ StoreP(r8, MemOperand(ip)); |
| 1233 | 1281 |
| 1234 // Invoke the function by calling through JS entry trampoline builtin. | 1282 // Invoke the function by calling through JS entry trampoline builtin. |
| 1235 // Notice that we cannot store a reference to the trampoline code directly in | 1283 // Notice that we cannot store a reference to the trampoline code directly in |
| 1236 // this stub, because runtime stubs are not traversed when doing GC. | 1284 // this stub, because runtime stubs are not traversed when doing GC. |
| 1237 | 1285 |
| 1238 // Expected registers by Builtins::JSEntryTrampoline | 1286 // Expected registers by Builtins::JSEntryTrampoline |
| 1239 // r0: code entry | 1287 // r3: code entry |
| 1240 // r1: function | 1288 // r4: function |
| 1241 // r2: receiver | 1289 // r5: receiver |
| 1242 // r3: argc | 1290 // r6: argc |
| 1243 // r4: argv | 1291 // r7: argv |
| 1244 if (type() == StackFrame::ENTRY_CONSTRUCT) { | 1292 if (type() == StackFrame::ENTRY_CONSTRUCT) { |
| 1245 ExternalReference construct_entry(Builtins::kJSConstructEntryTrampoline, | 1293 ExternalReference construct_entry(Builtins::kJSConstructEntryTrampoline, |
| 1246 isolate()); | 1294 isolate()); |
| 1247 __ mov(ip, Operand(construct_entry)); | 1295 __ mov(ip, Operand(construct_entry)); |
| 1248 } else { | 1296 } else { |
| 1249 ExternalReference entry(Builtins::kJSEntryTrampoline, isolate()); | 1297 ExternalReference entry(Builtins::kJSEntryTrampoline, isolate()); |
| 1250 __ mov(ip, Operand(entry)); | 1298 __ mov(ip, Operand(entry)); |
| 1251 } | 1299 } |
| 1252 __ ldr(ip, MemOperand(ip)); // deref address | 1300 __ LoadP(ip, MemOperand(ip)); // deref address |
| 1253 __ add(ip, ip, Operand(Code::kHeaderSize - kHeapObjectTag)); | |
| 1254 | 1301 |
| 1255 // Branch and link to JSEntryTrampoline. | 1302 // Branch and link to JSEntryTrampoline. |
| 1256 __ Call(ip); | 1303 // the address points to the start of the code object, skip the header |
| 1304 __ addi(r0, ip, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 1305 __ mtlr(r0); |
| 1306 __ bclr(BA, SetLK); // make the call |
| 1257 | 1307 |
| 1258 // Unlink this frame from the handler chain. | 1308 // Unlink this frame from the handler chain. |
| 1259 __ PopTryHandler(); | 1309 __ PopTryHandler(); |
| 1260 | 1310 |
| 1261 __ bind(&exit); // r0 holds result | 1311 __ bind(&exit); // r3 holds result |
| 1262 // Check if the current stack frame is marked as the outermost JS frame. | 1312 // Check if the current stack frame is marked as the outermost JS frame. |
| 1263 Label non_outermost_js_2; | 1313 Label non_outermost_js_2; |
| 1264 __ pop(r5); | 1314 __ pop(r8); |
| 1265 __ cmp(r5, Operand(Smi::FromInt(StackFrame::OUTERMOST_JSENTRY_FRAME))); | 1315 __ CmpSmiLiteral(r8, Smi::FromInt(StackFrame::OUTERMOST_JSENTRY_FRAME), r0); |
| 1266 __ b(ne, &non_outermost_js_2); | 1316 __ bne(&non_outermost_js_2); |
| 1267 __ mov(r6, Operand::Zero()); | 1317 __ mov(r9, Operand::Zero()); |
| 1268 __ mov(r5, Operand(ExternalReference(js_entry_sp))); | 1318 __ mov(r8, Operand(ExternalReference(js_entry_sp))); |
| 1269 __ str(r6, MemOperand(r5)); | 1319 __ StoreP(r9, MemOperand(r8)); |
| 1270 __ bind(&non_outermost_js_2); | 1320 __ bind(&non_outermost_js_2); |
| 1271 | 1321 |
| 1272 // Restore the top frame descriptors from the stack. | 1322 // Restore the top frame descriptors from the stack. |
| 1273 __ pop(r3); | 1323 __ pop(r6); |
| 1274 __ mov(ip, | 1324 __ mov(ip, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); |
| 1275 Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); | 1325 __ StoreP(r6, MemOperand(ip)); |
| 1276 __ str(r3, MemOperand(ip)); | |
| 1277 | 1326 |
| 1278 // Reset the stack to the callee saved registers. | 1327 // Reset the stack to the callee saved registers. |
| 1279 __ add(sp, sp, Operand(-EntryFrameConstants::kCallerFPOffset)); | 1328 __ addi(sp, sp, Operand(-EntryFrameConstants::kCallerFPOffset)); |
| 1280 | 1329 |
| 1281 // Restore callee-saved registers and return. | 1330 // Restore callee-saved registers and return. |
| 1282 #ifdef DEBUG | 1331 #ifdef DEBUG |
| 1283 if (FLAG_debug_code) { | 1332 if (FLAG_debug_code) { |
| 1284 __ mov(lr, Operand(pc)); | 1333 Label here; |
| 1334 __ b(&here, SetLK); |
| 1335 __ bind(&here); |
| 1285 } | 1336 } |
| 1286 #endif | 1337 #endif |
| 1287 | 1338 |
| 1288 // Restore callee-saved vfp registers. | 1339 __ MultiPop(kCalleeSaved); |
| 1289 __ vldm(ia_w, sp, kFirstCalleeSavedDoubleReg, kLastCalleeSavedDoubleReg); | |
| 1290 | 1340 |
| 1291 __ ldm(ia_w, sp, kCalleeSaved | pc.bit()); | 1341 __ LoadP(r0, MemOperand(sp, kStackFrameLRSlot * kPointerSize)); |
| 1342 __ mtctr(r0); |
| 1343 __ bctr(); |
| 1292 } | 1344 } |
| 1293 | 1345 |
| 1294 | 1346 |
| 1295 // Uses registers r0 to r4. | 1347 // Uses registers r3 to r7. |
| 1296 // Expected input (depending on whether args are in registers or on the stack): | 1348 // Expected input (depending on whether args are in registers or on the stack): |
| 1297 // * object: r0 or at sp + 1 * kPointerSize. | 1349 // * object: r3 or at sp + 1 * kPointerSize. |
| 1298 // * function: r1 or at sp. | 1350 // * function: r4 or at sp. |
| 1299 // | 1351 // |
| 1300 // An inlined call site may have been generated before calling this stub. | 1352 // An inlined call site may have been generated before calling this stub. |
| 1301 // In this case the offset to the inline sites to patch are passed in r5 and r6. | 1353 // In this case the offset to the inline site to patch is passed in r8. |
| 1302 // (See LCodeGen::DoInstanceOfKnownGlobal) | 1354 // (See LCodeGen::DoInstanceOfKnownGlobal) |
| 1303 void InstanceofStub::Generate(MacroAssembler* masm) { | 1355 void InstanceofStub::Generate(MacroAssembler* masm) { |
| 1304 // Call site inlining and patching implies arguments in registers. | 1356 // Call site inlining and patching implies arguments in registers. |
| 1305 DCHECK(HasArgsInRegisters() || !HasCallSiteInlineCheck()); | 1357 DCHECK(HasArgsInRegisters() || !HasCallSiteInlineCheck()); |
| 1306 | 1358 |
| 1307 // Fixed register usage throughout the stub: | 1359 // Fixed register usage throughout the stub: |
| 1308 const Register object = r0; // Object (lhs). | 1360 const Register object = r3; // Object (lhs). |
| 1309 Register map = r3; // Map of the object. | 1361 Register map = r6; // Map of the object. |
| 1310 const Register function = r1; // Function (rhs). | 1362 const Register function = r4; // Function (rhs). |
| 1311 const Register prototype = r4; // Prototype of the function. | 1363 const Register prototype = r7; // Prototype of the function. |
| 1312 const Register scratch = r2; | 1364 const Register inline_site = r9; |
| 1365 const Register scratch = r5; |
| 1366 Register scratch3 = no_reg; |
| 1367 |
| 1368 // delta = mov + unaligned LoadP + cmp + bne |
| 1369 #if V8_TARGET_ARCH_PPC64 |
| 1370 const int32_t kDeltaToLoadBoolResult = |
| 1371 (Assembler::kMovInstructions + 4) * Assembler::kInstrSize; |
| 1372 #else |
| 1373 const int32_t kDeltaToLoadBoolResult = |
| 1374 (Assembler::kMovInstructions + 3) * Assembler::kInstrSize; |
| 1375 #endif |
| 1313 | 1376 |
| 1314 Label slow, loop, is_instance, is_not_instance, not_js_object; | 1377 Label slow, loop, is_instance, is_not_instance, not_js_object; |
| 1315 | 1378 |
| 1316 if (!HasArgsInRegisters()) { | 1379 if (!HasArgsInRegisters()) { |
| 1317 __ ldr(object, MemOperand(sp, 1 * kPointerSize)); | 1380 __ LoadP(object, MemOperand(sp, 1 * kPointerSize)); |
| 1318 __ ldr(function, MemOperand(sp, 0)); | 1381 __ LoadP(function, MemOperand(sp, 0)); |
| 1319 } | 1382 } |
| 1320 | 1383 |
| 1321 // Check that the left hand is a JS object and load map. | 1384 // Check that the left hand is a JS object and load map. |
| 1322 __ JumpIfSmi(object, ¬_js_object); | 1385 __ JumpIfSmi(object, ¬_js_object); |
| 1323 __ IsObjectJSObjectType(object, map, scratch, ¬_js_object); | 1386 __ IsObjectJSObjectType(object, map, scratch, ¬_js_object); |
| 1324 | 1387 |
| 1325 // If there is a call site cache don't look in the global cache, but do the | 1388 // If there is a call site cache don't look in the global cache, but do the |
| 1326 // real lookup and update the call site cache. | 1389 // real lookup and update the call site cache. |
| 1327 if (!HasCallSiteInlineCheck() && !ReturnTrueFalseObject()) { | 1390 if (!HasCallSiteInlineCheck() && !ReturnTrueFalseObject()) { |
| 1328 Label miss; | 1391 Label miss; |
| 1329 __ CompareRoot(function, Heap::kInstanceofCacheFunctionRootIndex); | 1392 __ CompareRoot(function, Heap::kInstanceofCacheFunctionRootIndex); |
| 1330 __ b(ne, &miss); | 1393 __ bne(&miss); |
| 1331 __ CompareRoot(map, Heap::kInstanceofCacheMapRootIndex); | 1394 __ CompareRoot(map, Heap::kInstanceofCacheMapRootIndex); |
| 1332 __ b(ne, &miss); | 1395 __ bne(&miss); |
| 1333 __ LoadRoot(r0, Heap::kInstanceofCacheAnswerRootIndex); | 1396 __ LoadRoot(r3, Heap::kInstanceofCacheAnswerRootIndex); |
| 1334 __ Ret(HasArgsInRegisters() ? 0 : 2); | 1397 __ Ret(HasArgsInRegisters() ? 0 : 2); |
| 1335 | 1398 |
| 1336 __ bind(&miss); | 1399 __ bind(&miss); |
| 1337 } | 1400 } |
| 1338 | 1401 |
| 1339 // Get the prototype of the function. | 1402 // Get the prototype of the function. |
| 1340 __ TryGetFunctionPrototype(function, prototype, scratch, &slow, true); | 1403 __ TryGetFunctionPrototype(function, prototype, scratch, &slow, true); |
| 1341 | 1404 |
| 1342 // Check that the function prototype is a JS object. | 1405 // Check that the function prototype is a JS object. |
| 1343 __ JumpIfSmi(prototype, &slow); | 1406 __ JumpIfSmi(prototype, &slow); |
| 1344 __ IsObjectJSObjectType(prototype, scratch, scratch, &slow); | 1407 __ IsObjectJSObjectType(prototype, scratch, scratch, &slow); |
| 1345 | 1408 |
| 1346 // Update the global instanceof or call site inlined cache with the current | 1409 // Update the global instanceof or call site inlined cache with the current |
| 1347 // map and function. The cached answer will be set when it is known below. | 1410 // map and function. The cached answer will be set when it is known below. |
| 1348 if (!HasCallSiteInlineCheck()) { | 1411 if (!HasCallSiteInlineCheck()) { |
| 1349 __ StoreRoot(function, Heap::kInstanceofCacheFunctionRootIndex); | 1412 __ StoreRoot(function, Heap::kInstanceofCacheFunctionRootIndex); |
| 1350 __ StoreRoot(map, Heap::kInstanceofCacheMapRootIndex); | 1413 __ StoreRoot(map, Heap::kInstanceofCacheMapRootIndex); |
| 1351 } else { | 1414 } else { |
| 1352 DCHECK(HasArgsInRegisters()); | 1415 DCHECK(HasArgsInRegisters()); |
| 1353 // Patch the (relocated) inlined map check. | 1416 // Patch the (relocated) inlined map check. |
| 1354 | 1417 |
| 1355 // The map_load_offset was stored in r5 | 1418 // The offset was stored in r8 |
| 1356 // (See LCodeGen::DoDeferredLInstanceOfKnownGlobal). | 1419 // (See LCodeGen::DoDeferredLInstanceOfKnownGlobal). |
| 1357 const Register map_load_offset = r5; | 1420 const Register offset = r8; |
| 1358 __ sub(r9, lr, map_load_offset); | 1421 __ mflr(inline_site); |
| 1359 // Get the map location in r5 and patch it. | 1422 __ sub(inline_site, inline_site, offset); |
| 1360 __ GetRelocatedValueLocation(r9, map_load_offset, scratch); | 1423 // Get the map location in r8 and patch it. |
| 1361 __ ldr(map_load_offset, MemOperand(map_load_offset)); | 1424 __ GetRelocatedValue(inline_site, offset, scratch); |
| 1362 __ str(map, FieldMemOperand(map_load_offset, Cell::kValueOffset)); | 1425 __ StoreP(map, FieldMemOperand(offset, Cell::kValueOffset), r0); |
| 1363 } | 1426 } |
| 1364 | 1427 |
| 1365 // Register mapping: r3 is object map and r4 is function prototype. | 1428 // Register mapping: r6 is object map and r7 is function prototype. |
| 1366 // Get prototype of object into r2. | 1429 // Get prototype of object into r5. |
| 1367 __ ldr(scratch, FieldMemOperand(map, Map::kPrototypeOffset)); | 1430 __ LoadP(scratch, FieldMemOperand(map, Map::kPrototypeOffset)); |
| 1368 | 1431 |
| 1369 // We don't need map any more. Use it as a scratch register. | 1432 // We don't need map any more. Use it as a scratch register. |
| 1370 Register scratch2 = map; | 1433 scratch3 = map; |
| 1371 map = no_reg; | 1434 map = no_reg; |
| 1372 | 1435 |
| 1373 // Loop through the prototype chain looking for the function prototype. | 1436 // Loop through the prototype chain looking for the function prototype. |
| 1374 __ LoadRoot(scratch2, Heap::kNullValueRootIndex); | 1437 __ LoadRoot(scratch3, Heap::kNullValueRootIndex); |
| 1375 __ bind(&loop); | 1438 __ bind(&loop); |
| 1376 __ cmp(scratch, Operand(prototype)); | 1439 __ cmp(scratch, prototype); |
| 1377 __ b(eq, &is_instance); | 1440 __ beq(&is_instance); |
| 1378 __ cmp(scratch, scratch2); | 1441 __ cmp(scratch, scratch3); |
| 1379 __ b(eq, &is_not_instance); | 1442 __ beq(&is_not_instance); |
| 1380 __ ldr(scratch, FieldMemOperand(scratch, HeapObject::kMapOffset)); | 1443 __ LoadP(scratch, FieldMemOperand(scratch, HeapObject::kMapOffset)); |
| 1381 __ ldr(scratch, FieldMemOperand(scratch, Map::kPrototypeOffset)); | 1444 __ LoadP(scratch, FieldMemOperand(scratch, Map::kPrototypeOffset)); |
| 1382 __ jmp(&loop); | 1445 __ b(&loop); |
| 1383 Factory* factory = isolate()->factory(); | 1446 Factory* factory = isolate()->factory(); |
| 1384 | 1447 |
| 1385 __ bind(&is_instance); | 1448 __ bind(&is_instance); |
| 1386 if (!HasCallSiteInlineCheck()) { | 1449 if (!HasCallSiteInlineCheck()) { |
| 1387 __ mov(r0, Operand(Smi::FromInt(0))); | 1450 __ LoadSmiLiteral(r3, Smi::FromInt(0)); |
| 1388 __ StoreRoot(r0, Heap::kInstanceofCacheAnswerRootIndex); | 1451 __ StoreRoot(r3, Heap::kInstanceofCacheAnswerRootIndex); |
| 1389 if (ReturnTrueFalseObject()) { | 1452 if (ReturnTrueFalseObject()) { |
| 1390 __ Move(r0, factory->true_value()); | 1453 __ Move(r3, factory->true_value()); |
| 1391 } | 1454 } |
| 1392 } else { | 1455 } else { |
| 1393 // Patch the call site to return true. | 1456 // Patch the call site to return true. |
| 1394 __ LoadRoot(r0, Heap::kTrueValueRootIndex); | 1457 __ LoadRoot(r3, Heap::kTrueValueRootIndex); |
| 1395 // The bool_load_offset was stored in r6 | 1458 __ addi(inline_site, inline_site, Operand(kDeltaToLoadBoolResult)); |
| 1396 // (See LCodeGen::DoDeferredLInstanceOfKnownGlobal). | |
| 1397 const Register bool_load_offset = r6; | |
| 1398 __ sub(r9, lr, bool_load_offset); | |
| 1399 // Get the boolean result location in scratch and patch it. | 1459 // Get the boolean result location in scratch and patch it. |
| 1400 __ GetRelocatedValueLocation(r9, scratch, scratch2); | 1460 __ SetRelocatedValue(inline_site, scratch, r3); |
| 1401 __ str(r0, MemOperand(scratch)); | |
| 1402 | 1461 |
| 1403 if (!ReturnTrueFalseObject()) { | 1462 if (!ReturnTrueFalseObject()) { |
| 1404 __ mov(r0, Operand(Smi::FromInt(0))); | 1463 __ LoadSmiLiteral(r3, Smi::FromInt(0)); |
| 1405 } | 1464 } |
| 1406 } | 1465 } |
| 1407 __ Ret(HasArgsInRegisters() ? 0 : 2); | 1466 __ Ret(HasArgsInRegisters() ? 0 : 2); |
| 1408 | 1467 |
| 1409 __ bind(&is_not_instance); | 1468 __ bind(&is_not_instance); |
| 1410 if (!HasCallSiteInlineCheck()) { | 1469 if (!HasCallSiteInlineCheck()) { |
| 1411 __ mov(r0, Operand(Smi::FromInt(1))); | 1470 __ LoadSmiLiteral(r3, Smi::FromInt(1)); |
| 1412 __ StoreRoot(r0, Heap::kInstanceofCacheAnswerRootIndex); | 1471 __ StoreRoot(r3, Heap::kInstanceofCacheAnswerRootIndex); |
| 1413 if (ReturnTrueFalseObject()) { | 1472 if (ReturnTrueFalseObject()) { |
| 1414 __ Move(r0, factory->false_value()); | 1473 __ Move(r3, factory->false_value()); |
| 1415 } | 1474 } |
| 1416 } else { | 1475 } else { |
| 1417 // Patch the call site to return false. | 1476 // Patch the call site to return false. |
| 1418 __ LoadRoot(r0, Heap::kFalseValueRootIndex); | 1477 __ LoadRoot(r3, Heap::kFalseValueRootIndex); |
| 1419 // The bool_load_offset was stored in r6 | 1478 __ addi(inline_site, inline_site, Operand(kDeltaToLoadBoolResult)); |
| 1420 // (See LCodeGen::DoDeferredLInstanceOfKnownGlobal). | |
| 1421 const Register bool_load_offset = r6; | |
| 1422 __ sub(r9, lr, bool_load_offset); | |
| 1423 ; | |
| 1424 // Get the boolean result location in scratch and patch it. | 1479 // Get the boolean result location in scratch and patch it. |
| 1425 __ GetRelocatedValueLocation(r9, scratch, scratch2); | 1480 __ SetRelocatedValue(inline_site, scratch, r3); |
| 1426 __ str(r0, MemOperand(scratch)); | |
| 1427 | 1481 |
| 1428 if (!ReturnTrueFalseObject()) { | 1482 if (!ReturnTrueFalseObject()) { |
| 1429 __ mov(r0, Operand(Smi::FromInt(1))); | 1483 __ LoadSmiLiteral(r3, Smi::FromInt(1)); |
| 1430 } | 1484 } |
| 1431 } | 1485 } |
| 1432 __ Ret(HasArgsInRegisters() ? 0 : 2); | 1486 __ Ret(HasArgsInRegisters() ? 0 : 2); |
| 1433 | 1487 |
| 1434 Label object_not_null, object_not_null_or_smi; | 1488 Label object_not_null, object_not_null_or_smi; |
| 1435 __ bind(¬_js_object); | 1489 __ bind(¬_js_object); |
| 1436 // Before null, smi and string value checks, check that the rhs is a function | 1490 // Before null, smi and string value checks, check that the rhs is a function |
| 1437 // as for a non-function rhs an exception needs to be thrown. | 1491 // as for a non-function rhs an exception needs to be thrown. |
| 1438 __ JumpIfSmi(function, &slow); | 1492 __ JumpIfSmi(function, &slow); |
| 1439 __ CompareObjectType(function, scratch2, scratch, JS_FUNCTION_TYPE); | 1493 __ CompareObjectType(function, scratch3, scratch, JS_FUNCTION_TYPE); |
| 1440 __ b(ne, &slow); | 1494 __ bne(&slow); |
| 1441 | 1495 |
| 1442 // Null is not instance of anything. | 1496 // Null is not instance of anything. |
| 1443 __ cmp(scratch, Operand(isolate()->factory()->null_value())); | 1497 __ Cmpi(scratch, Operand(isolate()->factory()->null_value()), r0); |
| 1444 __ b(ne, &object_not_null); | 1498 __ bne(&object_not_null); |
| 1445 if (ReturnTrueFalseObject()) { | 1499 if (ReturnTrueFalseObject()) { |
| 1446 __ Move(r0, factory->false_value()); | 1500 __ Move(r3, factory->false_value()); |
| 1447 } else { | 1501 } else { |
| 1448 __ mov(r0, Operand(Smi::FromInt(1))); | 1502 __ LoadSmiLiteral(r3, Smi::FromInt(1)); |
| 1449 } | 1503 } |
| 1450 __ Ret(HasArgsInRegisters() ? 0 : 2); | 1504 __ Ret(HasArgsInRegisters() ? 0 : 2); |
| 1451 | 1505 |
| 1452 __ bind(&object_not_null); | 1506 __ bind(&object_not_null); |
| 1453 // Smi values are not instances of anything. | 1507 // Smi values are not instances of anything. |
| 1454 __ JumpIfNotSmi(object, &object_not_null_or_smi); | 1508 __ JumpIfNotSmi(object, &object_not_null_or_smi); |
| 1455 if (ReturnTrueFalseObject()) { | 1509 if (ReturnTrueFalseObject()) { |
| 1456 __ Move(r0, factory->false_value()); | 1510 __ Move(r3, factory->false_value()); |
| 1457 } else { | 1511 } else { |
| 1458 __ mov(r0, Operand(Smi::FromInt(1))); | 1512 __ LoadSmiLiteral(r3, Smi::FromInt(1)); |
| 1459 } | 1513 } |
| 1460 __ Ret(HasArgsInRegisters() ? 0 : 2); | 1514 __ Ret(HasArgsInRegisters() ? 0 : 2); |
| 1461 | 1515 |
| 1462 __ bind(&object_not_null_or_smi); | 1516 __ bind(&object_not_null_or_smi); |
| 1463 // String values are not instances of anything. | 1517 // String values are not instances of anything. |
| 1464 __ IsObjectJSStringType(object, scratch, &slow); | 1518 __ IsObjectJSStringType(object, scratch, &slow); |
| 1465 if (ReturnTrueFalseObject()) { | 1519 if (ReturnTrueFalseObject()) { |
| 1466 __ Move(r0, factory->false_value()); | 1520 __ Move(r3, factory->false_value()); |
| 1467 } else { | 1521 } else { |
| 1468 __ mov(r0, Operand(Smi::FromInt(1))); | 1522 __ LoadSmiLiteral(r3, Smi::FromInt(1)); |
| 1469 } | 1523 } |
| 1470 __ Ret(HasArgsInRegisters() ? 0 : 2); | 1524 __ Ret(HasArgsInRegisters() ? 0 : 2); |
| 1471 | 1525 |
| 1472 // Slow-case. Tail call builtin. | 1526 // Slow-case. Tail call builtin. |
| 1473 __ bind(&slow); | 1527 __ bind(&slow); |
| 1474 if (!ReturnTrueFalseObject()) { | 1528 if (!ReturnTrueFalseObject()) { |
| 1475 if (HasArgsInRegisters()) { | 1529 if (HasArgsInRegisters()) { |
| 1476 __ Push(r0, r1); | 1530 __ Push(r3, r4); |
| 1477 } | 1531 } |
| 1478 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); | 1532 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); |
| 1479 } else { | 1533 } else { |
| 1480 { | 1534 { |
| 1481 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 1535 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
| 1482 __ Push(r0, r1); | 1536 __ Push(r3, r4); |
| 1483 __ InvokeBuiltin(Builtins::INSTANCE_OF, CALL_FUNCTION); | 1537 __ InvokeBuiltin(Builtins::INSTANCE_OF, CALL_FUNCTION); |
| 1484 } | 1538 } |
| 1485 __ cmp(r0, Operand::Zero()); | 1539 Label true_value, done; |
| 1486 __ LoadRoot(r0, Heap::kTrueValueRootIndex, eq); | 1540 __ cmpi(r3, Operand::Zero()); |
| 1487 __ LoadRoot(r0, Heap::kFalseValueRootIndex, ne); | 1541 __ beq(&true_value); |
| 1542 |
| 1543 __ LoadRoot(r3, Heap::kFalseValueRootIndex); |
| 1544 __ b(&done); |
| 1545 |
| 1546 __ bind(&true_value); |
| 1547 __ LoadRoot(r3, Heap::kTrueValueRootIndex); |
| 1548 |
| 1549 __ bind(&done); |
| 1488 __ Ret(HasArgsInRegisters() ? 0 : 2); | 1550 __ Ret(HasArgsInRegisters() ? 0 : 2); |
| 1489 } | 1551 } |
| 1490 } | 1552 } |
| 1491 | 1553 |
| 1492 | 1554 |
| 1493 void FunctionPrototypeStub::Generate(MacroAssembler* masm) { | 1555 void FunctionPrototypeStub::Generate(MacroAssembler* masm) { |
| 1494 Label miss; | 1556 Label miss; |
| 1495 Register receiver = LoadDescriptor::ReceiverRegister(); | 1557 Register receiver = LoadDescriptor::ReceiverRegister(); |
| 1496 | 1558 |
| 1497 NamedLoadHandlerCompiler::GenerateLoadFunctionPrototype(masm, receiver, r3, | 1559 NamedLoadHandlerCompiler::GenerateLoadFunctionPrototype(masm, receiver, r6, |
| 1498 r4, &miss); | 1560 r7, &miss); |
| 1499 __ bind(&miss); | 1561 __ bind(&miss); |
| 1500 PropertyAccessCompiler::TailCallBuiltin( | 1562 PropertyAccessCompiler::TailCallBuiltin( |
| 1501 masm, PropertyAccessCompiler::MissBuiltin(Code::LOAD_IC)); | 1563 masm, PropertyAccessCompiler::MissBuiltin(Code::LOAD_IC)); |
| 1502 } | 1564 } |
| 1503 | 1565 |
| 1504 | 1566 |
| 1505 void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { | 1567 void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { |
| 1506 // The displacement is the offset of the last parameter (if any) | 1568 // The displacement is the offset of the last parameter (if any) |
| 1507 // relative to the frame pointer. | 1569 // relative to the frame pointer. |
| 1508 const int kDisplacement = | 1570 const int kDisplacement = |
| 1509 StandardFrameConstants::kCallerSPOffset - kPointerSize; | 1571 StandardFrameConstants::kCallerSPOffset - kPointerSize; |
| 1510 DCHECK(r1.is(ArgumentsAccessReadDescriptor::index())); | 1572 DCHECK(r4.is(ArgumentsAccessReadDescriptor::index())); |
| 1511 DCHECK(r0.is(ArgumentsAccessReadDescriptor::parameter_count())); | 1573 DCHECK(r3.is(ArgumentsAccessReadDescriptor::parameter_count())); |
| 1512 | 1574 |
| 1513 // Check that the key is a smi. | 1575 // Check that the key is a smi. |
| 1514 Label slow; | 1576 Label slow; |
| 1515 __ JumpIfNotSmi(r1, &slow); | 1577 __ JumpIfNotSmi(r4, &slow); |
| 1516 | 1578 |
| 1517 // Check if the calling frame is an arguments adaptor frame. | 1579 // Check if the calling frame is an arguments adaptor frame. |
| 1518 Label adaptor; | 1580 Label adaptor; |
| 1519 __ ldr(r2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | 1581 __ LoadP(r5, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
| 1520 __ ldr(r3, MemOperand(r2, StandardFrameConstants::kContextOffset)); | 1582 __ LoadP(r6, MemOperand(r5, StandardFrameConstants::kContextOffset)); |
| 1521 __ cmp(r3, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 1583 STATIC_ASSERT(StackFrame::ARGUMENTS_ADAPTOR < 0x3fffu); |
| 1522 __ b(eq, &adaptor); | 1584 __ CmpSmiLiteral(r6, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0); |
| 1585 __ beq(&adaptor); |
| 1523 | 1586 |
| 1524 // Check index against formal parameters count limit passed in | 1587 // Check index against formal parameters count limit passed in |
| 1525 // through register r0. Use unsigned comparison to get negative | 1588 // through register r3. Use unsigned comparison to get negative |
| 1526 // check for free. | 1589 // check for free. |
| 1527 __ cmp(r1, r0); | 1590 __ cmpl(r4, r3); |
| 1528 __ b(hs, &slow); | 1591 __ bge(&slow); |
| 1529 | 1592 |
| 1530 // Read the argument from the stack and return it. | 1593 // Read the argument from the stack and return it. |
| 1531 __ sub(r3, r0, r1); | 1594 __ sub(r6, r3, r4); |
| 1532 __ add(r3, fp, Operand::PointerOffsetFromSmiKey(r3)); | 1595 __ SmiToPtrArrayOffset(r6, r6); |
| 1533 __ ldr(r0, MemOperand(r3, kDisplacement)); | 1596 __ add(r6, fp, r6); |
| 1534 __ Jump(lr); | 1597 __ LoadP(r3, MemOperand(r6, kDisplacement)); |
| 1598 __ blr(); |
| 1535 | 1599 |
| 1536 // Arguments adaptor case: Check index against actual arguments | 1600 // Arguments adaptor case: Check index against actual arguments |
| 1537 // limit found in the arguments adaptor frame. Use unsigned | 1601 // limit found in the arguments adaptor frame. Use unsigned |
| 1538 // comparison to get negative check for free. | 1602 // comparison to get negative check for free. |
| 1539 __ bind(&adaptor); | 1603 __ bind(&adaptor); |
| 1540 __ ldr(r0, MemOperand(r2, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 1604 __ LoadP(r3, MemOperand(r5, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
| 1541 __ cmp(r1, r0); | 1605 __ cmpl(r4, r3); |
| 1542 __ b(cs, &slow); | 1606 __ bge(&slow); |
| 1543 | 1607 |
| 1544 // Read the argument from the adaptor frame and return it. | 1608 // Read the argument from the adaptor frame and return it. |
| 1545 __ sub(r3, r0, r1); | 1609 __ sub(r6, r3, r4); |
| 1546 __ add(r3, r2, Operand::PointerOffsetFromSmiKey(r3)); | 1610 __ SmiToPtrArrayOffset(r6, r6); |
| 1547 __ ldr(r0, MemOperand(r3, kDisplacement)); | 1611 __ add(r6, r5, r6); |
| 1548 __ Jump(lr); | 1612 __ LoadP(r3, MemOperand(r6, kDisplacement)); |
| 1613 __ blr(); |
| 1549 | 1614 |
| 1550 // Slow-case: Handle non-smi or out-of-bounds access to arguments | 1615 // Slow-case: Handle non-smi or out-of-bounds access to arguments |
| 1551 // by calling the runtime system. | 1616 // by calling the runtime system. |
| 1552 __ bind(&slow); | 1617 __ bind(&slow); |
| 1553 __ push(r1); | 1618 __ push(r4); |
| 1554 __ TailCallRuntime(Runtime::kGetArgumentsProperty, 1, 1); | 1619 __ TailCallRuntime(Runtime::kGetArgumentsProperty, 1, 1); |
| 1555 } | 1620 } |
| 1556 | 1621 |
| 1557 | 1622 |
| 1558 void ArgumentsAccessStub::GenerateNewSloppySlow(MacroAssembler* masm) { | 1623 void ArgumentsAccessStub::GenerateNewSloppySlow(MacroAssembler* masm) { |
| 1559 // sp[0] : number of parameters | 1624 // sp[0] : number of parameters |
| 1560 // sp[4] : receiver displacement | 1625 // sp[1] : receiver displacement |
| 1561 // sp[8] : function | 1626 // sp[2] : function |
| 1562 | 1627 |
| 1563 // Check if the calling frame is an arguments adaptor frame. | 1628 // Check if the calling frame is an arguments adaptor frame. |
| 1564 Label runtime; | 1629 Label runtime; |
| 1565 __ ldr(r3, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | 1630 __ LoadP(r6, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
| 1566 __ ldr(r2, MemOperand(r3, StandardFrameConstants::kContextOffset)); | 1631 __ LoadP(r5, MemOperand(r6, StandardFrameConstants::kContextOffset)); |
| 1567 __ cmp(r2, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 1632 STATIC_ASSERT(StackFrame::ARGUMENTS_ADAPTOR < 0x3fffu); |
| 1568 __ b(ne, &runtime); | 1633 __ CmpSmiLiteral(r5, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0); |
| 1634 __ bne(&runtime); |
| 1569 | 1635 |
| 1570 // Patch the arguments.length and the parameters pointer in the current frame. | 1636 // Patch the arguments.length and the parameters pointer in the current frame. |
| 1571 __ ldr(r2, MemOperand(r3, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 1637 __ LoadP(r5, MemOperand(r6, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
| 1572 __ str(r2, MemOperand(sp, 0 * kPointerSize)); | 1638 __ StoreP(r5, MemOperand(sp, 0 * kPointerSize)); |
| 1573 __ add(r3, r3, Operand(r2, LSL, 1)); | 1639 __ SmiToPtrArrayOffset(r5, r5); |
| 1574 __ add(r3, r3, Operand(StandardFrameConstants::kCallerSPOffset)); | 1640 __ add(r6, r6, r5); |
| 1575 __ str(r3, MemOperand(sp, 1 * kPointerSize)); | 1641 __ addi(r6, r6, Operand(StandardFrameConstants::kCallerSPOffset)); |
| 1642 __ StoreP(r6, MemOperand(sp, 1 * kPointerSize)); |
| 1576 | 1643 |
| 1577 __ bind(&runtime); | 1644 __ bind(&runtime); |
| 1578 __ TailCallRuntime(Runtime::kNewSloppyArguments, 3, 1); | 1645 __ TailCallRuntime(Runtime::kNewSloppyArguments, 3, 1); |
| 1579 } | 1646 } |
| 1580 | 1647 |
| 1581 | 1648 |
| 1582 void ArgumentsAccessStub::GenerateNewSloppyFast(MacroAssembler* masm) { | 1649 void ArgumentsAccessStub::GenerateNewSloppyFast(MacroAssembler* masm) { |
| 1583 // Stack layout: | 1650 // Stack layout: |
| 1584 // sp[0] : number of parameters (tagged) | 1651 // sp[0] : number of parameters (tagged) |
| 1585 // sp[4] : address of receiver argument | 1652 // sp[1] : address of receiver argument |
| 1586 // sp[8] : function | 1653 // sp[2] : function |
| 1587 // Registers used over whole function: | 1654 // Registers used over whole function: |
| 1588 // r6 : allocated object (tagged) | 1655 // r9 : allocated object (tagged) |
| 1589 // r9 : mapped parameter count (tagged) | 1656 // r11 : mapped parameter count (tagged) |
| 1590 | 1657 |
| 1591 __ ldr(r1, MemOperand(sp, 0 * kPointerSize)); | 1658 __ LoadP(r4, MemOperand(sp, 0 * kPointerSize)); |
| 1592 // r1 = parameter count (tagged) | 1659 // r4 = parameter count (tagged) |
| 1593 | 1660 |
| 1594 // Check if the calling frame is an arguments adaptor frame. | 1661 // Check if the calling frame is an arguments adaptor frame. |
| 1595 Label runtime; | 1662 Label runtime; |
| 1596 Label adaptor_frame, try_allocate; | 1663 Label adaptor_frame, try_allocate; |
| 1597 __ ldr(r3, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | 1664 __ LoadP(r6, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
| 1598 __ ldr(r2, MemOperand(r3, StandardFrameConstants::kContextOffset)); | 1665 __ LoadP(r5, MemOperand(r6, StandardFrameConstants::kContextOffset)); |
| 1599 __ cmp(r2, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 1666 STATIC_ASSERT(StackFrame::ARGUMENTS_ADAPTOR < 0x3fffu); |
| 1600 __ b(eq, &adaptor_frame); | 1667 __ CmpSmiLiteral(r5, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0); |
| 1668 __ beq(&adaptor_frame); |
| 1601 | 1669 |
| 1602 // No adaptor, parameter count = argument count. | 1670 // No adaptor, parameter count = argument count. |
| 1603 __ mov(r2, r1); | 1671 __ mr(r5, r4); |
| 1604 __ b(&try_allocate); | 1672 __ b(&try_allocate); |
| 1605 | 1673 |
| 1606 // We have an adaptor frame. Patch the parameters pointer. | 1674 // We have an adaptor frame. Patch the parameters pointer. |
| 1607 __ bind(&adaptor_frame); | 1675 __ bind(&adaptor_frame); |
| 1608 __ ldr(r2, MemOperand(r3, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 1676 __ LoadP(r5, MemOperand(r6, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
| 1609 __ add(r3, r3, Operand(r2, LSL, 1)); | 1677 __ SmiToPtrArrayOffset(r7, r5); |
| 1610 __ add(r3, r3, Operand(StandardFrameConstants::kCallerSPOffset)); | 1678 __ add(r6, r6, r7); |
| 1611 __ str(r3, MemOperand(sp, 1 * kPointerSize)); | 1679 __ addi(r6, r6, Operand(StandardFrameConstants::kCallerSPOffset)); |
| 1680 __ StoreP(r6, MemOperand(sp, 1 * kPointerSize)); |
| 1612 | 1681 |
| 1613 // r1 = parameter count (tagged) | 1682 // r4 = parameter count (tagged) |
| 1614 // r2 = argument count (tagged) | 1683 // r5 = argument count (tagged) |
| 1615 // Compute the mapped parameter count = min(r1, r2) in r1. | 1684 // Compute the mapped parameter count = min(r4, r5) in r4. |
| 1616 __ cmp(r1, Operand(r2)); | 1685 Label skip; |
| 1617 __ mov(r1, Operand(r2), LeaveCC, gt); | 1686 __ cmp(r4, r5); |
| 1687 __ blt(&skip); |
| 1688 __ mr(r4, r5); |
| 1689 __ bind(&skip); |
| 1618 | 1690 |
| 1619 __ bind(&try_allocate); | 1691 __ bind(&try_allocate); |
| 1620 | 1692 |
| 1621 // Compute the sizes of backing store, parameter map, and arguments object. | 1693 // Compute the sizes of backing store, parameter map, and arguments object. |
| 1622 // 1. Parameter map, has 2 extra words containing context and backing store. | 1694 // 1. Parameter map, has 2 extra words containing context and backing store. |
| 1623 const int kParameterMapHeaderSize = | 1695 const int kParameterMapHeaderSize = |
| 1624 FixedArray::kHeaderSize + 2 * kPointerSize; | 1696 FixedArray::kHeaderSize + 2 * kPointerSize; |
| 1625 // If there are no mapped parameters, we do not need the parameter_map. | 1697 // If there are no mapped parameters, we do not need the parameter_map. |
| 1626 __ cmp(r1, Operand(Smi::FromInt(0))); | 1698 Label skip2, skip3; |
| 1627 __ mov(r9, Operand::Zero(), LeaveCC, eq); | 1699 __ CmpSmiLiteral(r4, Smi::FromInt(0), r0); |
| 1628 __ mov(r9, Operand(r1, LSL, 1), LeaveCC, ne); | 1700 __ bne(&skip2); |
| 1629 __ add(r9, r9, Operand(kParameterMapHeaderSize), LeaveCC, ne); | 1701 __ li(r11, Operand::Zero()); |
| 1702 __ b(&skip3); |
| 1703 __ bind(&skip2); |
| 1704 __ SmiToPtrArrayOffset(r11, r4); |
| 1705 __ addi(r11, r11, Operand(kParameterMapHeaderSize)); |
| 1706 __ bind(&skip3); |
| 1630 | 1707 |
| 1631 // 2. Backing store. | 1708 // 2. Backing store. |
| 1632 __ add(r9, r9, Operand(r2, LSL, 1)); | 1709 __ SmiToPtrArrayOffset(r7, r5); |
| 1633 __ add(r9, r9, Operand(FixedArray::kHeaderSize)); | 1710 __ add(r11, r11, r7); |
| 1711 __ addi(r11, r11, Operand(FixedArray::kHeaderSize)); |
| 1634 | 1712 |
| 1635 // 3. Arguments object. | 1713 // 3. Arguments object. |
| 1636 __ add(r9, r9, Operand(Heap::kSloppyArgumentsObjectSize)); | 1714 __ addi(r11, r11, Operand(Heap::kSloppyArgumentsObjectSize)); |
| 1637 | 1715 |
| 1638 // Do the allocation of all three objects in one go. | 1716 // Do the allocation of all three objects in one go. |
| 1639 __ Allocate(r9, r0, r3, r4, &runtime, TAG_OBJECT); | 1717 __ Allocate(r11, r3, r6, r7, &runtime, TAG_OBJECT); |
| 1640 | 1718 |
| 1641 // r0 = address of new object(s) (tagged) | 1719 // r3 = address of new object(s) (tagged) |
| 1642 // r2 = argument count (smi-tagged) | 1720 // r5 = argument count (smi-tagged) |
| 1643 // Get the arguments boilerplate from the current native context into r4. | 1721 // Get the arguments boilerplate from the current native context into r4. |
| 1644 const int kNormalOffset = | 1722 const int kNormalOffset = |
| 1645 Context::SlotOffset(Context::SLOPPY_ARGUMENTS_MAP_INDEX); | 1723 Context::SlotOffset(Context::SLOPPY_ARGUMENTS_MAP_INDEX); |
| 1646 const int kAliasedOffset = | 1724 const int kAliasedOffset = |
| 1647 Context::SlotOffset(Context::ALIASED_ARGUMENTS_MAP_INDEX); | 1725 Context::SlotOffset(Context::ALIASED_ARGUMENTS_MAP_INDEX); |
| 1648 | 1726 |
| 1649 __ ldr(r4, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 1727 __ LoadP(r7, |
| 1650 __ ldr(r4, FieldMemOperand(r4, GlobalObject::kNativeContextOffset)); | 1728 MemOperand(cp, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
| 1651 __ cmp(r1, Operand::Zero()); | 1729 __ LoadP(r7, FieldMemOperand(r7, GlobalObject::kNativeContextOffset)); |
| 1652 __ ldr(r4, MemOperand(r4, kNormalOffset), eq); | 1730 Label skip4, skip5; |
| 1653 __ ldr(r4, MemOperand(r4, kAliasedOffset), ne); | 1731 __ cmpi(r4, Operand::Zero()); |
| 1732 __ bne(&skip4); |
| 1733 __ LoadP(r7, MemOperand(r7, kNormalOffset)); |
| 1734 __ b(&skip5); |
| 1735 __ bind(&skip4); |
| 1736 __ LoadP(r7, MemOperand(r7, kAliasedOffset)); |
| 1737 __ bind(&skip5); |
| 1654 | 1738 |
| 1655 // r0 = address of new object (tagged) | 1739 // r3 = address of new object (tagged) |
| 1656 // r1 = mapped parameter count (tagged) | 1740 // r4 = mapped parameter count (tagged) |
| 1657 // r2 = argument count (smi-tagged) | 1741 // r5 = argument count (smi-tagged) |
| 1658 // r4 = address of arguments map (tagged) | 1742 // r7 = address of arguments map (tagged) |
| 1659 __ str(r4, FieldMemOperand(r0, JSObject::kMapOffset)); | 1743 __ StoreP(r7, FieldMemOperand(r3, JSObject::kMapOffset), r0); |
| 1660 __ LoadRoot(r3, Heap::kEmptyFixedArrayRootIndex); | 1744 __ LoadRoot(r6, Heap::kEmptyFixedArrayRootIndex); |
| 1661 __ str(r3, FieldMemOperand(r0, JSObject::kPropertiesOffset)); | 1745 __ StoreP(r6, FieldMemOperand(r3, JSObject::kPropertiesOffset), r0); |
| 1662 __ str(r3, FieldMemOperand(r0, JSObject::kElementsOffset)); | 1746 __ StoreP(r6, FieldMemOperand(r3, JSObject::kElementsOffset), r0); |
| 1663 | 1747 |
| 1664 // Set up the callee in-object property. | 1748 // Set up the callee in-object property. |
| 1665 STATIC_ASSERT(Heap::kArgumentsCalleeIndex == 1); | 1749 STATIC_ASSERT(Heap::kArgumentsCalleeIndex == 1); |
| 1666 __ ldr(r3, MemOperand(sp, 2 * kPointerSize)); | 1750 __ LoadP(r6, MemOperand(sp, 2 * kPointerSize)); |
| 1667 __ AssertNotSmi(r3); | 1751 __ AssertNotSmi(r6); |
| 1668 const int kCalleeOffset = JSObject::kHeaderSize + | 1752 const int kCalleeOffset = |
| 1669 Heap::kArgumentsCalleeIndex * kPointerSize; | 1753 JSObject::kHeaderSize + Heap::kArgumentsCalleeIndex * kPointerSize; |
| 1670 __ str(r3, FieldMemOperand(r0, kCalleeOffset)); | 1754 __ StoreP(r6, FieldMemOperand(r3, kCalleeOffset), r0); |
| 1671 | 1755 |
| 1672 // Use the length (smi tagged) and set that as an in-object property too. | 1756 // Use the length (smi tagged) and set that as an in-object property too. |
| 1673 __ AssertSmi(r2); | 1757 __ AssertSmi(r5); |
| 1674 STATIC_ASSERT(Heap::kArgumentsLengthIndex == 0); | 1758 STATIC_ASSERT(Heap::kArgumentsLengthIndex == 0); |
| 1675 const int kLengthOffset = JSObject::kHeaderSize + | 1759 const int kLengthOffset = |
| 1676 Heap::kArgumentsLengthIndex * kPointerSize; | 1760 JSObject::kHeaderSize + Heap::kArgumentsLengthIndex * kPointerSize; |
| 1677 __ str(r2, FieldMemOperand(r0, kLengthOffset)); | 1761 __ StoreP(r5, FieldMemOperand(r3, kLengthOffset), r0); |
| 1678 | 1762 |
| 1679 // Set up the elements pointer in the allocated arguments object. | 1763 // Set up the elements pointer in the allocated arguments object. |
| 1680 // If we allocated a parameter map, r4 will point there, otherwise | 1764 // If we allocated a parameter map, r7 will point there, otherwise |
| 1681 // it will point to the backing store. | 1765 // it will point to the backing store. |
| 1682 __ add(r4, r0, Operand(Heap::kSloppyArgumentsObjectSize)); | 1766 __ addi(r7, r3, Operand(Heap::kSloppyArgumentsObjectSize)); |
| 1683 __ str(r4, FieldMemOperand(r0, JSObject::kElementsOffset)); | 1767 __ StoreP(r7, FieldMemOperand(r3, JSObject::kElementsOffset), r0); |
| 1684 | 1768 |
| 1685 // r0 = address of new object (tagged) | 1769 // r3 = address of new object (tagged) |
| 1686 // r1 = mapped parameter count (tagged) | 1770 // r4 = mapped parameter count (tagged) |
| 1687 // r2 = argument count (tagged) | 1771 // r5 = argument count (tagged) |
| 1688 // r4 = address of parameter map or backing store (tagged) | 1772 // r7 = address of parameter map or backing store (tagged) |
| 1689 // Initialize parameter map. If there are no mapped arguments, we're done. | 1773 // Initialize parameter map. If there are no mapped arguments, we're done. |
| 1690 Label skip_parameter_map; | 1774 Label skip_parameter_map, skip6; |
| 1691 __ cmp(r1, Operand(Smi::FromInt(0))); | 1775 __ CmpSmiLiteral(r4, Smi::FromInt(0), r0); |
| 1692 // Move backing store address to r3, because it is | 1776 __ bne(&skip6); |
| 1777 // Move backing store address to r6, because it is |
| 1693 // expected there when filling in the unmapped arguments. | 1778 // expected there when filling in the unmapped arguments. |
| 1694 __ mov(r3, r4, LeaveCC, eq); | 1779 __ mr(r6, r7); |
| 1695 __ b(eq, &skip_parameter_map); | 1780 __ b(&skip_parameter_map); |
| 1781 __ bind(&skip6); |
| 1696 | 1782 |
| 1697 __ LoadRoot(r6, Heap::kSloppyArgumentsElementsMapRootIndex); | 1783 __ LoadRoot(r9, Heap::kSloppyArgumentsElementsMapRootIndex); |
| 1698 __ str(r6, FieldMemOperand(r4, FixedArray::kMapOffset)); | 1784 __ StoreP(r9, FieldMemOperand(r7, FixedArray::kMapOffset), r0); |
| 1699 __ add(r6, r1, Operand(Smi::FromInt(2))); | 1785 __ AddSmiLiteral(r9, r4, Smi::FromInt(2), r0); |
| 1700 __ str(r6, FieldMemOperand(r4, FixedArray::kLengthOffset)); | 1786 __ StoreP(r9, FieldMemOperand(r7, FixedArray::kLengthOffset), r0); |
| 1701 __ str(cp, FieldMemOperand(r4, FixedArray::kHeaderSize + 0 * kPointerSize)); | 1787 __ StoreP(cp, FieldMemOperand(r7, FixedArray::kHeaderSize + 0 * kPointerSize), |
| 1702 __ add(r6, r4, Operand(r1, LSL, 1)); | 1788 r0); |
| 1703 __ add(r6, r6, Operand(kParameterMapHeaderSize)); | 1789 __ SmiToPtrArrayOffset(r9, r4); |
| 1704 __ str(r6, FieldMemOperand(r4, FixedArray::kHeaderSize + 1 * kPointerSize)); | 1790 __ add(r9, r7, r9); |
| 1791 __ addi(r9, r9, Operand(kParameterMapHeaderSize)); |
| 1792 __ StoreP(r9, FieldMemOperand(r7, FixedArray::kHeaderSize + 1 * kPointerSize), |
| 1793 r0); |
| 1705 | 1794 |
| 1706 // Copy the parameter slots and the holes in the arguments. | 1795 // Copy the parameter slots and the holes in the arguments. |
| 1707 // We need to fill in mapped_parameter_count slots. They index the context, | 1796 // We need to fill in mapped_parameter_count slots. They index the context, |
| 1708 // where parameters are stored in reverse order, at | 1797 // where parameters are stored in reverse order, at |
| 1709 // MIN_CONTEXT_SLOTS .. MIN_CONTEXT_SLOTS+parameter_count-1 | 1798 // MIN_CONTEXT_SLOTS .. MIN_CONTEXT_SLOTS+parameter_count-1 |
| 1710 // The mapped parameter thus need to get indices | 1799 // The mapped parameter thus need to get indices |
| 1711 // MIN_CONTEXT_SLOTS+parameter_count-1 .. | 1800 // MIN_CONTEXT_SLOTS+parameter_count-1 .. |
| 1712 // MIN_CONTEXT_SLOTS+parameter_count-mapped_parameter_count | 1801 // MIN_CONTEXT_SLOTS+parameter_count-mapped_parameter_count |
| 1713 // We loop from right to left. | 1802 // We loop from right to left. |
| 1714 Label parameters_loop, parameters_test; | 1803 Label parameters_loop, parameters_test; |
| 1715 __ mov(r6, r1); | 1804 __ mr(r9, r4); |
| 1716 __ ldr(r9, MemOperand(sp, 0 * kPointerSize)); | 1805 __ LoadP(r11, MemOperand(sp, 0 * kPointerSize)); |
| 1717 __ add(r9, r9, Operand(Smi::FromInt(Context::MIN_CONTEXT_SLOTS))); | 1806 __ AddSmiLiteral(r11, r11, Smi::FromInt(Context::MIN_CONTEXT_SLOTS), r0); |
| 1718 __ sub(r9, r9, Operand(r1)); | 1807 __ sub(r11, r11, r4); |
| 1719 __ LoadRoot(r5, Heap::kTheHoleValueRootIndex); | 1808 __ LoadRoot(r10, Heap::kTheHoleValueRootIndex); |
| 1720 __ add(r3, r4, Operand(r6, LSL, 1)); | 1809 __ SmiToPtrArrayOffset(r6, r9); |
| 1721 __ add(r3, r3, Operand(kParameterMapHeaderSize)); | 1810 __ add(r6, r7, r6); |
| 1811 __ addi(r6, r6, Operand(kParameterMapHeaderSize)); |
| 1722 | 1812 |
| 1723 // r6 = loop variable (tagged) | 1813 // r9 = loop variable (tagged) |
| 1724 // r1 = mapping index (tagged) | 1814 // r4 = mapping index (tagged) |
| 1725 // r3 = address of backing store (tagged) | 1815 // r6 = address of backing store (tagged) |
| 1726 // r4 = address of parameter map (tagged), which is also the address of new | 1816 // r7 = address of parameter map (tagged) |
| 1727 // object + Heap::kSloppyArgumentsObjectSize (tagged) | 1817 // r8 = temporary scratch (a.o., for address calculation) |
| 1728 // r0 = temporary scratch (a.o., for address calculation) | 1818 // r10 = the hole value |
| 1729 // r5 = the hole value | 1819 __ b(¶meters_test); |
| 1730 __ jmp(¶meters_test); | |
| 1731 | 1820 |
| 1732 __ bind(¶meters_loop); | 1821 __ bind(¶meters_loop); |
| 1733 __ sub(r6, r6, Operand(Smi::FromInt(1))); | 1822 __ SubSmiLiteral(r9, r9, Smi::FromInt(1), r0); |
| 1734 __ mov(r0, Operand(r6, LSL, 1)); | 1823 __ SmiToPtrArrayOffset(r8, r9); |
| 1735 __ add(r0, r0, Operand(kParameterMapHeaderSize - kHeapObjectTag)); | 1824 __ addi(r8, r8, Operand(kParameterMapHeaderSize - kHeapObjectTag)); |
| 1736 __ str(r9, MemOperand(r4, r0)); | 1825 __ StorePX(r11, MemOperand(r8, r7)); |
| 1737 __ sub(r0, r0, Operand(kParameterMapHeaderSize - FixedArray::kHeaderSize)); | 1826 __ subi(r8, r8, Operand(kParameterMapHeaderSize - FixedArray::kHeaderSize)); |
| 1738 __ str(r5, MemOperand(r3, r0)); | 1827 __ StorePX(r10, MemOperand(r8, r6)); |
| 1739 __ add(r9, r9, Operand(Smi::FromInt(1))); | 1828 __ AddSmiLiteral(r11, r11, Smi::FromInt(1), r0); |
| 1740 __ bind(¶meters_test); | 1829 __ bind(¶meters_test); |
| 1741 __ cmp(r6, Operand(Smi::FromInt(0))); | 1830 __ CmpSmiLiteral(r9, Smi::FromInt(0), r0); |
| 1742 __ b(ne, ¶meters_loop); | 1831 __ bne(¶meters_loop); |
| 1743 | |
| 1744 // Restore r0 = new object (tagged) | |
| 1745 __ sub(r0, r4, Operand(Heap::kSloppyArgumentsObjectSize)); | |
| 1746 | 1832 |
| 1747 __ bind(&skip_parameter_map); | 1833 __ bind(&skip_parameter_map); |
| 1748 // r0 = address of new object (tagged) | 1834 // r5 = argument count (tagged) |
| 1749 // r2 = argument count (tagged) | 1835 // r6 = address of backing store (tagged) |
| 1750 // r3 = address of backing store (tagged) | 1836 // r8 = scratch |
| 1751 // r5 = scratch | |
| 1752 // Copy arguments header and remaining slots (if there are any). | 1837 // Copy arguments header and remaining slots (if there are any). |
| 1753 __ LoadRoot(r5, Heap::kFixedArrayMapRootIndex); | 1838 __ LoadRoot(r8, Heap::kFixedArrayMapRootIndex); |
| 1754 __ str(r5, FieldMemOperand(r3, FixedArray::kMapOffset)); | 1839 __ StoreP(r8, FieldMemOperand(r6, FixedArray::kMapOffset), r0); |
| 1755 __ str(r2, FieldMemOperand(r3, FixedArray::kLengthOffset)); | 1840 __ StoreP(r5, FieldMemOperand(r6, FixedArray::kLengthOffset), r0); |
| 1756 | 1841 |
| 1757 Label arguments_loop, arguments_test; | 1842 Label arguments_loop, arguments_test; |
| 1758 __ mov(r9, r1); | 1843 __ mr(r11, r4); |
| 1759 __ ldr(r4, MemOperand(sp, 1 * kPointerSize)); | 1844 __ LoadP(r7, MemOperand(sp, 1 * kPointerSize)); |
| 1760 __ sub(r4, r4, Operand(r9, LSL, 1)); | 1845 __ SmiToPtrArrayOffset(r8, r11); |
| 1761 __ jmp(&arguments_test); | 1846 __ sub(r7, r7, r8); |
| 1847 __ b(&arguments_test); |
| 1762 | 1848 |
| 1763 __ bind(&arguments_loop); | 1849 __ bind(&arguments_loop); |
| 1764 __ sub(r4, r4, Operand(kPointerSize)); | 1850 __ subi(r7, r7, Operand(kPointerSize)); |
| 1765 __ ldr(r6, MemOperand(r4, 0)); | 1851 __ LoadP(r9, MemOperand(r7, 0)); |
| 1766 __ add(r5, r3, Operand(r9, LSL, 1)); | 1852 __ SmiToPtrArrayOffset(r8, r11); |
| 1767 __ str(r6, FieldMemOperand(r5, FixedArray::kHeaderSize)); | 1853 __ add(r8, r6, r8); |
| 1768 __ add(r9, r9, Operand(Smi::FromInt(1))); | 1854 __ StoreP(r9, FieldMemOperand(r8, FixedArray::kHeaderSize), r0); |
| 1855 __ AddSmiLiteral(r11, r11, Smi::FromInt(1), r0); |
| 1769 | 1856 |
| 1770 __ bind(&arguments_test); | 1857 __ bind(&arguments_test); |
| 1771 __ cmp(r9, Operand(r2)); | 1858 __ cmp(r11, r5); |
| 1772 __ b(lt, &arguments_loop); | 1859 __ blt(&arguments_loop); |
| 1773 | 1860 |
| 1774 // Return and remove the on-stack parameters. | 1861 // Return and remove the on-stack parameters. |
| 1775 __ add(sp, sp, Operand(3 * kPointerSize)); | 1862 __ addi(sp, sp, Operand(3 * kPointerSize)); |
| 1776 __ Ret(); | 1863 __ Ret(); |
| 1777 | 1864 |
| 1778 // Do the runtime call to allocate the arguments object. | 1865 // Do the runtime call to allocate the arguments object. |
| 1779 // r0 = address of new object (tagged) | 1866 // r5 = argument count (tagged) |
| 1780 // r2 = argument count (tagged) | |
| 1781 __ bind(&runtime); | 1867 __ bind(&runtime); |
| 1782 __ str(r2, MemOperand(sp, 0 * kPointerSize)); // Patch argument count. | 1868 __ StoreP(r5, MemOperand(sp, 0 * kPointerSize)); // Patch argument count. |
| 1783 __ TailCallRuntime(Runtime::kNewSloppyArguments, 3, 1); | 1869 __ TailCallRuntime(Runtime::kNewSloppyArguments, 3, 1); |
| 1784 } | 1870 } |
| 1785 | 1871 |
| 1786 | 1872 |
| 1873 void LoadIndexedInterceptorStub::Generate(MacroAssembler* masm) { |
| 1874 // Return address is in lr. |
| 1875 Label slow; |
| 1876 |
| 1877 Register receiver = LoadDescriptor::ReceiverRegister(); |
| 1878 Register key = LoadDescriptor::NameRegister(); |
| 1879 |
| 1880 // Check that the key is an array index, that is Uint32. |
| 1881 __ TestIfPositiveSmi(key, r0); |
| 1882 __ bne(&slow, cr0); |
| 1883 |
| 1884 // Everything is fine, call runtime. |
| 1885 __ Push(receiver, key); // Receiver, key. |
| 1886 |
| 1887 // Perform tail call to the entry. |
| 1888 __ TailCallExternalReference( |
| 1889 ExternalReference(IC_Utility(IC::kLoadElementWithInterceptor), |
| 1890 masm->isolate()), |
| 1891 2, 1); |
| 1892 |
| 1893 __ bind(&slow); |
| 1894 PropertyAccessCompiler::TailCallBuiltin( |
| 1895 masm, PropertyAccessCompiler::MissBuiltin(Code::KEYED_LOAD_IC)); |
| 1896 } |
| 1897 |
| 1898 |
| 1787 void ArgumentsAccessStub::GenerateNewStrict(MacroAssembler* masm) { | 1899 void ArgumentsAccessStub::GenerateNewStrict(MacroAssembler* masm) { |
| 1788 // sp[0] : number of parameters | 1900 // sp[0] : number of parameters |
| 1789 // sp[4] : receiver displacement | 1901 // sp[4] : receiver displacement |
| 1790 // sp[8] : function | 1902 // sp[8] : function |
| 1791 // Check if the calling frame is an arguments adaptor frame. | 1903 // Check if the calling frame is an arguments adaptor frame. |
| 1792 Label adaptor_frame, try_allocate, runtime; | 1904 Label adaptor_frame, try_allocate, runtime; |
| 1793 __ ldr(r2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | 1905 __ LoadP(r5, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
| 1794 __ ldr(r3, MemOperand(r2, StandardFrameConstants::kContextOffset)); | 1906 __ LoadP(r6, MemOperand(r5, StandardFrameConstants::kContextOffset)); |
| 1795 __ cmp(r3, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 1907 STATIC_ASSERT(StackFrame::ARGUMENTS_ADAPTOR < 0x3fffu); |
| 1796 __ b(eq, &adaptor_frame); | 1908 __ CmpSmiLiteral(r6, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0); |
| 1909 __ beq(&adaptor_frame); |
| 1797 | 1910 |
| 1798 // Get the length from the frame. | 1911 // Get the length from the frame. |
| 1799 __ ldr(r1, MemOperand(sp, 0)); | 1912 __ LoadP(r4, MemOperand(sp, 0)); |
| 1800 __ b(&try_allocate); | 1913 __ b(&try_allocate); |
| 1801 | 1914 |
| 1802 // Patch the arguments.length and the parameters pointer. | 1915 // Patch the arguments.length and the parameters pointer. |
| 1803 __ bind(&adaptor_frame); | 1916 __ bind(&adaptor_frame); |
| 1804 __ ldr(r1, MemOperand(r2, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 1917 __ LoadP(r4, MemOperand(r5, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
| 1805 __ str(r1, MemOperand(sp, 0)); | 1918 __ StoreP(r4, MemOperand(sp, 0)); |
| 1806 __ add(r3, r2, Operand::PointerOffsetFromSmiKey(r1)); | 1919 __ SmiToPtrArrayOffset(r6, r4); |
| 1807 __ add(r3, r3, Operand(StandardFrameConstants::kCallerSPOffset)); | 1920 __ add(r6, r5, r6); |
| 1808 __ str(r3, MemOperand(sp, 1 * kPointerSize)); | 1921 __ addi(r6, r6, Operand(StandardFrameConstants::kCallerSPOffset)); |
| 1922 __ StoreP(r6, MemOperand(sp, 1 * kPointerSize)); |
| 1809 | 1923 |
| 1810 // Try the new space allocation. Start out with computing the size | 1924 // Try the new space allocation. Start out with computing the size |
| 1811 // of the arguments object and the elements array in words. | 1925 // of the arguments object and the elements array in words. |
| 1812 Label add_arguments_object; | 1926 Label add_arguments_object; |
| 1813 __ bind(&try_allocate); | 1927 __ bind(&try_allocate); |
| 1814 __ SmiUntag(r1, SetCC); | 1928 __ cmpi(r4, Operand::Zero()); |
| 1815 __ b(eq, &add_arguments_object); | 1929 __ beq(&add_arguments_object); |
| 1816 __ add(r1, r1, Operand(FixedArray::kHeaderSize / kPointerSize)); | 1930 __ SmiUntag(r4); |
| 1931 __ addi(r4, r4, Operand(FixedArray::kHeaderSize / kPointerSize)); |
| 1817 __ bind(&add_arguments_object); | 1932 __ bind(&add_arguments_object); |
| 1818 __ add(r1, r1, Operand(Heap::kStrictArgumentsObjectSize / kPointerSize)); | 1933 __ addi(r4, r4, Operand(Heap::kStrictArgumentsObjectSize / kPointerSize)); |
| 1819 | 1934 |
| 1820 // Do the allocation of both objects in one go. | 1935 // Do the allocation of both objects in one go. |
| 1821 __ Allocate(r1, r0, r2, r3, &runtime, | 1936 __ Allocate(r4, r3, r5, r6, &runtime, |
| 1822 static_cast<AllocationFlags>(TAG_OBJECT | SIZE_IN_WORDS)); | 1937 static_cast<AllocationFlags>(TAG_OBJECT | SIZE_IN_WORDS)); |
| 1823 | 1938 |
| 1824 // Get the arguments boilerplate from the current native context. | 1939 // Get the arguments boilerplate from the current native context. |
| 1825 __ ldr(r4, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 1940 __ LoadP(r7, |
| 1826 __ ldr(r4, FieldMemOperand(r4, GlobalObject::kNativeContextOffset)); | 1941 MemOperand(cp, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
| 1827 __ ldr(r4, MemOperand( | 1942 __ LoadP(r7, FieldMemOperand(r7, GlobalObject::kNativeContextOffset)); |
| 1828 r4, Context::SlotOffset(Context::STRICT_ARGUMENTS_MAP_INDEX))); | 1943 __ LoadP( |
| 1944 r7, |
| 1945 MemOperand(r7, Context::SlotOffset(Context::STRICT_ARGUMENTS_MAP_INDEX))); |
| 1829 | 1946 |
| 1830 __ str(r4, FieldMemOperand(r0, JSObject::kMapOffset)); | 1947 __ StoreP(r7, FieldMemOperand(r3, JSObject::kMapOffset), r0); |
| 1831 __ LoadRoot(r3, Heap::kEmptyFixedArrayRootIndex); | 1948 __ LoadRoot(r6, Heap::kEmptyFixedArrayRootIndex); |
| 1832 __ str(r3, FieldMemOperand(r0, JSObject::kPropertiesOffset)); | 1949 __ StoreP(r6, FieldMemOperand(r3, JSObject::kPropertiesOffset), r0); |
| 1833 __ str(r3, FieldMemOperand(r0, JSObject::kElementsOffset)); | 1950 __ StoreP(r6, FieldMemOperand(r3, JSObject::kElementsOffset), r0); |
| 1834 | 1951 |
| 1835 // Get the length (smi tagged) and set that as an in-object property too. | 1952 // Get the length (smi tagged) and set that as an in-object property too. |
| 1836 STATIC_ASSERT(Heap::kArgumentsLengthIndex == 0); | 1953 STATIC_ASSERT(Heap::kArgumentsLengthIndex == 0); |
| 1837 __ ldr(r1, MemOperand(sp, 0 * kPointerSize)); | 1954 __ LoadP(r4, MemOperand(sp, 0 * kPointerSize)); |
| 1838 __ AssertSmi(r1); | 1955 __ AssertSmi(r4); |
| 1839 __ str(r1, FieldMemOperand(r0, JSObject::kHeaderSize + | 1956 __ StoreP(r4, |
| 1840 Heap::kArgumentsLengthIndex * kPointerSize)); | 1957 FieldMemOperand(r3, JSObject::kHeaderSize + |
| 1958 Heap::kArgumentsLengthIndex * kPointerSize), |
| 1959 r0); |
| 1841 | 1960 |
| 1842 // If there are no actual arguments, we're done. | 1961 // If there are no actual arguments, we're done. |
| 1843 Label done; | 1962 Label done; |
| 1844 __ cmp(r1, Operand::Zero()); | 1963 __ cmpi(r4, Operand::Zero()); |
| 1845 __ b(eq, &done); | 1964 __ beq(&done); |
| 1846 | 1965 |
| 1847 // Get the parameters pointer from the stack. | 1966 // Get the parameters pointer from the stack. |
| 1848 __ ldr(r2, MemOperand(sp, 1 * kPointerSize)); | 1967 __ LoadP(r5, MemOperand(sp, 1 * kPointerSize)); |
| 1849 | 1968 |
| 1850 // Set up the elements pointer in the allocated arguments object and | 1969 // Set up the elements pointer in the allocated arguments object and |
| 1851 // initialize the header in the elements fixed array. | 1970 // initialize the header in the elements fixed array. |
| 1852 __ add(r4, r0, Operand(Heap::kStrictArgumentsObjectSize)); | 1971 __ addi(r7, r3, Operand(Heap::kStrictArgumentsObjectSize)); |
| 1853 __ str(r4, FieldMemOperand(r0, JSObject::kElementsOffset)); | 1972 __ StoreP(r7, FieldMemOperand(r3, JSObject::kElementsOffset), r0); |
| 1854 __ LoadRoot(r3, Heap::kFixedArrayMapRootIndex); | 1973 __ LoadRoot(r6, Heap::kFixedArrayMapRootIndex); |
| 1855 __ str(r3, FieldMemOperand(r4, FixedArray::kMapOffset)); | 1974 __ StoreP(r6, FieldMemOperand(r7, FixedArray::kMapOffset), r0); |
| 1856 __ str(r1, FieldMemOperand(r4, FixedArray::kLengthOffset)); | 1975 __ StoreP(r4, FieldMemOperand(r7, FixedArray::kLengthOffset), r0); |
| 1857 __ SmiUntag(r1); | 1976 // Untag the length for the loop. |
| 1977 __ SmiUntag(r4); |
| 1858 | 1978 |
| 1859 // Copy the fixed array slots. | 1979 // Copy the fixed array slots. |
| 1860 Label loop; | 1980 Label loop; |
| 1861 // Set up r4 to point to the first array slot. | 1981 // Set up r7 to point to the first array slot. |
| 1862 __ add(r4, r4, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | 1982 __ addi(r7, r7, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
| 1863 __ bind(&loop); | 1983 __ bind(&loop); |
| 1864 // Pre-decrement r2 with kPointerSize on each iteration. | 1984 // Pre-decrement r5 with kPointerSize on each iteration. |
| 1865 // Pre-decrement in order to skip receiver. | 1985 // Pre-decrement in order to skip receiver. |
| 1866 __ ldr(r3, MemOperand(r2, kPointerSize, NegPreIndex)); | 1986 __ LoadPU(r6, MemOperand(r5, -kPointerSize)); |
| 1867 // Post-increment r4 with kPointerSize on each iteration. | 1987 // Post-increment r7 with kPointerSize on each iteration. |
| 1868 __ str(r3, MemOperand(r4, kPointerSize, PostIndex)); | 1988 __ StoreP(r6, MemOperand(r7)); |
| 1869 __ sub(r1, r1, Operand(1)); | 1989 __ addi(r7, r7, Operand(kPointerSize)); |
| 1870 __ cmp(r1, Operand::Zero()); | 1990 __ subi(r4, r4, Operand(1)); |
| 1871 __ b(ne, &loop); | 1991 __ cmpi(r4, Operand::Zero()); |
| 1992 __ bne(&loop); |
| 1872 | 1993 |
| 1873 // Return and remove the on-stack parameters. | 1994 // Return and remove the on-stack parameters. |
| 1874 __ bind(&done); | 1995 __ bind(&done); |
| 1875 __ add(sp, sp, Operand(3 * kPointerSize)); | 1996 __ addi(sp, sp, Operand(3 * kPointerSize)); |
| 1876 __ Ret(); | 1997 __ Ret(); |
| 1877 | 1998 |
| 1878 // Do the runtime call to allocate the arguments object. | 1999 // Do the runtime call to allocate the arguments object. |
| 1879 __ bind(&runtime); | 2000 __ bind(&runtime); |
| 1880 __ TailCallRuntime(Runtime::kNewStrictArguments, 3, 1); | 2001 __ TailCallRuntime(Runtime::kNewStrictArguments, 3, 1); |
| 1881 } | 2002 } |
| 1882 | 2003 |
| 1883 | 2004 |
| 1884 void RegExpExecStub::Generate(MacroAssembler* masm) { | 2005 void RegExpExecStub::Generate(MacroAssembler* masm) { |
| 1885 // Just jump directly to runtime if native RegExp is not selected at compile | 2006 // Just jump directly to runtime if native RegExp is not selected at compile |
| 1886 // time or if regexp entry in generated code is turned off runtime switch or | 2007 // time or if regexp entry in generated code is turned off runtime switch or |
| 1887 // at compilation. | 2008 // at compilation. |
| 1888 #ifdef V8_INTERPRETED_REGEXP | 2009 #ifdef V8_INTERPRETED_REGEXP |
| 1889 __ TailCallRuntime(Runtime::kRegExpExecRT, 4, 1); | 2010 __ TailCallRuntime(Runtime::kRegExpExecRT, 4, 1); |
| 1890 #else // V8_INTERPRETED_REGEXP | 2011 #else // V8_INTERPRETED_REGEXP |
| 1891 | 2012 |
| 1892 // Stack frame on entry. | 2013 // Stack frame on entry. |
| 1893 // sp[0]: last_match_info (expected JSArray) | 2014 // sp[0]: last_match_info (expected JSArray) |
| 1894 // sp[4]: previous index | 2015 // sp[4]: previous index |
| 1895 // sp[8]: subject string | 2016 // sp[8]: subject string |
| 1896 // sp[12]: JSRegExp object | 2017 // sp[12]: JSRegExp object |
| 1897 | 2018 |
| 1898 const int kLastMatchInfoOffset = 0 * kPointerSize; | 2019 const int kLastMatchInfoOffset = 0 * kPointerSize; |
| 1899 const int kPreviousIndexOffset = 1 * kPointerSize; | 2020 const int kPreviousIndexOffset = 1 * kPointerSize; |
| 1900 const int kSubjectOffset = 2 * kPointerSize; | 2021 const int kSubjectOffset = 2 * kPointerSize; |
| 1901 const int kJSRegExpOffset = 3 * kPointerSize; | 2022 const int kJSRegExpOffset = 3 * kPointerSize; |
| 1902 | 2023 |
| 1903 Label runtime; | 2024 Label runtime, br_over, encoding_type_UC16; |
| 2025 |
| 1904 // Allocation of registers for this function. These are in callee save | 2026 // Allocation of registers for this function. These are in callee save |
| 1905 // registers and will be preserved by the call to the native RegExp code, as | 2027 // registers and will be preserved by the call to the native RegExp code, as |
| 1906 // this code is called using the normal C calling convention. When calling | 2028 // this code is called using the normal C calling convention. When calling |
| 1907 // directly from generated code the native RegExp code will not do a GC and | 2029 // directly from generated code the native RegExp code will not do a GC and |
| 1908 // therefore the content of these registers are safe to use after the call. | 2030 // therefore the content of these registers are safe to use after the call. |
| 1909 Register subject = r4; | 2031 Register subject = r14; |
| 1910 Register regexp_data = r5; | 2032 Register regexp_data = r15; |
| 1911 Register last_match_info_elements = no_reg; // will be r6; | 2033 Register last_match_info_elements = r16; |
| 2034 Register code = r17; |
| 2035 |
| 2036 // Ensure register assigments are consistent with callee save masks |
| 2037 DCHECK(subject.bit() & kCalleeSaved); |
| 2038 DCHECK(regexp_data.bit() & kCalleeSaved); |
| 2039 DCHECK(last_match_info_elements.bit() & kCalleeSaved); |
| 2040 DCHECK(code.bit() & kCalleeSaved); |
| 1912 | 2041 |
| 1913 // Ensure that a RegExp stack is allocated. | 2042 // Ensure that a RegExp stack is allocated. |
| 1914 ExternalReference address_of_regexp_stack_memory_address = | 2043 ExternalReference address_of_regexp_stack_memory_address = |
| 1915 ExternalReference::address_of_regexp_stack_memory_address(isolate()); | 2044 ExternalReference::address_of_regexp_stack_memory_address(isolate()); |
| 1916 ExternalReference address_of_regexp_stack_memory_size = | 2045 ExternalReference address_of_regexp_stack_memory_size = |
| 1917 ExternalReference::address_of_regexp_stack_memory_size(isolate()); | 2046 ExternalReference::address_of_regexp_stack_memory_size(isolate()); |
| 1918 __ mov(r0, Operand(address_of_regexp_stack_memory_size)); | 2047 __ mov(r3, Operand(address_of_regexp_stack_memory_size)); |
| 1919 __ ldr(r0, MemOperand(r0, 0)); | 2048 __ LoadP(r3, MemOperand(r3, 0)); |
| 1920 __ cmp(r0, Operand::Zero()); | 2049 __ cmpi(r3, Operand::Zero()); |
| 1921 __ b(eq, &runtime); | 2050 __ beq(&runtime); |
| 1922 | 2051 |
| 1923 // Check that the first argument is a JSRegExp object. | 2052 // Check that the first argument is a JSRegExp object. |
| 1924 __ ldr(r0, MemOperand(sp, kJSRegExpOffset)); | 2053 __ LoadP(r3, MemOperand(sp, kJSRegExpOffset)); |
| 1925 __ JumpIfSmi(r0, &runtime); | 2054 __ JumpIfSmi(r3, &runtime); |
| 1926 __ CompareObjectType(r0, r1, r1, JS_REGEXP_TYPE); | 2055 __ CompareObjectType(r3, r4, r4, JS_REGEXP_TYPE); |
| 1927 __ b(ne, &runtime); | 2056 __ bne(&runtime); |
| 1928 | 2057 |
| 1929 // Check that the RegExp has been compiled (data contains a fixed array). | 2058 // Check that the RegExp has been compiled (data contains a fixed array). |
| 1930 __ ldr(regexp_data, FieldMemOperand(r0, JSRegExp::kDataOffset)); | 2059 __ LoadP(regexp_data, FieldMemOperand(r3, JSRegExp::kDataOffset)); |
| 1931 if (FLAG_debug_code) { | 2060 if (FLAG_debug_code) { |
| 1932 __ SmiTst(regexp_data); | 2061 __ TestIfSmi(regexp_data, r0); |
| 1933 __ Check(ne, kUnexpectedTypeForRegExpDataFixedArrayExpected); | 2062 __ Check(ne, kUnexpectedTypeForRegExpDataFixedArrayExpected, cr0); |
| 1934 __ CompareObjectType(regexp_data, r0, r0, FIXED_ARRAY_TYPE); | 2063 __ CompareObjectType(regexp_data, r3, r3, FIXED_ARRAY_TYPE); |
| 1935 __ Check(eq, kUnexpectedTypeForRegExpDataFixedArrayExpected); | 2064 __ Check(eq, kUnexpectedTypeForRegExpDataFixedArrayExpected); |
| 1936 } | 2065 } |
| 1937 | 2066 |
| 1938 // regexp_data: RegExp data (FixedArray) | 2067 // regexp_data: RegExp data (FixedArray) |
| 1939 // Check the type of the RegExp. Only continue if type is JSRegExp::IRREGEXP. | 2068 // Check the type of the RegExp. Only continue if type is JSRegExp::IRREGEXP. |
| 1940 __ ldr(r0, FieldMemOperand(regexp_data, JSRegExp::kDataTagOffset)); | 2069 __ LoadP(r3, FieldMemOperand(regexp_data, JSRegExp::kDataTagOffset)); |
| 1941 __ cmp(r0, Operand(Smi::FromInt(JSRegExp::IRREGEXP))); | 2070 // DCHECK(Smi::FromInt(JSRegExp::IRREGEXP) < (char *)0xffffu); |
| 1942 __ b(ne, &runtime); | 2071 __ CmpSmiLiteral(r3, Smi::FromInt(JSRegExp::IRREGEXP), r0); |
| 2072 __ bne(&runtime); |
| 1943 | 2073 |
| 1944 // regexp_data: RegExp data (FixedArray) | 2074 // regexp_data: RegExp data (FixedArray) |
| 1945 // Check that the number of captures fit in the static offsets vector buffer. | 2075 // Check that the number of captures fit in the static offsets vector buffer. |
| 1946 __ ldr(r2, | 2076 __ LoadP(r5, |
| 1947 FieldMemOperand(regexp_data, JSRegExp::kIrregexpCaptureCountOffset)); | 2077 FieldMemOperand(regexp_data, JSRegExp::kIrregexpCaptureCountOffset)); |
| 1948 // Check (number_of_captures + 1) * 2 <= offsets vector size | 2078 // Check (number_of_captures + 1) * 2 <= offsets vector size |
| 1949 // Or number_of_captures * 2 <= offsets vector size - 2 | 2079 // Or number_of_captures * 2 <= offsets vector size - 2 |
| 1950 // Multiplying by 2 comes for free since r2 is smi-tagged. | 2080 // SmiToShortArrayOffset accomplishes the multiplication by 2 and |
| 1951 STATIC_ASSERT(kSmiTag == 0); | 2081 // SmiUntag (which is a nop for 32-bit). |
| 1952 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); | 2082 __ SmiToShortArrayOffset(r5, r5); |
| 1953 STATIC_ASSERT(Isolate::kJSRegexpStaticOffsetsVectorSize >= 2); | 2083 STATIC_ASSERT(Isolate::kJSRegexpStaticOffsetsVectorSize >= 2); |
| 1954 __ cmp(r2, Operand(Isolate::kJSRegexpStaticOffsetsVectorSize - 2)); | 2084 __ cmpli(r5, Operand(Isolate::kJSRegexpStaticOffsetsVectorSize - 2)); |
| 1955 __ b(hi, &runtime); | 2085 __ bgt(&runtime); |
| 1956 | 2086 |
| 1957 // Reset offset for possibly sliced string. | 2087 // Reset offset for possibly sliced string. |
| 1958 __ mov(r9, Operand::Zero()); | 2088 __ li(r11, Operand::Zero()); |
| 1959 __ ldr(subject, MemOperand(sp, kSubjectOffset)); | 2089 __ LoadP(subject, MemOperand(sp, kSubjectOffset)); |
| 1960 __ JumpIfSmi(subject, &runtime); | 2090 __ JumpIfSmi(subject, &runtime); |
| 1961 __ mov(r3, subject); // Make a copy of the original subject string. | 2091 __ mr(r6, subject); // Make a copy of the original subject string. |
| 1962 __ ldr(r0, FieldMemOperand(subject, HeapObject::kMapOffset)); | 2092 __ LoadP(r3, FieldMemOperand(subject, HeapObject::kMapOffset)); |
| 1963 __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset)); | 2093 __ lbz(r3, FieldMemOperand(r3, Map::kInstanceTypeOffset)); |
| 1964 // subject: subject string | 2094 // subject: subject string |
| 1965 // r3: subject string | 2095 // r6: subject string |
| 1966 // r0: subject string instance type | 2096 // r3: subject string instance type |
| 1967 // regexp_data: RegExp data (FixedArray) | 2097 // regexp_data: RegExp data (FixedArray) |
| 1968 // Handle subject string according to its encoding and representation: | 2098 // Handle subject string according to its encoding and representation: |
| 1969 // (1) Sequential string? If yes, go to (5). | 2099 // (1) Sequential string? If yes, go to (5). |
| 1970 // (2) Anything but sequential or cons? If yes, go to (6). | 2100 // (2) Anything but sequential or cons? If yes, go to (6). |
| 1971 // (3) Cons string. If the string is flat, replace subject with first string. | 2101 // (3) Cons string. If the string is flat, replace subject with first string. |
| 1972 // Otherwise bailout. | 2102 // Otherwise bailout. |
| 1973 // (4) Is subject external? If yes, go to (7). | 2103 // (4) Is subject external? If yes, go to (7). |
| 1974 // (5) Sequential string. Load regexp code according to encoding. | 2104 // (5) Sequential string. Load regexp code according to encoding. |
| 1975 // (E) Carry on. | 2105 // (E) Carry on. |
| 1976 /// [...] | 2106 /// [...] |
| 1977 | 2107 |
| 1978 // Deferred code at the end of the stub: | 2108 // Deferred code at the end of the stub: |
| 1979 // (6) Not a long external string? If yes, go to (8). | 2109 // (6) Not a long external string? If yes, go to (8). |
| 1980 // (7) External string. Make it, offset-wise, look like a sequential string. | 2110 // (7) External string. Make it, offset-wise, look like a sequential string. |
| 1981 // Go to (5). | 2111 // Go to (5). |
| 1982 // (8) Short external string or not a string? If yes, bail out to runtime. | 2112 // (8) Short external string or not a string? If yes, bail out to runtime. |
| 1983 // (9) Sliced string. Replace subject with parent. Go to (4). | 2113 // (9) Sliced string. Replace subject with parent. Go to (4). |
| 1984 | 2114 |
| 1985 Label seq_string /* 5 */, external_string /* 7 */, | 2115 Label seq_string /* 5 */, external_string /* 7 */, check_underlying /* 4 */, |
| 1986 check_underlying /* 4 */, not_seq_nor_cons /* 6 */, | 2116 not_seq_nor_cons /* 6 */, not_long_external /* 8 */; |
| 1987 not_long_external /* 8 */; | |
| 1988 | 2117 |
| 1989 // (1) Sequential string? If yes, go to (5). | 2118 // (1) Sequential string? If yes, go to (5). |
| 1990 __ and_(r1, | 2119 STATIC_ASSERT((kIsNotStringMask | kStringRepresentationMask | |
| 1991 r0, | 2120 kShortExternalStringMask) == 0x93); |
| 1992 Operand(kIsNotStringMask | | 2121 __ andi(r4, r3, Operand(kIsNotStringMask | kStringRepresentationMask | |
| 1993 kStringRepresentationMask | | 2122 kShortExternalStringMask)); |
| 1994 kShortExternalStringMask), | |
| 1995 SetCC); | |
| 1996 STATIC_ASSERT((kStringTag | kSeqStringTag) == 0); | 2123 STATIC_ASSERT((kStringTag | kSeqStringTag) == 0); |
| 1997 __ b(eq, &seq_string); // Go to (5). | 2124 __ beq(&seq_string, cr0); // Go to (5). |
| 1998 | 2125 |
| 1999 // (2) Anything but sequential or cons? If yes, go to (6). | 2126 // (2) Anything but sequential or cons? If yes, go to (6). |
| 2000 STATIC_ASSERT(kConsStringTag < kExternalStringTag); | 2127 STATIC_ASSERT(kConsStringTag < kExternalStringTag); |
| 2001 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag); | 2128 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag); |
| 2002 STATIC_ASSERT(kIsNotStringMask > kExternalStringTag); | 2129 STATIC_ASSERT(kIsNotStringMask > kExternalStringTag); |
| 2003 STATIC_ASSERT(kShortExternalStringTag > kExternalStringTag); | 2130 STATIC_ASSERT(kShortExternalStringTag > kExternalStringTag); |
| 2004 __ cmp(r1, Operand(kExternalStringTag)); | 2131 STATIC_ASSERT(kExternalStringTag < 0xffffu); |
| 2005 __ b(ge, ¬_seq_nor_cons); // Go to (6). | 2132 __ cmpi(r4, Operand(kExternalStringTag)); |
| 2133 __ bge(¬_seq_nor_cons); // Go to (6). |
| 2006 | 2134 |
| 2007 // (3) Cons string. Check that it's flat. | 2135 // (3) Cons string. Check that it's flat. |
| 2008 // Replace subject with first string and reload instance type. | 2136 // Replace subject with first string and reload instance type. |
| 2009 __ ldr(r0, FieldMemOperand(subject, ConsString::kSecondOffset)); | 2137 __ LoadP(r3, FieldMemOperand(subject, ConsString::kSecondOffset)); |
| 2010 __ CompareRoot(r0, Heap::kempty_stringRootIndex); | 2138 __ CompareRoot(r3, Heap::kempty_stringRootIndex); |
| 2011 __ b(ne, &runtime); | 2139 __ bne(&runtime); |
| 2012 __ ldr(subject, FieldMemOperand(subject, ConsString::kFirstOffset)); | 2140 __ LoadP(subject, FieldMemOperand(subject, ConsString::kFirstOffset)); |
| 2013 | 2141 |
| 2014 // (4) Is subject external? If yes, go to (7). | 2142 // (4) Is subject external? If yes, go to (7). |
| 2015 __ bind(&check_underlying); | 2143 __ bind(&check_underlying); |
| 2016 __ ldr(r0, FieldMemOperand(subject, HeapObject::kMapOffset)); | 2144 __ LoadP(r3, FieldMemOperand(subject, HeapObject::kMapOffset)); |
| 2017 __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset)); | 2145 __ lbz(r3, FieldMemOperand(r3, Map::kInstanceTypeOffset)); |
| 2018 STATIC_ASSERT(kSeqStringTag == 0); | 2146 STATIC_ASSERT(kSeqStringTag == 0); |
| 2019 __ tst(r0, Operand(kStringRepresentationMask)); | 2147 STATIC_ASSERT(kStringRepresentationMask == 3); |
| 2148 __ andi(r0, r3, Operand(kStringRepresentationMask)); |
| 2020 // The underlying external string is never a short external string. | 2149 // The underlying external string is never a short external string. |
| 2021 STATIC_ASSERT(ExternalString::kMaxShortLength < ConsString::kMinLength); | 2150 STATIC_ASSERT(ExternalString::kMaxShortLength < ConsString::kMinLength); |
| 2022 STATIC_ASSERT(ExternalString::kMaxShortLength < SlicedString::kMinLength); | 2151 STATIC_ASSERT(ExternalString::kMaxShortLength < SlicedString::kMinLength); |
| 2023 __ b(ne, &external_string); // Go to (7). | 2152 __ bne(&external_string, cr0); // Go to (7). |
| 2024 | 2153 |
| 2025 // (5) Sequential string. Load regexp code according to encoding. | 2154 // (5) Sequential string. Load regexp code according to encoding. |
| 2026 __ bind(&seq_string); | 2155 __ bind(&seq_string); |
| 2027 // subject: sequential subject string (or look-alike, external string) | 2156 // subject: sequential subject string (or look-alike, external string) |
| 2028 // r3: original subject string | 2157 // r6: original subject string |
| 2029 // Load previous index and check range before r3 is overwritten. We have to | 2158 // Load previous index and check range before r6 is overwritten. We have to |
| 2030 // use r3 instead of subject here because subject might have been only made | 2159 // use r6 instead of subject here because subject might have been only made |
| 2031 // to look like a sequential string when it actually is an external string. | 2160 // to look like a sequential string when it actually is an external string. |
| 2032 __ ldr(r1, MemOperand(sp, kPreviousIndexOffset)); | 2161 __ LoadP(r4, MemOperand(sp, kPreviousIndexOffset)); |
| 2033 __ JumpIfNotSmi(r1, &runtime); | 2162 __ JumpIfNotSmi(r4, &runtime); |
| 2034 __ ldr(r3, FieldMemOperand(r3, String::kLengthOffset)); | 2163 __ LoadP(r6, FieldMemOperand(r6, String::kLengthOffset)); |
| 2035 __ cmp(r3, Operand(r1)); | 2164 __ cmpl(r6, r4); |
| 2036 __ b(ls, &runtime); | 2165 __ ble(&runtime); |
| 2037 __ SmiUntag(r1); | 2166 __ SmiUntag(r4); |
| 2038 | 2167 |
| 2039 STATIC_ASSERT(4 == kOneByteStringTag); | 2168 STATIC_ASSERT(4 == kOneByteStringTag); |
| 2040 STATIC_ASSERT(kTwoByteStringTag == 0); | 2169 STATIC_ASSERT(kTwoByteStringTag == 0); |
| 2041 __ and_(r0, r0, Operand(kStringEncodingMask)); | 2170 STATIC_ASSERT(kStringEncodingMask == 4); |
| 2042 __ mov(r3, Operand(r0, ASR, 2), SetCC); | 2171 __ ExtractBitMask(r6, r3, kStringEncodingMask, SetRC); |
| 2043 __ ldr(r6, FieldMemOperand(regexp_data, JSRegExp::kDataOneByteCodeOffset), | 2172 __ beq(&encoding_type_UC16, cr0); |
| 2044 ne); | 2173 __ LoadP(code, |
| 2045 __ ldr(r6, FieldMemOperand(regexp_data, JSRegExp::kDataUC16CodeOffset), eq); | 2174 FieldMemOperand(regexp_data, JSRegExp::kDataOneByteCodeOffset)); |
| 2175 __ b(&br_over); |
| 2176 __ bind(&encoding_type_UC16); |
| 2177 __ LoadP(code, FieldMemOperand(regexp_data, JSRegExp::kDataUC16CodeOffset)); |
| 2178 __ bind(&br_over); |
| 2046 | 2179 |
| 2047 // (E) Carry on. String handling is done. | 2180 // (E) Carry on. String handling is done. |
| 2048 // r6: irregexp code | 2181 // code: irregexp code |
| 2049 // Check that the irregexp code has been generated for the actual string | 2182 // Check that the irregexp code has been generated for the actual string |
| 2050 // encoding. If it has, the field contains a code object otherwise it contains | 2183 // encoding. If it has, the field contains a code object otherwise it contains |
| 2051 // a smi (code flushing support). | 2184 // a smi (code flushing support). |
| 2052 __ JumpIfSmi(r6, &runtime); | 2185 __ JumpIfSmi(code, &runtime); |
| 2053 | 2186 |
| 2054 // r1: previous index | 2187 // r4: previous index |
| 2055 // r3: encoding of subject string (1 if one_byte, 0 if two_byte); | 2188 // r6: encoding of subject string (1 if one_byte, 0 if two_byte); |
| 2056 // r6: code | 2189 // code: Address of generated regexp code |
| 2057 // subject: Subject string | 2190 // subject: Subject string |
| 2058 // regexp_data: RegExp data (FixedArray) | 2191 // regexp_data: RegExp data (FixedArray) |
| 2059 // All checks done. Now push arguments for native regexp code. | 2192 // All checks done. Now push arguments for native regexp code. |
| 2060 __ IncrementCounter(isolate()->counters()->regexp_entry_native(), 1, r0, r2); | 2193 __ IncrementCounter(isolate()->counters()->regexp_entry_native(), 1, r3, r5); |
| 2061 | 2194 |
| 2062 // Isolates: note we add an additional parameter here (isolate pointer). | 2195 // Isolates: note we add an additional parameter here (isolate pointer). |
| 2063 const int kRegExpExecuteArguments = 9; | 2196 const int kRegExpExecuteArguments = 10; |
| 2064 const int kParameterRegisters = 4; | 2197 const int kParameterRegisters = 8; |
| 2065 __ EnterExitFrame(false, kRegExpExecuteArguments - kParameterRegisters); | 2198 __ EnterExitFrame(false, kRegExpExecuteArguments - kParameterRegisters); |
| 2066 | 2199 |
| 2067 // Stack pointer now points to cell where return address is to be written. | 2200 // Stack pointer now points to cell where return address is to be written. |
| 2068 // Arguments are before that on the stack or in registers. | 2201 // Arguments are before that on the stack or in registers. |
| 2069 | 2202 |
| 2070 // Argument 9 (sp[20]): Pass current isolate address. | 2203 // Argument 10 (in stack parameter area): Pass current isolate address. |
| 2071 __ mov(r0, Operand(ExternalReference::isolate_address(isolate()))); | 2204 __ mov(r3, Operand(ExternalReference::isolate_address(isolate()))); |
| 2072 __ str(r0, MemOperand(sp, 5 * kPointerSize)); | 2205 __ StoreP(r3, MemOperand(sp, (kStackFrameExtraParamSlot + 1) * kPointerSize)); |
| 2073 | 2206 |
| 2074 // Argument 8 (sp[16]): Indicate that this is a direct call from JavaScript. | 2207 // Argument 9 is a dummy that reserves the space used for |
| 2075 __ mov(r0, Operand(1)); | 2208 // the return address added by the ExitFrame in native calls. |
| 2076 __ str(r0, MemOperand(sp, 4 * kPointerSize)); | 2209 |
| 2077 | 2210 // Argument 8 (r10): Indicate that this is a direct call from JavaScript. |
| 2078 // Argument 7 (sp[12]): Start (high end) of backtracking stack memory area. | 2211 __ li(r10, Operand(1)); |
| 2079 __ mov(r0, Operand(address_of_regexp_stack_memory_address)); | 2212 |
| 2080 __ ldr(r0, MemOperand(r0, 0)); | 2213 // Argument 7 (r9): Start (high end) of backtracking stack memory area. |
| 2081 __ mov(r2, Operand(address_of_regexp_stack_memory_size)); | 2214 __ mov(r3, Operand(address_of_regexp_stack_memory_address)); |
| 2082 __ ldr(r2, MemOperand(r2, 0)); | 2215 __ LoadP(r3, MemOperand(r3, 0)); |
| 2083 __ add(r0, r0, Operand(r2)); | 2216 __ mov(r5, Operand(address_of_regexp_stack_memory_size)); |
| 2084 __ str(r0, MemOperand(sp, 3 * kPointerSize)); | 2217 __ LoadP(r5, MemOperand(r5, 0)); |
| 2085 | 2218 __ add(r9, r3, r5); |
| 2086 // Argument 6: Set the number of capture registers to zero to force global | 2219 |
| 2087 // regexps to behave as non-global. This does not affect non-global regexps. | 2220 // Argument 6 (r8): Set the number of capture registers to zero to force |
| 2088 __ mov(r0, Operand::Zero()); | 2221 // global egexps to behave as non-global. This does not affect non-global |
| 2089 __ str(r0, MemOperand(sp, 2 * kPointerSize)); | 2222 // regexps. |
| 2090 | 2223 __ li(r8, Operand::Zero()); |
| 2091 // Argument 5 (sp[4]): static offsets vector buffer. | 2224 |
| 2092 __ mov(r0, | 2225 // Argument 5 (r7): static offsets vector buffer. |
| 2093 Operand(ExternalReference::address_of_static_offsets_vector( | 2226 __ mov( |
| 2094 isolate()))); | 2227 r7, |
| 2095 __ str(r0, MemOperand(sp, 1 * kPointerSize)); | 2228 Operand(ExternalReference::address_of_static_offsets_vector(isolate()))); |
| 2096 | 2229 |
| 2097 // For arguments 4 and 3 get string length, calculate start of string data and | 2230 // For arguments 4 (r6) and 3 (r5) get string length, calculate start of data |
| 2098 // calculate the shift of the index (0 for one-byte and 1 for two-byte). | 2231 // and calculate the shift of the index (0 for one-byte and 1 for two-byte). |
| 2099 __ add(r7, subject, Operand(SeqString::kHeaderSize - kHeapObjectTag)); | 2232 __ addi(r18, subject, Operand(SeqString::kHeaderSize - kHeapObjectTag)); |
| 2100 __ eor(r3, r3, Operand(1)); | 2233 __ xori(r6, r6, Operand(1)); |
| 2101 // Load the length from the original subject string from the previous stack | 2234 // Load the length from the original subject string from the previous stack |
| 2102 // frame. Therefore we have to use fp, which points exactly to two pointer | 2235 // frame. Therefore we have to use fp, which points exactly to two pointer |
| 2103 // sizes below the previous sp. (Because creating a new stack frame pushes | 2236 // sizes below the previous sp. (Because creating a new stack frame pushes |
| 2104 // the previous fp onto the stack and moves up sp by 2 * kPointerSize.) | 2237 // the previous fp onto the stack and moves up sp by 2 * kPointerSize.) |
| 2105 __ ldr(subject, MemOperand(fp, kSubjectOffset + 2 * kPointerSize)); | 2238 __ LoadP(subject, MemOperand(fp, kSubjectOffset + 2 * kPointerSize)); |
| 2106 // If slice offset is not 0, load the length from the original sliced string. | 2239 // If slice offset is not 0, load the length from the original sliced string. |
| 2107 // Argument 4, r3: End of string data | 2240 // Argument 4, r6: End of string data |
| 2108 // Argument 3, r2: Start of string data | 2241 // Argument 3, r5: Start of string data |
| 2109 // Prepare start and end index of the input. | 2242 // Prepare start and end index of the input. |
| 2110 __ add(r9, r7, Operand(r9, LSL, r3)); | 2243 __ ShiftLeft(r11, r11, r6); |
| 2111 __ add(r2, r9, Operand(r1, LSL, r3)); | 2244 __ add(r11, r18, r11); |
| 2112 | 2245 __ ShiftLeft(r5, r4, r6); |
| 2113 __ ldr(r7, FieldMemOperand(subject, String::kLengthOffset)); | 2246 __ add(r5, r11, r5); |
| 2114 __ SmiUntag(r7); | 2247 |
| 2115 __ add(r3, r9, Operand(r7, LSL, r3)); | 2248 __ LoadP(r18, FieldMemOperand(subject, String::kLengthOffset)); |
| 2116 | 2249 __ SmiUntag(r18); |
| 2117 // Argument 2 (r1): Previous index. | 2250 __ ShiftLeft(r6, r18, r6); |
| 2251 __ add(r6, r11, r6); |
| 2252 |
| 2253 // Argument 2 (r4): Previous index. |
| 2118 // Already there | 2254 // Already there |
| 2119 | 2255 |
| 2120 // Argument 1 (r0): Subject string. | 2256 // Argument 1 (r3): Subject string. |
| 2121 __ mov(r0, subject); | 2257 __ mr(r3, subject); |
| 2122 | 2258 |
| 2123 // Locate the code entry and call it. | 2259 // Locate the code entry and call it. |
| 2124 __ add(r6, r6, Operand(Code::kHeaderSize - kHeapObjectTag)); | 2260 __ addi(code, code, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 2261 |
| 2262 |
| 2263 #if ABI_USES_FUNCTION_DESCRIPTORS && defined(USE_SIMULATOR) |
| 2264 // Even Simulated AIX/PPC64 Linux uses a function descriptor for the |
| 2265 // RegExp routine. Extract the instruction address here since |
| 2266 // DirectCEntryStub::GenerateCall will not do it for calls out to |
| 2267 // what it thinks is C code compiled for the simulator/host |
| 2268 // platform. |
| 2269 __ LoadP(code, MemOperand(code, 0)); // Instruction address |
| 2270 #endif |
| 2271 |
| 2125 DirectCEntryStub stub(isolate()); | 2272 DirectCEntryStub stub(isolate()); |
| 2126 stub.GenerateCall(masm, r6); | 2273 stub.GenerateCall(masm, code); |
| 2127 | 2274 |
| 2128 __ LeaveExitFrame(false, no_reg, true); | 2275 __ LeaveExitFrame(false, no_reg, true); |
| 2129 | 2276 |
| 2130 last_match_info_elements = r6; | 2277 // r3: result |
| 2131 | |
| 2132 // r0: result | |
| 2133 // subject: subject string (callee saved) | 2278 // subject: subject string (callee saved) |
| 2134 // regexp_data: RegExp data (callee saved) | 2279 // regexp_data: RegExp data (callee saved) |
| 2135 // last_match_info_elements: Last match info elements (callee saved) | 2280 // last_match_info_elements: Last match info elements (callee saved) |
| 2136 // Check the result. | 2281 // Check the result. |
| 2137 Label success; | 2282 Label success; |
| 2138 __ cmp(r0, Operand(1)); | 2283 __ cmpi(r3, Operand(1)); |
| 2139 // We expect exactly one result since we force the called regexp to behave | 2284 // We expect exactly one result since we force the called regexp to behave |
| 2140 // as non-global. | 2285 // as non-global. |
| 2141 __ b(eq, &success); | 2286 __ beq(&success); |
| 2142 Label failure; | 2287 Label failure; |
| 2143 __ cmp(r0, Operand(NativeRegExpMacroAssembler::FAILURE)); | 2288 __ cmpi(r3, Operand(NativeRegExpMacroAssembler::FAILURE)); |
| 2144 __ b(eq, &failure); | 2289 __ beq(&failure); |
| 2145 __ cmp(r0, Operand(NativeRegExpMacroAssembler::EXCEPTION)); | 2290 __ cmpi(r3, Operand(NativeRegExpMacroAssembler::EXCEPTION)); |
| 2146 // If not exception it can only be retry. Handle that in the runtime system. | 2291 // If not exception it can only be retry. Handle that in the runtime system. |
| 2147 __ b(ne, &runtime); | 2292 __ bne(&runtime); |
| 2148 // Result must now be exception. If there is no pending exception already a | 2293 // Result must now be exception. If there is no pending exception already a |
| 2149 // stack overflow (on the backtrack stack) was detected in RegExp code but | 2294 // stack overflow (on the backtrack stack) was detected in RegExp code but |
| 2150 // haven't created the exception yet. Handle that in the runtime system. | 2295 // haven't created the exception yet. Handle that in the runtime system. |
| 2151 // TODO(592): Rerunning the RegExp to get the stack overflow exception. | 2296 // TODO(592): Rerunning the RegExp to get the stack overflow exception. |
| 2152 __ mov(r1, Operand(isolate()->factory()->the_hole_value())); | 2297 __ mov(r4, Operand(isolate()->factory()->the_hole_value())); |
| 2153 __ mov(r2, Operand(ExternalReference(Isolate::kPendingExceptionAddress, | 2298 __ mov(r5, Operand(ExternalReference(Isolate::kPendingExceptionAddress, |
| 2154 isolate()))); | 2299 isolate()))); |
| 2155 __ ldr(r0, MemOperand(r2, 0)); | 2300 __ LoadP(r3, MemOperand(r5, 0)); |
| 2156 __ cmp(r0, r1); | 2301 __ cmp(r3, r4); |
| 2157 __ b(eq, &runtime); | 2302 __ beq(&runtime); |
| 2158 | 2303 |
| 2159 __ str(r1, MemOperand(r2, 0)); // Clear pending exception. | 2304 __ StoreP(r4, MemOperand(r5, 0)); // Clear pending exception. |
| 2160 | 2305 |
| 2161 // Check if the exception is a termination. If so, throw as uncatchable. | 2306 // Check if the exception is a termination. If so, throw as uncatchable. |
| 2162 __ CompareRoot(r0, Heap::kTerminationExceptionRootIndex); | 2307 __ CompareRoot(r3, Heap::kTerminationExceptionRootIndex); |
| 2163 | 2308 |
| 2164 Label termination_exception; | 2309 Label termination_exception; |
| 2165 __ b(eq, &termination_exception); | 2310 __ beq(&termination_exception); |
| 2166 | 2311 |
| 2167 __ Throw(r0); | 2312 __ Throw(r3); |
| 2168 | 2313 |
| 2169 __ bind(&termination_exception); | 2314 __ bind(&termination_exception); |
| 2170 __ ThrowUncatchable(r0); | 2315 __ ThrowUncatchable(r3); |
| 2171 | 2316 |
| 2172 __ bind(&failure); | 2317 __ bind(&failure); |
| 2173 // For failure and exception return null. | 2318 // For failure and exception return null. |
| 2174 __ mov(r0, Operand(isolate()->factory()->null_value())); | 2319 __ mov(r3, Operand(isolate()->factory()->null_value())); |
| 2175 __ add(sp, sp, Operand(4 * kPointerSize)); | 2320 __ addi(sp, sp, Operand(4 * kPointerSize)); |
| 2176 __ Ret(); | 2321 __ Ret(); |
| 2177 | 2322 |
| 2178 // Process the result from the native regexp code. | 2323 // Process the result from the native regexp code. |
| 2179 __ bind(&success); | 2324 __ bind(&success); |
| 2180 __ ldr(r1, | 2325 __ LoadP(r4, |
| 2181 FieldMemOperand(regexp_data, JSRegExp::kIrregexpCaptureCountOffset)); | 2326 FieldMemOperand(regexp_data, JSRegExp::kIrregexpCaptureCountOffset)); |
| 2182 // Calculate number of capture registers (number_of_captures + 1) * 2. | 2327 // Calculate number of capture registers (number_of_captures + 1) * 2. |
| 2183 // Multiplying by 2 comes for free since r1 is smi-tagged. | 2328 // SmiToShortArrayOffset accomplishes the multiplication by 2 and |
| 2184 STATIC_ASSERT(kSmiTag == 0); | 2329 // SmiUntag (which is a nop for 32-bit). |
| 2185 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); | 2330 __ SmiToShortArrayOffset(r4, r4); |
| 2186 __ add(r1, r1, Operand(2)); // r1 was a smi. | 2331 __ addi(r4, r4, Operand(2)); |
| 2187 | 2332 |
| 2188 __ ldr(r0, MemOperand(sp, kLastMatchInfoOffset)); | 2333 __ LoadP(r3, MemOperand(sp, kLastMatchInfoOffset)); |
| 2189 __ JumpIfSmi(r0, &runtime); | 2334 __ JumpIfSmi(r3, &runtime); |
| 2190 __ CompareObjectType(r0, r2, r2, JS_ARRAY_TYPE); | 2335 __ CompareObjectType(r3, r5, r5, JS_ARRAY_TYPE); |
| 2191 __ b(ne, &runtime); | 2336 __ bne(&runtime); |
| 2192 // Check that the JSArray is in fast case. | 2337 // Check that the JSArray is in fast case. |
| 2193 __ ldr(last_match_info_elements, | 2338 __ LoadP(last_match_info_elements, |
| 2194 FieldMemOperand(r0, JSArray::kElementsOffset)); | 2339 FieldMemOperand(r3, JSArray::kElementsOffset)); |
| 2195 __ ldr(r0, FieldMemOperand(last_match_info_elements, HeapObject::kMapOffset)); | 2340 __ LoadP(r3, |
| 2196 __ CompareRoot(r0, Heap::kFixedArrayMapRootIndex); | 2341 FieldMemOperand(last_match_info_elements, HeapObject::kMapOffset)); |
| 2197 __ b(ne, &runtime); | 2342 __ CompareRoot(r3, Heap::kFixedArrayMapRootIndex); |
| 2343 __ bne(&runtime); |
| 2198 // Check that the last match info has space for the capture registers and the | 2344 // Check that the last match info has space for the capture registers and the |
| 2199 // additional information. | 2345 // additional information. |
| 2200 __ ldr(r0, | 2346 __ LoadP( |
| 2201 FieldMemOperand(last_match_info_elements, FixedArray::kLengthOffset)); | 2347 r3, FieldMemOperand(last_match_info_elements, FixedArray::kLengthOffset)); |
| 2202 __ add(r2, r1, Operand(RegExpImpl::kLastMatchOverhead)); | 2348 __ addi(r5, r4, Operand(RegExpImpl::kLastMatchOverhead)); |
| 2203 __ cmp(r2, Operand::SmiUntag(r0)); | 2349 __ SmiUntag(r0, r3); |
| 2204 __ b(gt, &runtime); | 2350 __ cmp(r5, r0); |
| 2205 | 2351 __ bgt(&runtime); |
| 2206 // r1: number of capture registers | 2352 |
| 2207 // r4: subject string | 2353 // r4: number of capture registers |
| 2354 // subject: subject string |
| 2208 // Store the capture count. | 2355 // Store the capture count. |
| 2209 __ SmiTag(r2, r1); | 2356 __ SmiTag(r5, r4); |
| 2210 __ str(r2, FieldMemOperand(last_match_info_elements, | 2357 __ StoreP(r5, FieldMemOperand(last_match_info_elements, |
| 2211 RegExpImpl::kLastCaptureCountOffset)); | 2358 RegExpImpl::kLastCaptureCountOffset), |
| 2359 r0); |
| 2212 // Store last subject and last input. | 2360 // Store last subject and last input. |
| 2213 __ str(subject, | 2361 __ StoreP(subject, FieldMemOperand(last_match_info_elements, |
| 2214 FieldMemOperand(last_match_info_elements, | 2362 RegExpImpl::kLastSubjectOffset), |
| 2215 RegExpImpl::kLastSubjectOffset)); | 2363 r0); |
| 2216 __ mov(r2, subject); | 2364 __ mr(r5, subject); |
| 2217 __ RecordWriteField(last_match_info_elements, | 2365 __ RecordWriteField(last_match_info_elements, RegExpImpl::kLastSubjectOffset, |
| 2218 RegExpImpl::kLastSubjectOffset, | 2366 subject, r10, kLRHasNotBeenSaved, kDontSaveFPRegs); |
| 2219 subject, | 2367 __ mr(subject, r5); |
| 2220 r3, | 2368 __ StoreP(subject, FieldMemOperand(last_match_info_elements, |
| 2221 kLRHasNotBeenSaved, | 2369 RegExpImpl::kLastInputOffset), |
| 2222 kDontSaveFPRegs); | 2370 r0); |
| 2223 __ mov(subject, r2); | 2371 __ RecordWriteField(last_match_info_elements, RegExpImpl::kLastInputOffset, |
| 2224 __ str(subject, | 2372 subject, r10, kLRHasNotBeenSaved, kDontSaveFPRegs); |
| 2225 FieldMemOperand(last_match_info_elements, | |
| 2226 RegExpImpl::kLastInputOffset)); | |
| 2227 __ RecordWriteField(last_match_info_elements, | |
| 2228 RegExpImpl::kLastInputOffset, | |
| 2229 subject, | |
| 2230 r3, | |
| 2231 kLRHasNotBeenSaved, | |
| 2232 kDontSaveFPRegs); | |
| 2233 | 2373 |
| 2234 // Get the static offsets vector filled by the native regexp code. | 2374 // Get the static offsets vector filled by the native regexp code. |
| 2235 ExternalReference address_of_static_offsets_vector = | 2375 ExternalReference address_of_static_offsets_vector = |
| 2236 ExternalReference::address_of_static_offsets_vector(isolate()); | 2376 ExternalReference::address_of_static_offsets_vector(isolate()); |
| 2237 __ mov(r2, Operand(address_of_static_offsets_vector)); | 2377 __ mov(r5, Operand(address_of_static_offsets_vector)); |
| 2238 | 2378 |
| 2239 // r1: number of capture registers | 2379 // r4: number of capture registers |
| 2240 // r2: offsets vector | 2380 // r5: offsets vector |
| 2241 Label next_capture, done; | 2381 Label next_capture; |
| 2242 // Capture register counter starts from number of capture registers and | 2382 // Capture register counter starts from number of capture registers and |
| 2243 // counts down until wraping after zero. | 2383 // counts down until wraping after zero. |
| 2244 __ add(r0, | 2384 __ addi( |
| 2245 last_match_info_elements, | 2385 r3, last_match_info_elements, |
| 2246 Operand(RegExpImpl::kFirstCaptureOffset - kHeapObjectTag)); | 2386 Operand(RegExpImpl::kFirstCaptureOffset - kHeapObjectTag - kPointerSize)); |
| 2387 __ addi(r5, r5, Operand(-kIntSize)); // bias down for lwzu |
| 2388 __ mtctr(r4); |
| 2247 __ bind(&next_capture); | 2389 __ bind(&next_capture); |
| 2248 __ sub(r1, r1, Operand(1), SetCC); | |
| 2249 __ b(mi, &done); | |
| 2250 // Read the value from the static offsets vector buffer. | 2390 // Read the value from the static offsets vector buffer. |
| 2251 __ ldr(r3, MemOperand(r2, kPointerSize, PostIndex)); | 2391 __ lwzu(r6, MemOperand(r5, kIntSize)); |
| 2252 // Store the smi value in the last match info. | 2392 // Store the smi value in the last match info. |
| 2253 __ SmiTag(r3); | 2393 __ SmiTag(r6); |
| 2254 __ str(r3, MemOperand(r0, kPointerSize, PostIndex)); | 2394 __ StorePU(r6, MemOperand(r3, kPointerSize)); |
| 2255 __ jmp(&next_capture); | 2395 __ bdnz(&next_capture); |
| 2256 __ bind(&done); | |
| 2257 | 2396 |
| 2258 // Return last match info. | 2397 // Return last match info. |
| 2259 __ ldr(r0, MemOperand(sp, kLastMatchInfoOffset)); | 2398 __ LoadP(r3, MemOperand(sp, kLastMatchInfoOffset)); |
| 2260 __ add(sp, sp, Operand(4 * kPointerSize)); | 2399 __ addi(sp, sp, Operand(4 * kPointerSize)); |
| 2261 __ Ret(); | 2400 __ Ret(); |
| 2262 | 2401 |
| 2263 // Do the runtime call to execute the regexp. | 2402 // Do the runtime call to execute the regexp. |
| 2264 __ bind(&runtime); | 2403 __ bind(&runtime); |
| 2265 __ TailCallRuntime(Runtime::kRegExpExecRT, 4, 1); | 2404 __ TailCallRuntime(Runtime::kRegExpExecRT, 4, 1); |
| 2266 | 2405 |
| 2267 // Deferred code for string handling. | 2406 // Deferred code for string handling. |
| 2268 // (6) Not a long external string? If yes, go to (8). | 2407 // (6) Not a long external string? If yes, go to (8). |
| 2269 __ bind(¬_seq_nor_cons); | 2408 __ bind(¬_seq_nor_cons); |
| 2270 // Compare flags are still set. | 2409 // Compare flags are still set. |
| 2271 __ b(gt, ¬_long_external); // Go to (8). | 2410 __ bgt(¬_long_external); // Go to (8). |
| 2272 | 2411 |
| 2273 // (7) External string. Make it, offset-wise, look like a sequential string. | 2412 // (7) External string. Make it, offset-wise, look like a sequential string. |
| 2274 __ bind(&external_string); | 2413 __ bind(&external_string); |
| 2275 __ ldr(r0, FieldMemOperand(subject, HeapObject::kMapOffset)); | 2414 __ LoadP(r3, FieldMemOperand(subject, HeapObject::kMapOffset)); |
| 2276 __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset)); | 2415 __ lbz(r3, FieldMemOperand(r3, Map::kInstanceTypeOffset)); |
| 2277 if (FLAG_debug_code) { | 2416 if (FLAG_debug_code) { |
| 2278 // Assert that we do not have a cons or slice (indirect strings) here. | 2417 // Assert that we do not have a cons or slice (indirect strings) here. |
| 2279 // Sequential strings have already been ruled out. | 2418 // Sequential strings have already been ruled out. |
| 2280 __ tst(r0, Operand(kIsIndirectStringMask)); | 2419 STATIC_ASSERT(kIsIndirectStringMask == 1); |
| 2281 __ Assert(eq, kExternalStringExpectedButNotFound); | 2420 __ andi(r0, r3, Operand(kIsIndirectStringMask)); |
| 2421 __ Assert(eq, kExternalStringExpectedButNotFound, cr0); |
| 2282 } | 2422 } |
| 2283 __ ldr(subject, | 2423 __ LoadP(subject, |
| 2284 FieldMemOperand(subject, ExternalString::kResourceDataOffset)); | 2424 FieldMemOperand(subject, ExternalString::kResourceDataOffset)); |
| 2285 // Move the pointer so that offset-wise, it looks like a sequential string. | 2425 // Move the pointer so that offset-wise, it looks like a sequential string. |
| 2286 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqOneByteString::kHeaderSize); | 2426 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqOneByteString::kHeaderSize); |
| 2287 __ sub(subject, | 2427 __ subi(subject, subject, |
| 2288 subject, | 2428 Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); |
| 2289 Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); | 2429 __ b(&seq_string); // Go to (5). |
| 2290 __ jmp(&seq_string); // Go to (5). | |
| 2291 | 2430 |
| 2292 // (8) Short external string or not a string? If yes, bail out to runtime. | 2431 // (8) Short external string or not a string? If yes, bail out to runtime. |
| 2293 __ bind(¬_long_external); | 2432 __ bind(¬_long_external); |
| 2294 STATIC_ASSERT(kNotStringTag != 0 && kShortExternalStringTag !=0); | 2433 STATIC_ASSERT(kNotStringTag != 0 && kShortExternalStringTag != 0); |
| 2295 __ tst(r1, Operand(kIsNotStringMask | kShortExternalStringMask)); | 2434 __ andi(r0, r4, Operand(kIsNotStringMask | kShortExternalStringMask)); |
| 2296 __ b(ne, &runtime); | 2435 __ bne(&runtime, cr0); |
| 2297 | 2436 |
| 2298 // (9) Sliced string. Replace subject with parent. Go to (4). | 2437 // (9) Sliced string. Replace subject with parent. Go to (4). |
| 2299 // Load offset into r9 and replace subject string with parent. | 2438 // Load offset into r11 and replace subject string with parent. |
| 2300 __ ldr(r9, FieldMemOperand(subject, SlicedString::kOffsetOffset)); | 2439 __ LoadP(r11, FieldMemOperand(subject, SlicedString::kOffsetOffset)); |
| 2301 __ SmiUntag(r9); | 2440 __ SmiUntag(r11); |
| 2302 __ ldr(subject, FieldMemOperand(subject, SlicedString::kParentOffset)); | 2441 __ LoadP(subject, FieldMemOperand(subject, SlicedString::kParentOffset)); |
| 2303 __ jmp(&check_underlying); // Go to (4). | 2442 __ b(&check_underlying); // Go to (4). |
| 2304 #endif // V8_INTERPRETED_REGEXP | 2443 #endif // V8_INTERPRETED_REGEXP |
| 2305 } | 2444 } |
| 2306 | 2445 |
| 2307 | 2446 |
| 2308 static void GenerateRecordCallTarget(MacroAssembler* masm) { | 2447 static void GenerateRecordCallTarget(MacroAssembler* masm) { |
| 2309 // Cache the called function in a feedback vector slot. Cache states | 2448 // Cache the called function in a feedback vector slot. Cache states |
| 2310 // are uninitialized, monomorphic (indicated by a JSFunction), and | 2449 // are uninitialized, monomorphic (indicated by a JSFunction), and |
| 2311 // megamorphic. | 2450 // megamorphic. |
| 2312 // r0 : number of arguments to the construct function | 2451 // r3 : number of arguments to the construct function |
| 2313 // r1 : the function to call | 2452 // r4 : the function to call |
| 2314 // r2 : Feedback vector | 2453 // r5 : Feedback vector |
| 2315 // r3 : slot in feedback vector (Smi) | 2454 // r6 : slot in feedback vector (Smi) |
| 2316 Label initialize, done, miss, megamorphic, not_array_function; | 2455 Label initialize, done, miss, megamorphic, not_array_function; |
| 2317 | 2456 |
| 2318 DCHECK_EQ(*TypeFeedbackInfo::MegamorphicSentinel(masm->isolate()), | 2457 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), |
| 2319 masm->isolate()->heap()->megamorphic_symbol()); | 2458 masm->isolate()->heap()->megamorphic_symbol()); |
| 2320 DCHECK_EQ(*TypeFeedbackInfo::UninitializedSentinel(masm->isolate()), | 2459 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), |
| 2321 masm->isolate()->heap()->uninitialized_symbol()); | 2460 masm->isolate()->heap()->uninitialized_symbol()); |
| 2322 | 2461 |
| 2323 // Load the cache state into r4. | 2462 // Load the cache state into r7. |
| 2324 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3)); | 2463 __ SmiToPtrArrayOffset(r7, r6); |
| 2325 __ ldr(r4, FieldMemOperand(r4, FixedArray::kHeaderSize)); | 2464 __ add(r7, r5, r7); |
| 2465 __ LoadP(r7, FieldMemOperand(r7, FixedArray::kHeaderSize)); |
| 2326 | 2466 |
| 2327 // A monomorphic cache hit or an already megamorphic state: invoke the | 2467 // A monomorphic cache hit or an already megamorphic state: invoke the |
| 2328 // function without changing the state. | 2468 // function without changing the state. |
| 2329 __ cmp(r4, r1); | 2469 __ cmp(r7, r4); |
| 2330 __ b(eq, &done); | 2470 __ b(eq, &done); |
| 2331 | 2471 |
| 2332 if (!FLAG_pretenuring_call_new) { | 2472 if (!FLAG_pretenuring_call_new) { |
| 2333 // If we came here, we need to see if we are the array function. | 2473 // If we came here, we need to see if we are the array function. |
| 2334 // If we didn't have a matching function, and we didn't find the megamorph | 2474 // If we didn't have a matching function, and we didn't find the megamorph |
| 2335 // sentinel, then we have in the slot either some other function or an | 2475 // sentinel, then we have in the slot either some other function or an |
| 2336 // AllocationSite. Do a map check on the object in ecx. | 2476 // AllocationSite. Do a map check on the object in ecx. |
| 2337 __ ldr(r5, FieldMemOperand(r4, 0)); | 2477 __ LoadP(r8, FieldMemOperand(r7, 0)); |
| 2338 __ CompareRoot(r5, Heap::kAllocationSiteMapRootIndex); | 2478 __ CompareRoot(r8, Heap::kAllocationSiteMapRootIndex); |
| 2339 __ b(ne, &miss); | 2479 __ bne(&miss); |
| 2340 | 2480 |
| 2341 // Make sure the function is the Array() function | 2481 // Make sure the function is the Array() function |
| 2342 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, r4); | 2482 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, r7); |
| 2343 __ cmp(r1, r4); | 2483 __ cmp(r4, r7); |
| 2344 __ b(ne, &megamorphic); | 2484 __ bne(&megamorphic); |
| 2345 __ jmp(&done); | 2485 __ b(&done); |
| 2346 } | 2486 } |
| 2347 | 2487 |
| 2348 __ bind(&miss); | 2488 __ bind(&miss); |
| 2349 | 2489 |
| 2350 // A monomorphic miss (i.e, here the cache is not uninitialized) goes | 2490 // A monomorphic miss (i.e, here the cache is not uninitialized) goes |
| 2351 // megamorphic. | 2491 // megamorphic. |
| 2352 __ CompareRoot(r4, Heap::kUninitializedSymbolRootIndex); | 2492 __ CompareRoot(r7, Heap::kUninitializedSymbolRootIndex); |
| 2353 __ b(eq, &initialize); | 2493 __ beq(&initialize); |
| 2354 // MegamorphicSentinel is an immortal immovable object (undefined) so no | 2494 // MegamorphicSentinel is an immortal immovable object (undefined) so no |
| 2355 // write-barrier is needed. | 2495 // write-barrier is needed. |
| 2356 __ bind(&megamorphic); | 2496 __ bind(&megamorphic); |
| 2357 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3)); | 2497 __ SmiToPtrArrayOffset(r7, r6); |
| 2498 __ add(r7, r5, r7); |
| 2358 __ LoadRoot(ip, Heap::kMegamorphicSymbolRootIndex); | 2499 __ LoadRoot(ip, Heap::kMegamorphicSymbolRootIndex); |
| 2359 __ str(ip, FieldMemOperand(r4, FixedArray::kHeaderSize)); | 2500 __ StoreP(ip, FieldMemOperand(r7, FixedArray::kHeaderSize), r0); |
| 2360 __ jmp(&done); | 2501 __ jmp(&done); |
| 2361 | 2502 |
| 2362 // An uninitialized cache is patched with the function | 2503 // An uninitialized cache is patched with the function |
| 2363 __ bind(&initialize); | 2504 __ bind(&initialize); |
| 2364 | 2505 |
| 2365 if (!FLAG_pretenuring_call_new) { | 2506 if (!FLAG_pretenuring_call_new) { |
| 2366 // Make sure the function is the Array() function | 2507 // Make sure the function is the Array() function. |
| 2367 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, r4); | 2508 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, r7); |
| 2368 __ cmp(r1, r4); | 2509 __ cmp(r4, r7); |
| 2369 __ b(ne, ¬_array_function); | 2510 __ bne(¬_array_function); |
| 2370 | 2511 |
| 2371 // The target function is the Array constructor, | 2512 // The target function is the Array constructor, |
| 2372 // Create an AllocationSite if we don't already have it, store it in the | 2513 // Create an AllocationSite if we don't already have it, store it in the |
| 2373 // slot. | 2514 // slot. |
| 2374 { | 2515 { |
| 2375 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 2516 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
| 2376 | 2517 |
| 2377 // Arguments register must be smi-tagged to call out. | 2518 // Arguments register must be smi-tagged to call out. |
| 2378 __ SmiTag(r0); | 2519 __ SmiTag(r3); |
| 2379 __ Push(r3, r2, r1, r0); | 2520 __ Push(r6, r5, r4, r3); |
| 2380 | 2521 |
| 2381 CreateAllocationSiteStub create_stub(masm->isolate()); | 2522 CreateAllocationSiteStub create_stub(masm->isolate()); |
| 2382 __ CallStub(&create_stub); | 2523 __ CallStub(&create_stub); |
| 2383 | 2524 |
| 2384 __ Pop(r3, r2, r1, r0); | 2525 __ Pop(r6, r5, r4, r3); |
| 2385 __ SmiUntag(r0); | 2526 __ SmiUntag(r3); |
| 2386 } | 2527 } |
| 2387 __ b(&done); | 2528 __ b(&done); |
| 2388 | 2529 |
| 2389 __ bind(¬_array_function); | 2530 __ bind(¬_array_function); |
| 2390 } | 2531 } |
| 2391 | 2532 |
| 2392 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3)); | 2533 __ SmiToPtrArrayOffset(r7, r6); |
| 2393 __ add(r4, r4, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | 2534 __ add(r7, r5, r7); |
| 2394 __ str(r1, MemOperand(r4, 0)); | 2535 __ addi(r7, r7, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
| 2536 __ StoreP(r4, MemOperand(r7, 0)); |
| 2395 | 2537 |
| 2396 __ Push(r4, r2, r1); | 2538 __ Push(r7, r5, r4); |
| 2397 __ RecordWrite(r2, r4, r1, kLRHasNotBeenSaved, kDontSaveFPRegs, | 2539 __ RecordWrite(r5, r7, r4, kLRHasNotBeenSaved, kDontSaveFPRegs, |
| 2398 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); | 2540 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); |
| 2399 __ Pop(r4, r2, r1); | 2541 __ Pop(r7, r5, r4); |
| 2400 | 2542 |
| 2401 __ bind(&done); | 2543 __ bind(&done); |
| 2402 } | 2544 } |
| 2403 | 2545 |
| 2404 | 2546 |
| 2405 static void EmitContinueIfStrictOrNative(MacroAssembler* masm, Label* cont) { | 2547 static void EmitContinueIfStrictOrNative(MacroAssembler* masm, Label* cont) { |
| 2406 // Do not transform the receiver for strict mode functions. | 2548 // Do not transform the receiver for strict mode functions and natives. |
| 2407 __ ldr(r3, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); | 2549 __ LoadP(r6, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); |
| 2408 __ ldr(r4, FieldMemOperand(r3, SharedFunctionInfo::kCompilerHintsOffset)); | 2550 __ lwz(r7, FieldMemOperand(r6, SharedFunctionInfo::kCompilerHintsOffset)); |
| 2409 __ tst(r4, Operand(1 << (SharedFunctionInfo::kStrictModeFunction + | 2551 __ TestBit(r7, |
| 2410 kSmiTagSize))); | 2552 #if V8_TARGET_ARCH_PPC64 |
| 2411 __ b(ne, cont); | 2553 SharedFunctionInfo::kStrictModeFunction, |
| 2554 #else |
| 2555 SharedFunctionInfo::kStrictModeFunction + kSmiTagSize, |
| 2556 #endif |
| 2557 r0); |
| 2558 __ bne(cont, cr0); |
| 2412 | 2559 |
| 2413 // Do not transform the receiver for native (Compilerhints already in r3). | 2560 // Do not transform the receiver for native. |
| 2414 __ tst(r4, Operand(1 << (SharedFunctionInfo::kNative + kSmiTagSize))); | 2561 __ TestBit(r7, |
| 2415 __ b(ne, cont); | 2562 #if V8_TARGET_ARCH_PPC64 |
| 2563 SharedFunctionInfo::kNative, |
| 2564 #else |
| 2565 SharedFunctionInfo::kNative + kSmiTagSize, |
| 2566 #endif |
| 2567 r0); |
| 2568 __ bne(cont, cr0); |
| 2416 } | 2569 } |
| 2417 | 2570 |
| 2418 | 2571 |
| 2419 static void EmitSlowCase(MacroAssembler* masm, | 2572 static void EmitSlowCase(MacroAssembler* masm, int argc, Label* non_function) { |
| 2420 int argc, | |
| 2421 Label* non_function) { | |
| 2422 // Check for function proxy. | 2573 // Check for function proxy. |
| 2423 __ cmp(r4, Operand(JS_FUNCTION_PROXY_TYPE)); | 2574 STATIC_ASSERT(JS_FUNCTION_PROXY_TYPE < 0xffffu); |
| 2424 __ b(ne, non_function); | 2575 __ cmpi(r7, Operand(JS_FUNCTION_PROXY_TYPE)); |
| 2425 __ push(r1); // put proxy as additional argument | 2576 __ bne(non_function); |
| 2426 __ mov(r0, Operand(argc + 1, RelocInfo::NONE32)); | 2577 __ push(r4); // put proxy as additional argument |
| 2427 __ mov(r2, Operand::Zero()); | 2578 __ li(r3, Operand(argc + 1)); |
| 2428 __ GetBuiltinFunction(r1, Builtins::CALL_FUNCTION_PROXY); | 2579 __ li(r5, Operand::Zero()); |
| 2580 __ GetBuiltinFunction(r4, Builtins::CALL_FUNCTION_PROXY); |
| 2429 { | 2581 { |
| 2430 Handle<Code> adaptor = | 2582 Handle<Code> adaptor = |
| 2431 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(); | 2583 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(); |
| 2432 __ Jump(adaptor, RelocInfo::CODE_TARGET); | 2584 __ Jump(adaptor, RelocInfo::CODE_TARGET); |
| 2433 } | 2585 } |
| 2434 | 2586 |
| 2435 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead | 2587 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead |
| 2436 // of the original receiver from the call site). | 2588 // of the original receiver from the call site). |
| 2437 __ bind(non_function); | 2589 __ bind(non_function); |
| 2438 __ str(r1, MemOperand(sp, argc * kPointerSize)); | 2590 __ StoreP(r4, MemOperand(sp, argc * kPointerSize), r0); |
| 2439 __ mov(r0, Operand(argc)); // Set up the number of arguments. | 2591 __ li(r3, Operand(argc)); // Set up the number of arguments. |
| 2440 __ mov(r2, Operand::Zero()); | 2592 __ li(r5, Operand::Zero()); |
| 2441 __ GetBuiltinFunction(r1, Builtins::CALL_NON_FUNCTION); | 2593 __ GetBuiltinFunction(r4, Builtins::CALL_NON_FUNCTION); |
| 2442 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 2594 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
| 2443 RelocInfo::CODE_TARGET); | 2595 RelocInfo::CODE_TARGET); |
| 2444 } | 2596 } |
| 2445 | 2597 |
| 2446 | 2598 |
| 2447 static void EmitWrapCase(MacroAssembler* masm, int argc, Label* cont) { | 2599 static void EmitWrapCase(MacroAssembler* masm, int argc, Label* cont) { |
| 2448 // Wrap the receiver and patch it back onto the stack. | 2600 // Wrap the receiver and patch it back onto the stack. |
| 2449 { FrameAndConstantPoolScope frame_scope(masm, StackFrame::INTERNAL); | 2601 { |
| 2450 __ Push(r1, r3); | 2602 FrameAndConstantPoolScope frame_scope(masm, StackFrame::INTERNAL); |
| 2603 __ Push(r4, r6); |
| 2451 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); | 2604 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); |
| 2452 __ pop(r1); | 2605 __ pop(r4); |
| 2453 } | 2606 } |
| 2454 __ str(r0, MemOperand(sp, argc * kPointerSize)); | 2607 __ StoreP(r3, MemOperand(sp, argc * kPointerSize), r0); |
| 2455 __ jmp(cont); | 2608 __ b(cont); |
| 2456 } | 2609 } |
| 2457 | 2610 |
| 2458 | 2611 |
| 2459 static void CallFunctionNoFeedback(MacroAssembler* masm, | 2612 static void CallFunctionNoFeedback(MacroAssembler* masm, int argc, |
| 2460 int argc, bool needs_checks, | 2613 bool needs_checks, bool call_as_method) { |
| 2461 bool call_as_method) { | 2614 // r4 : the function to call |
| 2462 // r1 : the function to call | |
| 2463 Label slow, non_function, wrap, cont; | 2615 Label slow, non_function, wrap, cont; |
| 2464 | 2616 |
| 2465 if (needs_checks) { | 2617 if (needs_checks) { |
| 2466 // Check that the function is really a JavaScript function. | 2618 // Check that the function is really a JavaScript function. |
| 2467 // r1: pushed function (to be verified) | 2619 // r4: pushed function (to be verified) |
| 2468 __ JumpIfSmi(r1, &non_function); | 2620 __ JumpIfSmi(r4, &non_function); |
| 2469 | 2621 |
| 2470 // Goto slow case if we do not have a function. | 2622 // Goto slow case if we do not have a function. |
| 2471 __ CompareObjectType(r1, r4, r4, JS_FUNCTION_TYPE); | 2623 __ CompareObjectType(r4, r7, r7, JS_FUNCTION_TYPE); |
| 2472 __ b(ne, &slow); | 2624 __ bne(&slow); |
| 2473 } | 2625 } |
| 2474 | 2626 |
| 2475 // Fast-case: Invoke the function now. | 2627 // Fast-case: Invoke the function now. |
| 2476 // r1: pushed function | 2628 // r4: pushed function |
| 2477 ParameterCount actual(argc); | 2629 ParameterCount actual(argc); |
| 2478 | 2630 |
| 2479 if (call_as_method) { | 2631 if (call_as_method) { |
| 2480 if (needs_checks) { | 2632 if (needs_checks) { |
| 2481 EmitContinueIfStrictOrNative(masm, &cont); | 2633 EmitContinueIfStrictOrNative(masm, &cont); |
| 2482 } | 2634 } |
| 2483 | 2635 |
| 2484 // Compute the receiver in sloppy mode. | 2636 // Compute the receiver in sloppy mode. |
| 2485 __ ldr(r3, MemOperand(sp, argc * kPointerSize)); | 2637 __ LoadP(r6, MemOperand(sp, argc * kPointerSize), r0); |
| 2486 | 2638 |
| 2487 if (needs_checks) { | 2639 if (needs_checks) { |
| 2488 __ JumpIfSmi(r3, &wrap); | 2640 __ JumpIfSmi(r6, &wrap); |
| 2489 __ CompareObjectType(r3, r4, r4, FIRST_SPEC_OBJECT_TYPE); | 2641 __ CompareObjectType(r6, r7, r7, FIRST_SPEC_OBJECT_TYPE); |
| 2490 __ b(lt, &wrap); | 2642 __ blt(&wrap); |
| 2491 } else { | 2643 } else { |
| 2492 __ jmp(&wrap); | 2644 __ b(&wrap); |
| 2493 } | 2645 } |
| 2494 | 2646 |
| 2495 __ bind(&cont); | 2647 __ bind(&cont); |
| 2496 } | 2648 } |
| 2497 | 2649 |
| 2498 __ InvokeFunction(r1, actual, JUMP_FUNCTION, NullCallWrapper()); | 2650 __ InvokeFunction(r4, actual, JUMP_FUNCTION, NullCallWrapper()); |
| 2499 | 2651 |
| 2500 if (needs_checks) { | 2652 if (needs_checks) { |
| 2501 // Slow-case: Non-function called. | 2653 // Slow-case: Non-function called. |
| 2502 __ bind(&slow); | 2654 __ bind(&slow); |
| 2503 EmitSlowCase(masm, argc, &non_function); | 2655 EmitSlowCase(masm, argc, &non_function); |
| 2504 } | 2656 } |
| 2505 | 2657 |
| 2506 if (call_as_method) { | 2658 if (call_as_method) { |
| 2507 __ bind(&wrap); | 2659 __ bind(&wrap); |
| 2508 EmitWrapCase(masm, argc, &cont); | 2660 EmitWrapCase(masm, argc, &cont); |
| 2509 } | 2661 } |
| 2510 } | 2662 } |
| 2511 | 2663 |
| 2512 | 2664 |
| 2513 void CallFunctionStub::Generate(MacroAssembler* masm) { | 2665 void CallFunctionStub::Generate(MacroAssembler* masm) { |
| 2514 CallFunctionNoFeedback(masm, argc(), NeedsChecks(), CallAsMethod()); | 2666 CallFunctionNoFeedback(masm, argc(), NeedsChecks(), CallAsMethod()); |
| 2515 } | 2667 } |
| 2516 | 2668 |
| 2517 | 2669 |
| 2518 void CallConstructStub::Generate(MacroAssembler* masm) { | 2670 void CallConstructStub::Generate(MacroAssembler* masm) { |
| 2519 // r0 : number of arguments | 2671 // r3 : number of arguments |
| 2520 // r1 : the function to call | 2672 // r4 : the function to call |
| 2521 // r2 : feedback vector | 2673 // r5 : feedback vector |
| 2522 // r3 : (only if r2 is not the megamorphic symbol) slot in feedback | 2674 // r6 : (only if r5 is not the megamorphic symbol) slot in feedback |
| 2523 // vector (Smi) | 2675 // vector (Smi) |
| 2524 Label slow, non_function_call; | 2676 Label slow, non_function_call; |
| 2525 | 2677 |
| 2526 // Check that the function is not a smi. | 2678 // Check that the function is not a smi. |
| 2527 __ JumpIfSmi(r1, &non_function_call); | 2679 __ JumpIfSmi(r4, &non_function_call); |
| 2528 // Check that the function is a JSFunction. | 2680 // Check that the function is a JSFunction. |
| 2529 __ CompareObjectType(r1, r4, r4, JS_FUNCTION_TYPE); | 2681 __ CompareObjectType(r4, r7, r7, JS_FUNCTION_TYPE); |
| 2530 __ b(ne, &slow); | 2682 __ bne(&slow); |
| 2531 | 2683 |
| 2532 if (RecordCallTarget()) { | 2684 if (RecordCallTarget()) { |
| 2533 GenerateRecordCallTarget(masm); | 2685 GenerateRecordCallTarget(masm); |
| 2534 | 2686 |
| 2535 __ add(r5, r2, Operand::PointerOffsetFromSmiKey(r3)); | 2687 __ SmiToPtrArrayOffset(r8, r6); |
| 2688 __ add(r8, r5, r8); |
| 2536 if (FLAG_pretenuring_call_new) { | 2689 if (FLAG_pretenuring_call_new) { |
| 2537 // Put the AllocationSite from the feedback vector into r2. | 2690 // Put the AllocationSite from the feedback vector into r5. |
| 2538 // By adding kPointerSize we encode that we know the AllocationSite | 2691 // By adding kPointerSize we encode that we know the AllocationSite |
| 2539 // entry is at the feedback vector slot given by r3 + 1. | 2692 // entry is at the feedback vector slot given by r6 + 1. |
| 2540 __ ldr(r2, FieldMemOperand(r5, FixedArray::kHeaderSize + kPointerSize)); | 2693 __ LoadP(r5, FieldMemOperand(r8, FixedArray::kHeaderSize + kPointerSize)); |
| 2541 } else { | 2694 } else { |
| 2542 Label feedback_register_initialized; | 2695 Label feedback_register_initialized; |
| 2543 // Put the AllocationSite from the feedback vector into r2, or undefined. | 2696 // Put the AllocationSite from the feedback vector into r5, or undefined. |
| 2544 __ ldr(r2, FieldMemOperand(r5, FixedArray::kHeaderSize)); | 2697 __ LoadP(r5, FieldMemOperand(r8, FixedArray::kHeaderSize)); |
| 2545 __ ldr(r5, FieldMemOperand(r2, AllocationSite::kMapOffset)); | 2698 __ LoadP(r8, FieldMemOperand(r5, AllocationSite::kMapOffset)); |
| 2546 __ CompareRoot(r5, Heap::kAllocationSiteMapRootIndex); | 2699 __ CompareRoot(r8, Heap::kAllocationSiteMapRootIndex); |
| 2547 __ b(eq, &feedback_register_initialized); | 2700 __ beq(&feedback_register_initialized); |
| 2548 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex); | 2701 __ LoadRoot(r5, Heap::kUndefinedValueRootIndex); |
| 2549 __ bind(&feedback_register_initialized); | 2702 __ bind(&feedback_register_initialized); |
| 2550 } | 2703 } |
| 2551 | 2704 |
| 2552 __ AssertUndefinedOrAllocationSite(r2, r5); | 2705 __ AssertUndefinedOrAllocationSite(r5, r8); |
| 2553 } | 2706 } |
| 2554 | 2707 |
| 2555 // Jump to the function-specific construct stub. | 2708 // Jump to the function-specific construct stub. |
| 2556 Register jmp_reg = r4; | 2709 Register jmp_reg = r7; |
| 2557 __ ldr(jmp_reg, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); | 2710 __ LoadP(jmp_reg, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); |
| 2558 __ ldr(jmp_reg, FieldMemOperand(jmp_reg, | 2711 __ LoadP(jmp_reg, |
| 2559 SharedFunctionInfo::kConstructStubOffset)); | 2712 FieldMemOperand(jmp_reg, SharedFunctionInfo::kConstructStubOffset)); |
| 2560 __ add(pc, jmp_reg, Operand(Code::kHeaderSize - kHeapObjectTag)); | 2713 __ addi(r0, jmp_reg, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 2714 __ Jump(r0); |
| 2561 | 2715 |
| 2562 // r0: number of arguments | 2716 // r3: number of arguments |
| 2563 // r1: called object | 2717 // r4: called object |
| 2564 // r4: object type | 2718 // r7: object type |
| 2565 Label do_call; | 2719 Label do_call; |
| 2566 __ bind(&slow); | 2720 __ bind(&slow); |
| 2567 __ cmp(r4, Operand(JS_FUNCTION_PROXY_TYPE)); | 2721 STATIC_ASSERT(JS_FUNCTION_PROXY_TYPE < 0xffffu); |
| 2568 __ b(ne, &non_function_call); | 2722 __ cmpi(r7, Operand(JS_FUNCTION_PROXY_TYPE)); |
| 2569 __ GetBuiltinFunction(r1, Builtins::CALL_FUNCTION_PROXY_AS_CONSTRUCTOR); | 2723 __ bne(&non_function_call); |
| 2570 __ jmp(&do_call); | 2724 __ GetBuiltinFunction(r4, Builtins::CALL_FUNCTION_PROXY_AS_CONSTRUCTOR); |
| 2725 __ b(&do_call); |
| 2571 | 2726 |
| 2572 __ bind(&non_function_call); | 2727 __ bind(&non_function_call); |
| 2573 __ GetBuiltinFunction(r1, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); | 2728 __ GetBuiltinFunction(r4, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); |
| 2574 __ bind(&do_call); | 2729 __ bind(&do_call); |
| 2575 // Set expected number of arguments to zero (not changing r0). | 2730 // Set expected number of arguments to zero (not changing r3). |
| 2576 __ mov(r2, Operand::Zero()); | 2731 __ li(r5, Operand::Zero()); |
| 2577 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 2732 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
| 2578 RelocInfo::CODE_TARGET); | 2733 RelocInfo::CODE_TARGET); |
| 2579 } | 2734 } |
| 2580 | 2735 |
| 2581 | 2736 |
| 2582 static void EmitLoadTypeFeedbackVector(MacroAssembler* masm, Register vector) { | 2737 static void EmitLoadTypeFeedbackVector(MacroAssembler* masm, Register vector) { |
| 2583 __ ldr(vector, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 2738 __ LoadP(vector, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 2584 __ ldr(vector, FieldMemOperand(vector, | 2739 __ LoadP(vector, |
| 2585 JSFunction::kSharedFunctionInfoOffset)); | 2740 FieldMemOperand(vector, JSFunction::kSharedFunctionInfoOffset)); |
| 2586 __ ldr(vector, FieldMemOperand(vector, | 2741 __ LoadP(vector, |
| 2587 SharedFunctionInfo::kFeedbackVectorOffset)); | 2742 FieldMemOperand(vector, SharedFunctionInfo::kFeedbackVectorOffset)); |
| 2588 } | 2743 } |
| 2589 | 2744 |
| 2590 | 2745 |
| 2591 void CallIC_ArrayStub::Generate(MacroAssembler* masm) { | 2746 void CallIC_ArrayStub::Generate(MacroAssembler* masm) { |
| 2592 // r1 - function | 2747 // r4 - function |
| 2593 // r3 - slot id | 2748 // r6 - slot id |
| 2594 Label miss; | 2749 Label miss; |
| 2595 int argc = arg_count(); | 2750 int argc = arg_count(); |
| 2596 ParameterCount actual(argc); | 2751 ParameterCount actual(argc); |
| 2597 | 2752 |
| 2598 EmitLoadTypeFeedbackVector(masm, r2); | 2753 EmitLoadTypeFeedbackVector(masm, r5); |
| 2599 | 2754 |
| 2600 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, r4); | 2755 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, r7); |
| 2601 __ cmp(r1, r4); | 2756 __ cmp(r4, r7); |
| 2602 __ b(ne, &miss); | 2757 __ bne(&miss); |
| 2603 | 2758 |
| 2604 __ mov(r0, Operand(arg_count())); | 2759 __ mov(r3, Operand(arg_count())); |
| 2605 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3)); | 2760 __ SmiToPtrArrayOffset(r7, r6); |
| 2606 __ ldr(r4, FieldMemOperand(r4, FixedArray::kHeaderSize)); | 2761 __ add(r7, r5, r7); |
| 2762 __ LoadP(r7, FieldMemOperand(r7, FixedArray::kHeaderSize)); |
| 2607 | 2763 |
| 2608 // Verify that r4 contains an AllocationSite | 2764 // Verify that r7 contains an AllocationSite |
| 2609 __ ldr(r5, FieldMemOperand(r4, HeapObject::kMapOffset)); | 2765 __ LoadP(r8, FieldMemOperand(r7, HeapObject::kMapOffset)); |
| 2610 __ CompareRoot(r5, Heap::kAllocationSiteMapRootIndex); | 2766 __ CompareRoot(r8, Heap::kAllocationSiteMapRootIndex); |
| 2611 __ b(ne, &miss); | 2767 __ bne(&miss); |
| 2612 | 2768 |
| 2613 __ mov(r2, r4); | 2769 __ mr(r5, r7); |
| 2614 ArrayConstructorStub stub(masm->isolate(), arg_count()); | 2770 ArrayConstructorStub stub(masm->isolate(), arg_count()); |
| 2615 __ TailCallStub(&stub); | 2771 __ TailCallStub(&stub); |
| 2616 | 2772 |
| 2617 __ bind(&miss); | 2773 __ bind(&miss); |
| 2618 GenerateMiss(masm, IC::kCallIC_Customization_Miss); | 2774 GenerateMiss(masm); |
| 2619 | 2775 |
| 2620 // The slow case, we need this no matter what to complete a call after a miss. | 2776 // The slow case, we need this no matter what to complete a call after a miss. |
| 2621 CallFunctionNoFeedback(masm, | 2777 CallFunctionNoFeedback(masm, arg_count(), true, CallAsMethod()); |
| 2622 arg_count(), | |
| 2623 true, | |
| 2624 CallAsMethod()); | |
| 2625 | 2778 |
| 2626 // Unreachable. | 2779 // Unreachable. |
| 2627 __ stop("Unexpected code address"); | 2780 __ stop("Unexpected code address"); |
| 2628 } | 2781 } |
| 2629 | 2782 |
| 2630 | 2783 |
| 2631 void CallICStub::Generate(MacroAssembler* masm) { | 2784 void CallICStub::Generate(MacroAssembler* masm) { |
| 2632 // r1 - function | 2785 // r4 - function |
| 2633 // r3 - slot id (Smi) | 2786 // r6 - slot id (Smi) |
| 2634 Label extra_checks_or_miss, slow_start; | 2787 Label extra_checks_or_miss, slow_start; |
| 2635 Label slow, non_function, wrap, cont; | 2788 Label slow, non_function, wrap, cont; |
| 2636 Label have_js_function; | 2789 Label have_js_function; |
| 2637 int argc = arg_count(); | 2790 int argc = arg_count(); |
| 2638 ParameterCount actual(argc); | 2791 ParameterCount actual(argc); |
| 2639 | 2792 |
| 2640 EmitLoadTypeFeedbackVector(masm, r2); | 2793 EmitLoadTypeFeedbackVector(masm, r5); |
| 2641 | 2794 |
| 2642 // The checks. First, does r1 match the recorded monomorphic target? | 2795 // The checks. First, does r4 match the recorded monomorphic target? |
| 2643 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3)); | 2796 __ SmiToPtrArrayOffset(r7, r6); |
| 2644 __ ldr(r4, FieldMemOperand(r4, FixedArray::kHeaderSize)); | 2797 __ add(r7, r5, r7); |
| 2645 __ cmp(r1, r4); | 2798 __ LoadP(r7, FieldMemOperand(r7, FixedArray::kHeaderSize)); |
| 2646 __ b(ne, &extra_checks_or_miss); | 2799 __ cmp(r4, r7); |
| 2800 __ bne(&extra_checks_or_miss); |
| 2647 | 2801 |
| 2648 __ bind(&have_js_function); | 2802 __ bind(&have_js_function); |
| 2649 if (CallAsMethod()) { | 2803 if (CallAsMethod()) { |
| 2650 EmitContinueIfStrictOrNative(masm, &cont); | 2804 EmitContinueIfStrictOrNative(masm, &cont); |
| 2651 // Compute the receiver in sloppy mode. | 2805 // Compute the receiver in sloppy mode. |
| 2652 __ ldr(r3, MemOperand(sp, argc * kPointerSize)); | 2806 __ LoadP(r6, MemOperand(sp, argc * kPointerSize), r0); |
| 2653 | 2807 |
| 2654 __ JumpIfSmi(r3, &wrap); | 2808 __ JumpIfSmi(r6, &wrap); |
| 2655 __ CompareObjectType(r3, r4, r4, FIRST_SPEC_OBJECT_TYPE); | 2809 __ CompareObjectType(r6, r7, r7, FIRST_SPEC_OBJECT_TYPE); |
| 2656 __ b(lt, &wrap); | 2810 __ blt(&wrap); |
| 2657 | 2811 |
| 2658 __ bind(&cont); | 2812 __ bind(&cont); |
| 2659 } | 2813 } |
| 2660 | 2814 |
| 2661 __ InvokeFunction(r1, actual, JUMP_FUNCTION, NullCallWrapper()); | 2815 __ InvokeFunction(r4, actual, JUMP_FUNCTION, NullCallWrapper()); |
| 2662 | 2816 |
| 2663 __ bind(&slow); | 2817 __ bind(&slow); |
| 2664 EmitSlowCase(masm, argc, &non_function); | 2818 EmitSlowCase(masm, argc, &non_function); |
| 2665 | 2819 |
| 2666 if (CallAsMethod()) { | 2820 if (CallAsMethod()) { |
| 2667 __ bind(&wrap); | 2821 __ bind(&wrap); |
| 2668 EmitWrapCase(masm, argc, &cont); | 2822 EmitWrapCase(masm, argc, &cont); |
| 2669 } | 2823 } |
| 2670 | 2824 |
| 2671 __ bind(&extra_checks_or_miss); | 2825 __ bind(&extra_checks_or_miss); |
| 2672 Label miss; | 2826 Label miss; |
| 2673 | 2827 |
| 2674 __ CompareRoot(r4, Heap::kMegamorphicSymbolRootIndex); | 2828 __ CompareRoot(r7, Heap::kMegamorphicSymbolRootIndex); |
| 2675 __ b(eq, &slow_start); | 2829 __ beq(&slow_start); |
| 2676 __ CompareRoot(r4, Heap::kUninitializedSymbolRootIndex); | 2830 __ CompareRoot(r7, Heap::kUninitializedSymbolRootIndex); |
| 2677 __ b(eq, &miss); | 2831 __ beq(&miss); |
| 2678 | 2832 |
| 2679 if (!FLAG_trace_ic) { | 2833 if (!FLAG_trace_ic) { |
| 2680 // We are going megamorphic. If the feedback is a JSFunction, it is fine | 2834 // We are going megamorphic. If the feedback is a JSFunction, it is fine |
| 2681 // to handle it here. More complex cases are dealt with in the runtime. | 2835 // to handle it here. More complex cases are dealt with in the runtime. |
| 2682 __ AssertNotSmi(r4); | 2836 __ AssertNotSmi(r7); |
| 2683 __ CompareObjectType(r4, r5, r5, JS_FUNCTION_TYPE); | 2837 __ CompareObjectType(r7, r8, r8, JS_FUNCTION_TYPE); |
| 2684 __ b(ne, &miss); | 2838 __ bne(&miss); |
| 2685 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3)); | 2839 __ SmiToPtrArrayOffset(r7, r6); |
| 2840 __ add(r7, r5, r7); |
| 2686 __ LoadRoot(ip, Heap::kMegamorphicSymbolRootIndex); | 2841 __ LoadRoot(ip, Heap::kMegamorphicSymbolRootIndex); |
| 2687 __ str(ip, FieldMemOperand(r4, FixedArray::kHeaderSize)); | 2842 __ StoreP(ip, FieldMemOperand(r7, FixedArray::kHeaderSize), r0); |
| 2688 __ jmp(&slow_start); | 2843 __ jmp(&slow_start); |
| 2689 } | 2844 } |
| 2690 | 2845 |
| 2691 // We are here because tracing is on or we are going monomorphic. | 2846 // We are here because tracing is on or we are going monomorphic. |
| 2692 __ bind(&miss); | 2847 __ bind(&miss); |
| 2693 GenerateMiss(masm, IC::kCallIC_Miss); | 2848 GenerateMiss(masm); |
| 2694 | 2849 |
| 2695 // the slow case | 2850 // the slow case |
| 2696 __ bind(&slow_start); | 2851 __ bind(&slow_start); |
| 2697 // Check that the function is really a JavaScript function. | 2852 // Check that the function is really a JavaScript function. |
| 2698 // r1: pushed function (to be verified) | 2853 // r4: pushed function (to be verified) |
| 2699 __ JumpIfSmi(r1, &non_function); | 2854 __ JumpIfSmi(r4, &non_function); |
| 2700 | 2855 |
| 2701 // Goto slow case if we do not have a function. | 2856 // Goto slow case if we do not have a function. |
| 2702 __ CompareObjectType(r1, r4, r4, JS_FUNCTION_TYPE); | 2857 __ CompareObjectType(r4, r7, r7, JS_FUNCTION_TYPE); |
| 2703 __ b(ne, &slow); | 2858 __ bne(&slow); |
| 2704 __ jmp(&have_js_function); | 2859 __ b(&have_js_function); |
| 2705 } | 2860 } |
| 2706 | 2861 |
| 2707 | 2862 |
| 2708 void CallICStub::GenerateMiss(MacroAssembler* masm, IC::UtilityId id) { | 2863 void CallICStub::GenerateMiss(MacroAssembler* masm) { |
| 2709 // Get the receiver of the function from the stack; 1 ~ return address. | 2864 // Get the receiver of the function from the stack; 1 ~ return address. |
| 2710 __ ldr(r4, MemOperand(sp, (arg_count() + 1) * kPointerSize)); | 2865 __ LoadP(r7, MemOperand(sp, (arg_count() + 1) * kPointerSize), r0); |
| 2711 | 2866 |
| 2712 { | 2867 { |
| 2713 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 2868 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
| 2714 | 2869 |
| 2715 // Push the receiver and the function and feedback info. | 2870 // Push the receiver and the function and feedback info. |
| 2716 __ Push(r4, r1, r2, r3); | 2871 __ Push(r7, r4, r5, r6); |
| 2717 | 2872 |
| 2718 // Call the entry. | 2873 // Call the entry. |
| 2719 ExternalReference miss = ExternalReference(IC_Utility(id), | 2874 IC::UtilityId id = GetICState() == DEFAULT ? IC::kCallIC_Miss |
| 2720 masm->isolate()); | 2875 : IC::kCallIC_Customization_Miss; |
| 2876 |
| 2877 ExternalReference miss = ExternalReference(IC_Utility(id), masm->isolate()); |
| 2721 __ CallExternalReference(miss, 4); | 2878 __ CallExternalReference(miss, 4); |
| 2722 | 2879 |
| 2723 // Move result to edi and exit the internal frame. | 2880 // Move result to r4 and exit the internal frame. |
| 2724 __ mov(r1, r0); | 2881 __ mr(r4, r3); |
| 2725 } | 2882 } |
| 2726 } | 2883 } |
| 2727 | 2884 |
| 2728 | 2885 |
| 2729 // StringCharCodeAtGenerator | 2886 // StringCharCodeAtGenerator |
| 2730 void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) { | 2887 void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) { |
| 2731 // If the receiver is a smi trigger the non-string case. | 2888 // If the receiver is a smi trigger the non-string case. |
| 2732 __ JumpIfSmi(object_, receiver_not_string_); | 2889 __ JumpIfSmi(object_, receiver_not_string_); |
| 2733 | 2890 |
| 2734 // Fetch the instance type of the receiver into result register. | 2891 // Fetch the instance type of the receiver into result register. |
| 2735 __ ldr(result_, FieldMemOperand(object_, HeapObject::kMapOffset)); | 2892 __ LoadP(result_, FieldMemOperand(object_, HeapObject::kMapOffset)); |
| 2736 __ ldrb(result_, FieldMemOperand(result_, Map::kInstanceTypeOffset)); | 2893 __ lbz(result_, FieldMemOperand(result_, Map::kInstanceTypeOffset)); |
| 2737 // If the receiver is not a string trigger the non-string case. | 2894 // If the receiver is not a string trigger the non-string case. |
| 2738 __ tst(result_, Operand(kIsNotStringMask)); | 2895 __ andi(r0, result_, Operand(kIsNotStringMask)); |
| 2739 __ b(ne, receiver_not_string_); | 2896 __ bne(receiver_not_string_, cr0); |
| 2740 | 2897 |
| 2741 // If the index is non-smi trigger the non-smi case. | 2898 // If the index is non-smi trigger the non-smi case. |
| 2742 __ JumpIfNotSmi(index_, &index_not_smi_); | 2899 __ JumpIfNotSmi(index_, &index_not_smi_); |
| 2743 __ bind(&got_smi_index_); | 2900 __ bind(&got_smi_index_); |
| 2744 | 2901 |
| 2745 // Check for index out of range. | 2902 // Check for index out of range. |
| 2746 __ ldr(ip, FieldMemOperand(object_, String::kLengthOffset)); | 2903 __ LoadP(ip, FieldMemOperand(object_, String::kLengthOffset)); |
| 2747 __ cmp(ip, Operand(index_)); | 2904 __ cmpl(ip, index_); |
| 2748 __ b(ls, index_out_of_range_); | 2905 __ ble(index_out_of_range_); |
| 2749 | 2906 |
| 2750 __ SmiUntag(index_); | 2907 __ SmiUntag(index_); |
| 2751 | 2908 |
| 2752 StringCharLoadGenerator::Generate(masm, | 2909 StringCharLoadGenerator::Generate(masm, object_, index_, result_, |
| 2753 object_, | |
| 2754 index_, | |
| 2755 result_, | |
| 2756 &call_runtime_); | 2910 &call_runtime_); |
| 2757 | 2911 |
| 2758 __ SmiTag(result_); | 2912 __ SmiTag(result_); |
| 2759 __ bind(&exit_); | 2913 __ bind(&exit_); |
| 2760 } | 2914 } |
| 2761 | 2915 |
| 2762 | 2916 |
| 2763 void StringCharCodeAtGenerator::GenerateSlow( | 2917 void StringCharCodeAtGenerator::GenerateSlow( |
| 2764 MacroAssembler* masm, | 2918 MacroAssembler* masm, const RuntimeCallHelper& call_helper) { |
| 2765 const RuntimeCallHelper& call_helper) { | |
| 2766 __ Abort(kUnexpectedFallthroughToCharCodeAtSlowCase); | 2919 __ Abort(kUnexpectedFallthroughToCharCodeAtSlowCase); |
| 2767 | 2920 |
| 2768 // Index is not a smi. | 2921 // Index is not a smi. |
| 2769 __ bind(&index_not_smi_); | 2922 __ bind(&index_not_smi_); |
| 2770 // If index is a heap number, try converting it to an integer. | 2923 // If index is a heap number, try converting it to an integer. |
| 2771 __ CheckMap(index_, | 2924 __ CheckMap(index_, result_, Heap::kHeapNumberMapRootIndex, index_not_number_, |
| 2772 result_, | |
| 2773 Heap::kHeapNumberMapRootIndex, | |
| 2774 index_not_number_, | |
| 2775 DONT_DO_SMI_CHECK); | 2925 DONT_DO_SMI_CHECK); |
| 2776 call_helper.BeforeCall(masm); | 2926 call_helper.BeforeCall(masm); |
| 2777 __ push(object_); | 2927 __ push(object_); |
| 2778 __ push(index_); // Consumed by runtime conversion function. | 2928 __ push(index_); // Consumed by runtime conversion function. |
| 2779 if (index_flags_ == STRING_INDEX_IS_NUMBER) { | 2929 if (index_flags_ == STRING_INDEX_IS_NUMBER) { |
| 2780 __ CallRuntime(Runtime::kNumberToIntegerMapMinusZero, 1); | 2930 __ CallRuntime(Runtime::kNumberToIntegerMapMinusZero, 1); |
| 2781 } else { | 2931 } else { |
| 2782 DCHECK(index_flags_ == STRING_INDEX_IS_ARRAY_INDEX); | 2932 DCHECK(index_flags_ == STRING_INDEX_IS_ARRAY_INDEX); |
| 2783 // NumberToSmi discards numbers that are not exact integers. | 2933 // NumberToSmi discards numbers that are not exact integers. |
| 2784 __ CallRuntime(Runtime::kNumberToSmi, 1); | 2934 __ CallRuntime(Runtime::kNumberToSmi, 1); |
| 2785 } | 2935 } |
| 2786 // Save the conversion result before the pop instructions below | 2936 // Save the conversion result before the pop instructions below |
| 2787 // have a chance to overwrite it. | 2937 // have a chance to overwrite it. |
| 2788 __ Move(index_, r0); | 2938 __ Move(index_, r3); |
| 2789 __ pop(object_); | 2939 __ pop(object_); |
| 2790 // Reload the instance type. | 2940 // Reload the instance type. |
| 2791 __ ldr(result_, FieldMemOperand(object_, HeapObject::kMapOffset)); | 2941 __ LoadP(result_, FieldMemOperand(object_, HeapObject::kMapOffset)); |
| 2792 __ ldrb(result_, FieldMemOperand(result_, Map::kInstanceTypeOffset)); | 2942 __ lbz(result_, FieldMemOperand(result_, Map::kInstanceTypeOffset)); |
| 2793 call_helper.AfterCall(masm); | 2943 call_helper.AfterCall(masm); |
| 2794 // If index is still not a smi, it must be out of range. | 2944 // If index is still not a smi, it must be out of range. |
| 2795 __ JumpIfNotSmi(index_, index_out_of_range_); | 2945 __ JumpIfNotSmi(index_, index_out_of_range_); |
| 2796 // Otherwise, return to the fast path. | 2946 // Otherwise, return to the fast path. |
| 2797 __ jmp(&got_smi_index_); | 2947 __ b(&got_smi_index_); |
| 2798 | 2948 |
| 2799 // Call runtime. We get here when the receiver is a string and the | 2949 // Call runtime. We get here when the receiver is a string and the |
| 2800 // index is a number, but the code of getting the actual character | 2950 // index is a number, but the code of getting the actual character |
| 2801 // is too complex (e.g., when the string needs to be flattened). | 2951 // is too complex (e.g., when the string needs to be flattened). |
| 2802 __ bind(&call_runtime_); | 2952 __ bind(&call_runtime_); |
| 2803 call_helper.BeforeCall(masm); | 2953 call_helper.BeforeCall(masm); |
| 2804 __ SmiTag(index_); | 2954 __ SmiTag(index_); |
| 2805 __ Push(object_, index_); | 2955 __ Push(object_, index_); |
| 2806 __ CallRuntime(Runtime::kStringCharCodeAtRT, 2); | 2956 __ CallRuntime(Runtime::kStringCharCodeAtRT, 2); |
| 2807 __ Move(result_, r0); | 2957 __ Move(result_, r3); |
| 2808 call_helper.AfterCall(masm); | 2958 call_helper.AfterCall(masm); |
| 2809 __ jmp(&exit_); | 2959 __ b(&exit_); |
| 2810 | 2960 |
| 2811 __ Abort(kUnexpectedFallthroughFromCharCodeAtSlowCase); | 2961 __ Abort(kUnexpectedFallthroughFromCharCodeAtSlowCase); |
| 2812 } | 2962 } |
| 2813 | 2963 |
| 2814 | 2964 |
| 2815 // ------------------------------------------------------------------------- | 2965 // ------------------------------------------------------------------------- |
| 2816 // StringCharFromCodeGenerator | 2966 // StringCharFromCodeGenerator |
| 2817 | 2967 |
| 2818 void StringCharFromCodeGenerator::GenerateFast(MacroAssembler* masm) { | 2968 void StringCharFromCodeGenerator::GenerateFast(MacroAssembler* masm) { |
| 2819 // Fast case of Heap::LookupSingleCharacterStringFromCode. | 2969 // Fast case of Heap::LookupSingleCharacterStringFromCode. |
| 2820 STATIC_ASSERT(kSmiTag == 0); | |
| 2821 STATIC_ASSERT(kSmiShiftSize == 0); | |
| 2822 DCHECK(base::bits::IsPowerOfTwo32(String::kMaxOneByteCharCode + 1)); | 2970 DCHECK(base::bits::IsPowerOfTwo32(String::kMaxOneByteCharCode + 1)); |
| 2823 __ tst(code_, | 2971 __ LoadSmiLiteral(r0, Smi::FromInt(~String::kMaxOneByteCharCode)); |
| 2824 Operand(kSmiTagMask | | 2972 __ ori(r0, r0, Operand(kSmiTagMask)); |
| 2825 ((~String::kMaxOneByteCharCode) << kSmiTagSize))); | 2973 __ and_(r0, code_, r0); |
| 2826 __ b(ne, &slow_case_); | 2974 __ cmpi(r0, Operand::Zero()); |
| 2975 __ bne(&slow_case_); |
| 2827 | 2976 |
| 2828 __ LoadRoot(result_, Heap::kSingleCharacterStringCacheRootIndex); | 2977 __ LoadRoot(result_, Heap::kSingleCharacterStringCacheRootIndex); |
| 2829 // At this point code register contains smi tagged one-byte char code. | 2978 // At this point code register contains smi tagged one-byte char code. |
| 2830 __ add(result_, result_, Operand::PointerOffsetFromSmiKey(code_)); | 2979 __ mr(r0, code_); |
| 2831 __ ldr(result_, FieldMemOperand(result_, FixedArray::kHeaderSize)); | 2980 __ SmiToPtrArrayOffset(code_, code_); |
| 2981 __ add(result_, result_, code_); |
| 2982 __ mr(code_, r0); |
| 2983 __ LoadP(result_, FieldMemOperand(result_, FixedArray::kHeaderSize)); |
| 2832 __ CompareRoot(result_, Heap::kUndefinedValueRootIndex); | 2984 __ CompareRoot(result_, Heap::kUndefinedValueRootIndex); |
| 2833 __ b(eq, &slow_case_); | 2985 __ beq(&slow_case_); |
| 2834 __ bind(&exit_); | 2986 __ bind(&exit_); |
| 2835 } | 2987 } |
| 2836 | 2988 |
| 2837 | 2989 |
| 2838 void StringCharFromCodeGenerator::GenerateSlow( | 2990 void StringCharFromCodeGenerator::GenerateSlow( |
| 2839 MacroAssembler* masm, | 2991 MacroAssembler* masm, const RuntimeCallHelper& call_helper) { |
| 2840 const RuntimeCallHelper& call_helper) { | |
| 2841 __ Abort(kUnexpectedFallthroughToCharFromCodeSlowCase); | 2992 __ Abort(kUnexpectedFallthroughToCharFromCodeSlowCase); |
| 2842 | 2993 |
| 2843 __ bind(&slow_case_); | 2994 __ bind(&slow_case_); |
| 2844 call_helper.BeforeCall(masm); | 2995 call_helper.BeforeCall(masm); |
| 2845 __ push(code_); | 2996 __ push(code_); |
| 2846 __ CallRuntime(Runtime::kCharFromCode, 1); | 2997 __ CallRuntime(Runtime::kCharFromCode, 1); |
| 2847 __ Move(result_, r0); | 2998 __ Move(result_, r3); |
| 2848 call_helper.AfterCall(masm); | 2999 call_helper.AfterCall(masm); |
| 2849 __ jmp(&exit_); | 3000 __ b(&exit_); |
| 2850 | 3001 |
| 2851 __ Abort(kUnexpectedFallthroughFromCharFromCodeSlowCase); | 3002 __ Abort(kUnexpectedFallthroughFromCharFromCodeSlowCase); |
| 2852 } | 3003 } |
| 2853 | 3004 |
| 2854 | 3005 |
| 2855 enum CopyCharactersFlags { COPY_ONE_BYTE = 1, DEST_ALWAYS_ALIGNED = 2 }; | 3006 enum CopyCharactersFlags { COPY_ONE_BYTE = 1, DEST_ALWAYS_ALIGNED = 2 }; |
| 2856 | 3007 |
| 2857 | 3008 |
| 2858 void StringHelper::GenerateCopyCharacters(MacroAssembler* masm, | 3009 void StringHelper::GenerateCopyCharacters(MacroAssembler* masm, Register dest, |
| 2859 Register dest, | 3010 Register src, Register count, |
| 2860 Register src, | |
| 2861 Register count, | |
| 2862 Register scratch, | 3011 Register scratch, |
| 2863 String::Encoding encoding) { | 3012 String::Encoding encoding) { |
| 2864 if (FLAG_debug_code) { | 3013 if (FLAG_debug_code) { |
| 2865 // Check that destination is word aligned. | 3014 // Check that destination is word aligned. |
| 2866 __ tst(dest, Operand(kPointerAlignmentMask)); | 3015 __ andi(r0, dest, Operand(kPointerAlignmentMask)); |
| 2867 __ Check(eq, kDestinationOfCopyNotAligned); | 3016 __ Check(eq, kDestinationOfCopyNotAligned, cr0); |
| 2868 } | 3017 } |
| 2869 | 3018 |
| 2870 // Assumes word reads and writes are little endian. | |
| 2871 // Nothing to do for zero characters. | 3019 // Nothing to do for zero characters. |
| 2872 Label done; | 3020 Label done; |
| 2873 if (encoding == String::TWO_BYTE_ENCODING) { | 3021 if (encoding == String::TWO_BYTE_ENCODING) { |
| 2874 __ add(count, count, Operand(count), SetCC); | 3022 // double the length |
| 3023 __ add(count, count, count, LeaveOE, SetRC); |
| 3024 __ beq(&done, cr0); |
| 3025 } else { |
| 3026 __ cmpi(count, Operand::Zero()); |
| 3027 __ beq(&done); |
| 2875 } | 3028 } |
| 2876 | 3029 |
| 2877 Register limit = count; // Read until dest equals this. | 3030 // Copy count bytes from src to dst. |
| 2878 __ add(limit, dest, Operand(count)); | 3031 Label byte_loop; |
| 2879 | 3032 __ mtctr(count); |
| 2880 Label loop_entry, loop; | 3033 __ bind(&byte_loop); |
| 2881 // Copy bytes from src to dest until dest hits limit. | 3034 __ lbz(scratch, MemOperand(src)); |
| 2882 __ b(&loop_entry); | 3035 __ addi(src, src, Operand(1)); |
| 2883 __ bind(&loop); | 3036 __ stb(scratch, MemOperand(dest)); |
| 2884 __ ldrb(scratch, MemOperand(src, 1, PostIndex), lt); | 3037 __ addi(dest, dest, Operand(1)); |
| 2885 __ strb(scratch, MemOperand(dest, 1, PostIndex)); | 3038 __ bdnz(&byte_loop); |
| 2886 __ bind(&loop_entry); | |
| 2887 __ cmp(dest, Operand(limit)); | |
| 2888 __ b(lt, &loop); | |
| 2889 | 3039 |
| 2890 __ bind(&done); | 3040 __ bind(&done); |
| 2891 } | 3041 } |
| 2892 | 3042 |
| 2893 | 3043 |
| 2894 void SubStringStub::Generate(MacroAssembler* masm) { | 3044 void SubStringStub::Generate(MacroAssembler* masm) { |
| 2895 Label runtime; | 3045 Label runtime; |
| 2896 | 3046 |
| 2897 // Stack frame on entry. | 3047 // Stack frame on entry. |
| 2898 // lr: return address | 3048 // lr: return address |
| 2899 // sp[0]: to | 3049 // sp[0]: to |
| 2900 // sp[4]: from | 3050 // sp[4]: from |
| 2901 // sp[8]: string | 3051 // sp[8]: string |
| 2902 | 3052 |
| 2903 // This stub is called from the native-call %_SubString(...), so | 3053 // This stub is called from the native-call %_SubString(...), so |
| 2904 // nothing can be assumed about the arguments. It is tested that: | 3054 // nothing can be assumed about the arguments. It is tested that: |
| 2905 // "string" is a sequential string, | 3055 // "string" is a sequential string, |
| 2906 // both "from" and "to" are smis, and | 3056 // both "from" and "to" are smis, and |
| 2907 // 0 <= from <= to <= string.length. | 3057 // 0 <= from <= to <= string.length. |
| 2908 // If any of these assumptions fail, we call the runtime system. | 3058 // If any of these assumptions fail, we call the runtime system. |
| 2909 | 3059 |
| 2910 const int kToOffset = 0 * kPointerSize; | 3060 const int kToOffset = 0 * kPointerSize; |
| 2911 const int kFromOffset = 1 * kPointerSize; | 3061 const int kFromOffset = 1 * kPointerSize; |
| 2912 const int kStringOffset = 2 * kPointerSize; | 3062 const int kStringOffset = 2 * kPointerSize; |
| 2913 | 3063 |
| 2914 __ Ldrd(r2, r3, MemOperand(sp, kToOffset)); | 3064 __ LoadP(r5, MemOperand(sp, kToOffset)); |
| 2915 STATIC_ASSERT(kFromOffset == kToOffset + 4); | 3065 __ LoadP(r6, MemOperand(sp, kFromOffset)); |
| 2916 STATIC_ASSERT(kSmiTag == 0); | |
| 2917 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); | |
| 2918 | 3066 |
| 2919 // Arithmetic shift right by one un-smi-tags. In this case we rotate right | 3067 // If either to or from had the smi tag bit set, then fail to generic runtime |
| 2920 // instead because we bail out on non-smi values: ROR and ASR are equivalent | 3068 __ JumpIfNotSmi(r5, &runtime); |
| 2921 // for smis but they set the flags in a way that's easier to optimize. | 3069 __ JumpIfNotSmi(r6, &runtime); |
| 2922 __ mov(r2, Operand(r2, ROR, 1), SetCC); | 3070 __ SmiUntag(r5); |
| 2923 __ mov(r3, Operand(r3, ROR, 1), SetCC, cc); | 3071 __ SmiUntag(r6, SetRC); |
| 2924 // If either to or from had the smi tag bit set, then C is set now, and N | 3072 // Both r5 and r6 are untagged integers. |
| 2925 // has the same value: we rotated by 1, so the bottom bit is now the top bit. | 3073 |
| 2926 // We want to bailout to runtime here if From is negative. In that case, the | 3074 // We want to bailout to runtime here if From is negative. |
| 2927 // next instruction is not executed and we fall through to bailing out to | 3075 __ blt(&runtime, cr0); // From < 0. |
| 2928 // runtime. | 3076 |
| 2929 // Executed if both r2 and r3 are untagged integers. | 3077 __ cmpl(r6, r5); |
| 2930 __ sub(r2, r2, Operand(r3), SetCC, cc); | 3078 __ bgt(&runtime); // Fail if from > to. |
| 2931 // One of the above un-smis or the above SUB could have set N==1. | 3079 __ sub(r5, r5, r6); |
| 2932 __ b(mi, &runtime); // Either "from" or "to" is not an smi, or from > to. | |
| 2933 | 3080 |
| 2934 // Make sure first argument is a string. | 3081 // Make sure first argument is a string. |
| 2935 __ ldr(r0, MemOperand(sp, kStringOffset)); | 3082 __ LoadP(r3, MemOperand(sp, kStringOffset)); |
| 2936 __ JumpIfSmi(r0, &runtime); | 3083 __ JumpIfSmi(r3, &runtime); |
| 2937 Condition is_string = masm->IsObjectStringType(r0, r1); | 3084 Condition is_string = masm->IsObjectStringType(r3, r4); |
| 2938 __ b(NegateCondition(is_string), &runtime); | 3085 __ b(NegateCondition(is_string), &runtime, cr0); |
| 2939 | 3086 |
| 2940 Label single_char; | 3087 Label single_char; |
| 2941 __ cmp(r2, Operand(1)); | 3088 __ cmpi(r5, Operand(1)); |
| 2942 __ b(eq, &single_char); | 3089 __ b(eq, &single_char); |
| 2943 | 3090 |
| 2944 // Short-cut for the case of trivial substring. | 3091 // Short-cut for the case of trivial substring. |
| 2945 Label return_r0; | 3092 Label return_r3; |
| 2946 // r0: original string | 3093 // r3: original string |
| 2947 // r2: result string length | 3094 // r5: result string length |
| 2948 __ ldr(r4, FieldMemOperand(r0, String::kLengthOffset)); | 3095 __ LoadP(r7, FieldMemOperand(r3, String::kLengthOffset)); |
| 2949 __ cmp(r2, Operand(r4, ASR, 1)); | 3096 __ SmiUntag(r0, r7); |
| 3097 __ cmpl(r5, r0); |
| 2950 // Return original string. | 3098 // Return original string. |
| 2951 __ b(eq, &return_r0); | 3099 __ beq(&return_r3); |
| 2952 // Longer than original string's length or negative: unsafe arguments. | 3100 // Longer than original string's length or negative: unsafe arguments. |
| 2953 __ b(hi, &runtime); | 3101 __ bgt(&runtime); |
| 2954 // Shorter than original string's length: an actual substring. | 3102 // Shorter than original string's length: an actual substring. |
| 2955 | 3103 |
| 2956 // Deal with different string types: update the index if necessary | 3104 // Deal with different string types: update the index if necessary |
| 2957 // and put the underlying string into r5. | 3105 // and put the underlying string into r8. |
| 2958 // r0: original string | 3106 // r3: original string |
| 2959 // r1: instance type | 3107 // r4: instance type |
| 2960 // r2: length | 3108 // r5: length |
| 2961 // r3: from index (untagged) | 3109 // r6: from index (untagged) |
| 2962 Label underlying_unpacked, sliced_string, seq_or_external_string; | 3110 Label underlying_unpacked, sliced_string, seq_or_external_string; |
| 2963 // If the string is not indirect, it can only be sequential or external. | 3111 // If the string is not indirect, it can only be sequential or external. |
| 2964 STATIC_ASSERT(kIsIndirectStringMask == (kSlicedStringTag & kConsStringTag)); | 3112 STATIC_ASSERT(kIsIndirectStringMask == (kSlicedStringTag & kConsStringTag)); |
| 2965 STATIC_ASSERT(kIsIndirectStringMask != 0); | 3113 STATIC_ASSERT(kIsIndirectStringMask != 0); |
| 2966 __ tst(r1, Operand(kIsIndirectStringMask)); | 3114 __ andi(r0, r4, Operand(kIsIndirectStringMask)); |
| 2967 __ b(eq, &seq_or_external_string); | 3115 __ beq(&seq_or_external_string, cr0); |
| 2968 | 3116 |
| 2969 __ tst(r1, Operand(kSlicedNotConsMask)); | 3117 __ andi(r0, r4, Operand(kSlicedNotConsMask)); |
| 2970 __ b(ne, &sliced_string); | 3118 __ bne(&sliced_string, cr0); |
| 2971 // Cons string. Check whether it is flat, then fetch first part. | 3119 // Cons string. Check whether it is flat, then fetch first part. |
| 2972 __ ldr(r5, FieldMemOperand(r0, ConsString::kSecondOffset)); | 3120 __ LoadP(r8, FieldMemOperand(r3, ConsString::kSecondOffset)); |
| 2973 __ CompareRoot(r5, Heap::kempty_stringRootIndex); | 3121 __ CompareRoot(r8, Heap::kempty_stringRootIndex); |
| 2974 __ b(ne, &runtime); | 3122 __ bne(&runtime); |
| 2975 __ ldr(r5, FieldMemOperand(r0, ConsString::kFirstOffset)); | 3123 __ LoadP(r8, FieldMemOperand(r3, ConsString::kFirstOffset)); |
| 2976 // Update instance type. | 3124 // Update instance type. |
| 2977 __ ldr(r1, FieldMemOperand(r5, HeapObject::kMapOffset)); | 3125 __ LoadP(r4, FieldMemOperand(r8, HeapObject::kMapOffset)); |
| 2978 __ ldrb(r1, FieldMemOperand(r1, Map::kInstanceTypeOffset)); | 3126 __ lbz(r4, FieldMemOperand(r4, Map::kInstanceTypeOffset)); |
| 2979 __ jmp(&underlying_unpacked); | 3127 __ b(&underlying_unpacked); |
| 2980 | 3128 |
| 2981 __ bind(&sliced_string); | 3129 __ bind(&sliced_string); |
| 2982 // Sliced string. Fetch parent and correct start index by offset. | 3130 // Sliced string. Fetch parent and correct start index by offset. |
| 2983 __ ldr(r5, FieldMemOperand(r0, SlicedString::kParentOffset)); | 3131 __ LoadP(r8, FieldMemOperand(r3, SlicedString::kParentOffset)); |
| 2984 __ ldr(r4, FieldMemOperand(r0, SlicedString::kOffsetOffset)); | 3132 __ LoadP(r7, FieldMemOperand(r3, SlicedString::kOffsetOffset)); |
| 2985 __ add(r3, r3, Operand(r4, ASR, 1)); // Add offset to index. | 3133 __ SmiUntag(r4, r7); |
| 3134 __ add(r6, r6, r4); // Add offset to index. |
| 2986 // Update instance type. | 3135 // Update instance type. |
| 2987 __ ldr(r1, FieldMemOperand(r5, HeapObject::kMapOffset)); | 3136 __ LoadP(r4, FieldMemOperand(r8, HeapObject::kMapOffset)); |
| 2988 __ ldrb(r1, FieldMemOperand(r1, Map::kInstanceTypeOffset)); | 3137 __ lbz(r4, FieldMemOperand(r4, Map::kInstanceTypeOffset)); |
| 2989 __ jmp(&underlying_unpacked); | 3138 __ b(&underlying_unpacked); |
| 2990 | 3139 |
| 2991 __ bind(&seq_or_external_string); | 3140 __ bind(&seq_or_external_string); |
| 2992 // Sequential or external string. Just move string to the expected register. | 3141 // Sequential or external string. Just move string to the expected register. |
| 2993 __ mov(r5, r0); | 3142 __ mr(r8, r3); |
| 2994 | 3143 |
| 2995 __ bind(&underlying_unpacked); | 3144 __ bind(&underlying_unpacked); |
| 2996 | 3145 |
| 2997 if (FLAG_string_slices) { | 3146 if (FLAG_string_slices) { |
| 2998 Label copy_routine; | 3147 Label copy_routine; |
| 2999 // r5: underlying subject string | 3148 // r8: underlying subject string |
| 3000 // r1: instance type of underlying subject string | 3149 // r4: instance type of underlying subject string |
| 3001 // r2: length | 3150 // r5: length |
| 3002 // r3: adjusted start index (untagged) | 3151 // r6: adjusted start index (untagged) |
| 3003 __ cmp(r2, Operand(SlicedString::kMinLength)); | 3152 __ cmpi(r5, Operand(SlicedString::kMinLength)); |
| 3004 // Short slice. Copy instead of slicing. | 3153 // Short slice. Copy instead of slicing. |
| 3005 __ b(lt, ©_routine); | 3154 __ blt(©_routine); |
| 3006 // Allocate new sliced string. At this point we do not reload the instance | 3155 // Allocate new sliced string. At this point we do not reload the instance |
| 3007 // type including the string encoding because we simply rely on the info | 3156 // type including the string encoding because we simply rely on the info |
| 3008 // provided by the original string. It does not matter if the original | 3157 // provided by the original string. It does not matter if the original |
| 3009 // string's encoding is wrong because we always have to recheck encoding of | 3158 // string's encoding is wrong because we always have to recheck encoding of |
| 3010 // the newly created string's parent anyways due to externalized strings. | 3159 // the newly created string's parent anyways due to externalized strings. |
| 3011 Label two_byte_slice, set_slice_header; | 3160 Label two_byte_slice, set_slice_header; |
| 3012 STATIC_ASSERT((kStringEncodingMask & kOneByteStringTag) != 0); | 3161 STATIC_ASSERT((kStringEncodingMask & kOneByteStringTag) != 0); |
| 3013 STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0); | 3162 STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0); |
| 3014 __ tst(r1, Operand(kStringEncodingMask)); | 3163 __ andi(r0, r4, Operand(kStringEncodingMask)); |
| 3015 __ b(eq, &two_byte_slice); | 3164 __ beq(&two_byte_slice, cr0); |
| 3016 __ AllocateOneByteSlicedString(r0, r2, r6, r4, &runtime); | 3165 __ AllocateOneByteSlicedString(r3, r5, r9, r10, &runtime); |
| 3017 __ jmp(&set_slice_header); | 3166 __ b(&set_slice_header); |
| 3018 __ bind(&two_byte_slice); | 3167 __ bind(&two_byte_slice); |
| 3019 __ AllocateTwoByteSlicedString(r0, r2, r6, r4, &runtime); | 3168 __ AllocateTwoByteSlicedString(r3, r5, r9, r10, &runtime); |
| 3020 __ bind(&set_slice_header); | 3169 __ bind(&set_slice_header); |
| 3021 __ mov(r3, Operand(r3, LSL, 1)); | 3170 __ SmiTag(r6); |
| 3022 __ str(r5, FieldMemOperand(r0, SlicedString::kParentOffset)); | 3171 __ StoreP(r8, FieldMemOperand(r3, SlicedString::kParentOffset), r0); |
| 3023 __ str(r3, FieldMemOperand(r0, SlicedString::kOffsetOffset)); | 3172 __ StoreP(r6, FieldMemOperand(r3, SlicedString::kOffsetOffset), r0); |
| 3024 __ jmp(&return_r0); | 3173 __ b(&return_r3); |
| 3025 | 3174 |
| 3026 __ bind(©_routine); | 3175 __ bind(©_routine); |
| 3027 } | 3176 } |
| 3028 | 3177 |
| 3029 // r5: underlying subject string | 3178 // r8: underlying subject string |
| 3030 // r1: instance type of underlying subject string | 3179 // r4: instance type of underlying subject string |
| 3031 // r2: length | 3180 // r5: length |
| 3032 // r3: adjusted start index (untagged) | 3181 // r6: adjusted start index (untagged) |
| 3033 Label two_byte_sequential, sequential_string, allocate_result; | 3182 Label two_byte_sequential, sequential_string, allocate_result; |
| 3034 STATIC_ASSERT(kExternalStringTag != 0); | 3183 STATIC_ASSERT(kExternalStringTag != 0); |
| 3035 STATIC_ASSERT(kSeqStringTag == 0); | 3184 STATIC_ASSERT(kSeqStringTag == 0); |
| 3036 __ tst(r1, Operand(kExternalStringTag)); | 3185 __ andi(r0, r4, Operand(kExternalStringTag)); |
| 3037 __ b(eq, &sequential_string); | 3186 __ beq(&sequential_string, cr0); |
| 3038 | 3187 |
| 3039 // Handle external string. | 3188 // Handle external string. |
| 3040 // Rule out short external strings. | 3189 // Rule out short external strings. |
| 3041 STATIC_ASSERT(kShortExternalStringTag != 0); | 3190 STATIC_ASSERT(kShortExternalStringTag != 0); |
| 3042 __ tst(r1, Operand(kShortExternalStringTag)); | 3191 __ andi(r0, r4, Operand(kShortExternalStringTag)); |
| 3043 __ b(ne, &runtime); | 3192 __ bne(&runtime, cr0); |
| 3044 __ ldr(r5, FieldMemOperand(r5, ExternalString::kResourceDataOffset)); | 3193 __ LoadP(r8, FieldMemOperand(r8, ExternalString::kResourceDataOffset)); |
| 3045 // r5 already points to the first character of underlying string. | 3194 // r8 already points to the first character of underlying string. |
| 3046 __ jmp(&allocate_result); | 3195 __ b(&allocate_result); |
| 3047 | 3196 |
| 3048 __ bind(&sequential_string); | 3197 __ bind(&sequential_string); |
| 3049 // Locate first character of underlying subject string. | 3198 // Locate first character of underlying subject string. |
| 3050 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqOneByteString::kHeaderSize); | 3199 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqOneByteString::kHeaderSize); |
| 3051 __ add(r5, r5, Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); | 3200 __ addi(r8, r8, Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); |
| 3052 | 3201 |
| 3053 __ bind(&allocate_result); | 3202 __ bind(&allocate_result); |
| 3054 // Sequential acii string. Allocate the result. | 3203 // Sequential acii string. Allocate the result. |
| 3055 STATIC_ASSERT((kOneByteStringTag & kStringEncodingMask) != 0); | 3204 STATIC_ASSERT((kOneByteStringTag & kStringEncodingMask) != 0); |
| 3056 __ tst(r1, Operand(kStringEncodingMask)); | 3205 __ andi(r0, r4, Operand(kStringEncodingMask)); |
| 3057 __ b(eq, &two_byte_sequential); | 3206 __ beq(&two_byte_sequential, cr0); |
| 3058 | 3207 |
| 3059 // Allocate and copy the resulting one-byte string. | 3208 // Allocate and copy the resulting one-byte string. |
| 3060 __ AllocateOneByteString(r0, r2, r4, r6, r1, &runtime); | 3209 __ AllocateOneByteString(r3, r5, r7, r9, r10, &runtime); |
| 3061 | 3210 |
| 3062 // Locate first character of substring to copy. | 3211 // Locate first character of substring to copy. |
| 3063 __ add(r5, r5, r3); | 3212 __ add(r8, r8, r6); |
| 3064 // Locate first character of result. | 3213 // Locate first character of result. |
| 3065 __ add(r1, r0, Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); | 3214 __ addi(r4, r3, Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); |
| 3066 | 3215 |
| 3067 // r0: result string | 3216 // r3: result string |
| 3068 // r1: first character of result string | 3217 // r4: first character of result string |
| 3069 // r2: result string length | 3218 // r5: result string length |
| 3070 // r5: first character of substring to copy | 3219 // r8: first character of substring to copy |
| 3071 STATIC_ASSERT((SeqOneByteString::kHeaderSize & kObjectAlignmentMask) == 0); | 3220 STATIC_ASSERT((SeqOneByteString::kHeaderSize & kObjectAlignmentMask) == 0); |
| 3072 StringHelper::GenerateCopyCharacters( | 3221 StringHelper::GenerateCopyCharacters(masm, r4, r8, r5, r6, |
| 3073 masm, r1, r5, r2, r3, String::ONE_BYTE_ENCODING); | 3222 String::ONE_BYTE_ENCODING); |
| 3074 __ jmp(&return_r0); | 3223 __ b(&return_r3); |
| 3075 | 3224 |
| 3076 // Allocate and copy the resulting two-byte string. | 3225 // Allocate and copy the resulting two-byte string. |
| 3077 __ bind(&two_byte_sequential); | 3226 __ bind(&two_byte_sequential); |
| 3078 __ AllocateTwoByteString(r0, r2, r4, r6, r1, &runtime); | 3227 __ AllocateTwoByteString(r3, r5, r7, r9, r10, &runtime); |
| 3079 | 3228 |
| 3080 // Locate first character of substring to copy. | 3229 // Locate first character of substring to copy. |
| 3081 STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0); | 3230 __ ShiftLeftImm(r4, r6, Operand(1)); |
| 3082 __ add(r5, r5, Operand(r3, LSL, 1)); | 3231 __ add(r8, r8, r4); |
| 3083 // Locate first character of result. | 3232 // Locate first character of result. |
| 3084 __ add(r1, r0, Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); | 3233 __ addi(r4, r3, Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); |
| 3085 | 3234 |
| 3086 // r0: result string. | 3235 // r3: result string. |
| 3087 // r1: first character of result. | 3236 // r4: first character of result. |
| 3088 // r2: result length. | 3237 // r5: result length. |
| 3089 // r5: first character of substring to copy. | 3238 // r8: first character of substring to copy. |
| 3090 STATIC_ASSERT((SeqTwoByteString::kHeaderSize & kObjectAlignmentMask) == 0); | 3239 STATIC_ASSERT((SeqTwoByteString::kHeaderSize & kObjectAlignmentMask) == 0); |
| 3091 StringHelper::GenerateCopyCharacters( | 3240 StringHelper::GenerateCopyCharacters(masm, r4, r8, r5, r6, |
| 3092 masm, r1, r5, r2, r3, String::TWO_BYTE_ENCODING); | 3241 String::TWO_BYTE_ENCODING); |
| 3093 | 3242 |
| 3094 __ bind(&return_r0); | 3243 __ bind(&return_r3); |
| 3095 Counters* counters = isolate()->counters(); | 3244 Counters* counters = isolate()->counters(); |
| 3096 __ IncrementCounter(counters->sub_string_native(), 1, r3, r4); | 3245 __ IncrementCounter(counters->sub_string_native(), 1, r6, r7); |
| 3097 __ Drop(3); | 3246 __ Drop(3); |
| 3098 __ Ret(); | 3247 __ Ret(); |
| 3099 | 3248 |
| 3100 // Just jump to runtime to create the sub string. | 3249 // Just jump to runtime to create the sub string. |
| 3101 __ bind(&runtime); | 3250 __ bind(&runtime); |
| 3102 __ TailCallRuntime(Runtime::kSubString, 3, 1); | 3251 __ TailCallRuntime(Runtime::kSubString, 3, 1); |
| 3103 | 3252 |
| 3104 __ bind(&single_char); | 3253 __ bind(&single_char); |
| 3105 // r0: original string | 3254 // r3: original string |
| 3106 // r1: instance type | 3255 // r4: instance type |
| 3107 // r2: length | 3256 // r5: length |
| 3108 // r3: from index (untagged) | 3257 // r6: from index (untagged) |
| 3109 __ SmiTag(r3, r3); | 3258 __ SmiTag(r6, r6); |
| 3110 StringCharAtGenerator generator( | 3259 StringCharAtGenerator generator(r3, r6, r5, r3, &runtime, &runtime, &runtime, |
| 3111 r0, r3, r2, r0, &runtime, &runtime, &runtime, STRING_INDEX_IS_NUMBER); | 3260 STRING_INDEX_IS_NUMBER); |
| 3112 generator.GenerateFast(masm); | 3261 generator.GenerateFast(masm); |
| 3113 __ Drop(3); | 3262 __ Drop(3); |
| 3114 __ Ret(); | 3263 __ Ret(); |
| 3115 generator.SkipSlow(masm, &runtime); | 3264 generator.SkipSlow(masm, &runtime); |
| 3116 } | 3265 } |
| 3117 | 3266 |
| 3118 | 3267 |
| 3119 void StringHelper::GenerateFlatOneByteStringEquals( | 3268 void StringHelper::GenerateFlatOneByteStringEquals(MacroAssembler* masm, |
| 3120 MacroAssembler* masm, Register left, Register right, Register scratch1, | 3269 Register left, |
| 3121 Register scratch2, Register scratch3) { | 3270 Register right, |
| 3271 Register scratch1, |
| 3272 Register scratch2) { |
| 3122 Register length = scratch1; | 3273 Register length = scratch1; |
| 3123 | 3274 |
| 3124 // Compare lengths. | 3275 // Compare lengths. |
| 3125 Label strings_not_equal, check_zero_length; | 3276 Label strings_not_equal, check_zero_length; |
| 3126 __ ldr(length, FieldMemOperand(left, String::kLengthOffset)); | 3277 __ LoadP(length, FieldMemOperand(left, String::kLengthOffset)); |
| 3127 __ ldr(scratch2, FieldMemOperand(right, String::kLengthOffset)); | 3278 __ LoadP(scratch2, FieldMemOperand(right, String::kLengthOffset)); |
| 3128 __ cmp(length, scratch2); | 3279 __ cmp(length, scratch2); |
| 3129 __ b(eq, &check_zero_length); | 3280 __ beq(&check_zero_length); |
| 3130 __ bind(&strings_not_equal); | 3281 __ bind(&strings_not_equal); |
| 3131 __ mov(r0, Operand(Smi::FromInt(NOT_EQUAL))); | 3282 __ LoadSmiLiteral(r3, Smi::FromInt(NOT_EQUAL)); |
| 3132 __ Ret(); | 3283 __ Ret(); |
| 3133 | 3284 |
| 3134 // Check if the length is zero. | 3285 // Check if the length is zero. |
| 3135 Label compare_chars; | 3286 Label compare_chars; |
| 3136 __ bind(&check_zero_length); | 3287 __ bind(&check_zero_length); |
| 3137 STATIC_ASSERT(kSmiTag == 0); | 3288 STATIC_ASSERT(kSmiTag == 0); |
| 3138 __ cmp(length, Operand::Zero()); | 3289 __ cmpi(length, Operand::Zero()); |
| 3139 __ b(ne, &compare_chars); | 3290 __ bne(&compare_chars); |
| 3140 __ mov(r0, Operand(Smi::FromInt(EQUAL))); | 3291 __ LoadSmiLiteral(r3, Smi::FromInt(EQUAL)); |
| 3141 __ Ret(); | 3292 __ Ret(); |
| 3142 | 3293 |
| 3143 // Compare characters. | 3294 // Compare characters. |
| 3144 __ bind(&compare_chars); | 3295 __ bind(&compare_chars); |
| 3145 GenerateOneByteCharsCompareLoop(masm, left, right, length, scratch2, scratch3, | 3296 GenerateOneByteCharsCompareLoop(masm, left, right, length, scratch2, |
| 3146 &strings_not_equal); | 3297 &strings_not_equal); |
| 3147 | 3298 |
| 3148 // Characters are equal. | 3299 // Characters are equal. |
| 3149 __ mov(r0, Operand(Smi::FromInt(EQUAL))); | 3300 __ LoadSmiLiteral(r3, Smi::FromInt(EQUAL)); |
| 3150 __ Ret(); | 3301 __ Ret(); |
| 3151 } | 3302 } |
| 3152 | 3303 |
| 3153 | 3304 |
| 3154 void StringHelper::GenerateCompareFlatOneByteStrings( | 3305 void StringHelper::GenerateCompareFlatOneByteStrings( |
| 3155 MacroAssembler* masm, Register left, Register right, Register scratch1, | 3306 MacroAssembler* masm, Register left, Register right, Register scratch1, |
| 3156 Register scratch2, Register scratch3, Register scratch4) { | 3307 Register scratch2, Register scratch3) { |
| 3157 Label result_not_equal, compare_lengths; | 3308 Label skip, result_not_equal, compare_lengths; |
| 3158 // Find minimum length and length difference. | 3309 // Find minimum length and length difference. |
| 3159 __ ldr(scratch1, FieldMemOperand(left, String::kLengthOffset)); | 3310 __ LoadP(scratch1, FieldMemOperand(left, String::kLengthOffset)); |
| 3160 __ ldr(scratch2, FieldMemOperand(right, String::kLengthOffset)); | 3311 __ LoadP(scratch2, FieldMemOperand(right, String::kLengthOffset)); |
| 3161 __ sub(scratch3, scratch1, Operand(scratch2), SetCC); | 3312 __ sub(scratch3, scratch1, scratch2, LeaveOE, SetRC); |
| 3162 Register length_delta = scratch3; | 3313 Register length_delta = scratch3; |
| 3163 __ mov(scratch1, scratch2, LeaveCC, gt); | 3314 __ ble(&skip, cr0); |
| 3315 __ mr(scratch1, scratch2); |
| 3316 __ bind(&skip); |
| 3164 Register min_length = scratch1; | 3317 Register min_length = scratch1; |
| 3165 STATIC_ASSERT(kSmiTag == 0); | 3318 STATIC_ASSERT(kSmiTag == 0); |
| 3166 __ cmp(min_length, Operand::Zero()); | 3319 __ cmpi(min_length, Operand::Zero()); |
| 3167 __ b(eq, &compare_lengths); | 3320 __ beq(&compare_lengths); |
| 3168 | 3321 |
| 3169 // Compare loop. | 3322 // Compare loop. |
| 3170 GenerateOneByteCharsCompareLoop(masm, left, right, min_length, scratch2, | 3323 GenerateOneByteCharsCompareLoop(masm, left, right, min_length, scratch2, |
| 3171 scratch4, &result_not_equal); | 3324 &result_not_equal); |
| 3172 | 3325 |
| 3173 // Compare lengths - strings up to min-length are equal. | 3326 // Compare lengths - strings up to min-length are equal. |
| 3174 __ bind(&compare_lengths); | 3327 __ bind(&compare_lengths); |
| 3175 DCHECK(Smi::FromInt(EQUAL) == static_cast<Smi*>(0)); | 3328 DCHECK(Smi::FromInt(EQUAL) == static_cast<Smi*>(0)); |
| 3176 // Use length_delta as result if it's zero. | 3329 // Use length_delta as result if it's zero. |
| 3177 __ mov(r0, Operand(length_delta), SetCC); | 3330 __ mr(r3, length_delta); |
| 3331 __ cmpi(r3, Operand::Zero()); |
| 3178 __ bind(&result_not_equal); | 3332 __ bind(&result_not_equal); |
| 3179 // Conditionally update the result based either on length_delta or | 3333 // Conditionally update the result based either on length_delta or |
| 3180 // the last comparion performed in the loop above. | 3334 // the last comparion performed in the loop above. |
| 3181 __ mov(r0, Operand(Smi::FromInt(GREATER)), LeaveCC, gt); | 3335 Label less_equal, equal; |
| 3182 __ mov(r0, Operand(Smi::FromInt(LESS)), LeaveCC, lt); | 3336 __ ble(&less_equal); |
| 3337 __ LoadSmiLiteral(r3, Smi::FromInt(GREATER)); |
| 3338 __ Ret(); |
| 3339 __ bind(&less_equal); |
| 3340 __ beq(&equal); |
| 3341 __ LoadSmiLiteral(r3, Smi::FromInt(LESS)); |
| 3342 __ bind(&equal); |
| 3183 __ Ret(); | 3343 __ Ret(); |
| 3184 } | 3344 } |
| 3185 | 3345 |
| 3186 | 3346 |
| 3187 void StringHelper::GenerateOneByteCharsCompareLoop( | 3347 void StringHelper::GenerateOneByteCharsCompareLoop( |
| 3188 MacroAssembler* masm, Register left, Register right, Register length, | 3348 MacroAssembler* masm, Register left, Register right, Register length, |
| 3189 Register scratch1, Register scratch2, Label* chars_not_equal) { | 3349 Register scratch1, Label* chars_not_equal) { |
| 3190 // Change index to run from -length to -1 by adding length to string | 3350 // Change index to run from -length to -1 by adding length to string |
| 3191 // start. This means that loop ends when index reaches zero, which | 3351 // start. This means that loop ends when index reaches zero, which |
| 3192 // doesn't need an additional compare. | 3352 // doesn't need an additional compare. |
| 3193 __ SmiUntag(length); | 3353 __ SmiUntag(length); |
| 3194 __ add(scratch1, length, | 3354 __ addi(scratch1, length, |
| 3195 Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); | 3355 Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); |
| 3196 __ add(left, left, Operand(scratch1)); | 3356 __ add(left, left, scratch1); |
| 3197 __ add(right, right, Operand(scratch1)); | 3357 __ add(right, right, scratch1); |
| 3198 __ rsb(length, length, Operand::Zero()); | 3358 __ subfic(length, length, Operand::Zero()); |
| 3199 Register index = length; // index = -length; | 3359 Register index = length; // index = -length; |
| 3200 | 3360 |
| 3201 // Compare loop. | 3361 // Compare loop. |
| 3202 Label loop; | 3362 Label loop; |
| 3203 __ bind(&loop); | 3363 __ bind(&loop); |
| 3204 __ ldrb(scratch1, MemOperand(left, index)); | 3364 __ lbzx(scratch1, MemOperand(left, index)); |
| 3205 __ ldrb(scratch2, MemOperand(right, index)); | 3365 __ lbzx(r0, MemOperand(right, index)); |
| 3206 __ cmp(scratch1, scratch2); | 3366 __ cmp(scratch1, r0); |
| 3207 __ b(ne, chars_not_equal); | 3367 __ bne(chars_not_equal); |
| 3208 __ add(index, index, Operand(1), SetCC); | 3368 __ addi(index, index, Operand(1)); |
| 3209 __ b(ne, &loop); | 3369 __ cmpi(index, Operand::Zero()); |
| 3370 __ bne(&loop); |
| 3210 } | 3371 } |
| 3211 | 3372 |
| 3212 | 3373 |
| 3213 void StringCompareStub::Generate(MacroAssembler* masm) { | 3374 void StringCompareStub::Generate(MacroAssembler* masm) { |
| 3214 Label runtime; | 3375 Label runtime; |
| 3215 | 3376 |
| 3216 Counters* counters = isolate()->counters(); | 3377 Counters* counters = isolate()->counters(); |
| 3217 | 3378 |
| 3218 // Stack frame on entry. | 3379 // Stack frame on entry. |
| 3219 // sp[0]: right string | 3380 // sp[0]: right string |
| 3220 // sp[4]: left string | 3381 // sp[4]: left string |
| 3221 __ Ldrd(r0 , r1, MemOperand(sp)); // Load right in r0, left in r1. | 3382 __ LoadP(r3, MemOperand(sp)); // Load right in r3, left in r4. |
| 3383 __ LoadP(r4, MemOperand(sp, kPointerSize)); |
| 3222 | 3384 |
| 3223 Label not_same; | 3385 Label not_same; |
| 3224 __ cmp(r0, r1); | 3386 __ cmp(r3, r4); |
| 3225 __ b(ne, ¬_same); | 3387 __ bne(¬_same); |
| 3226 STATIC_ASSERT(EQUAL == 0); | 3388 STATIC_ASSERT(EQUAL == 0); |
| 3227 STATIC_ASSERT(kSmiTag == 0); | 3389 STATIC_ASSERT(kSmiTag == 0); |
| 3228 __ mov(r0, Operand(Smi::FromInt(EQUAL))); | 3390 __ LoadSmiLiteral(r3, Smi::FromInt(EQUAL)); |
| 3229 __ IncrementCounter(counters->string_compare_native(), 1, r1, r2); | 3391 __ IncrementCounter(counters->string_compare_native(), 1, r4, r5); |
| 3230 __ add(sp, sp, Operand(2 * kPointerSize)); | 3392 __ addi(sp, sp, Operand(2 * kPointerSize)); |
| 3231 __ Ret(); | 3393 __ Ret(); |
| 3232 | 3394 |
| 3233 __ bind(¬_same); | 3395 __ bind(¬_same); |
| 3234 | 3396 |
| 3235 // Check that both objects are sequential one-byte strings. | 3397 // Check that both objects are sequential one-byte strings. |
| 3236 __ JumpIfNotBothSequentialOneByteStrings(r1, r0, r2, r3, &runtime); | 3398 __ JumpIfNotBothSequentialOneByteStrings(r4, r3, r5, r6, &runtime); |
| 3237 | 3399 |
| 3238 // Compare flat one-byte strings natively. Remove arguments from stack first. | 3400 // Compare flat one-byte strings natively. Remove arguments from stack first. |
| 3239 __ IncrementCounter(counters->string_compare_native(), 1, r2, r3); | 3401 __ IncrementCounter(counters->string_compare_native(), 1, r5, r6); |
| 3240 __ add(sp, sp, Operand(2 * kPointerSize)); | 3402 __ addi(sp, sp, Operand(2 * kPointerSize)); |
| 3241 StringHelper::GenerateCompareFlatOneByteStrings(masm, r1, r0, r2, r3, r4, r5); | 3403 StringHelper::GenerateCompareFlatOneByteStrings(masm, r4, r3, r5, r6, r7); |
| 3242 | 3404 |
| 3243 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) | 3405 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) |
| 3244 // tagged as a small integer. | 3406 // tagged as a small integer. |
| 3245 __ bind(&runtime); | 3407 __ bind(&runtime); |
| 3246 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); | 3408 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); |
| 3247 } | 3409 } |
| 3248 | 3410 |
| 3249 | 3411 |
| 3250 void BinaryOpICWithAllocationSiteStub::Generate(MacroAssembler* masm) { | 3412 void BinaryOpICWithAllocationSiteStub::Generate(MacroAssembler* masm) { |
| 3251 // ----------- S t a t e ------------- | 3413 // ----------- S t a t e ------------- |
| 3252 // -- r1 : left | 3414 // -- r4 : left |
| 3253 // -- r0 : right | 3415 // -- r3 : right |
| 3254 // -- lr : return address | 3416 // -- lr : return address |
| 3255 // ----------------------------------- | 3417 // ----------------------------------- |
| 3256 | 3418 |
| 3257 // Load r2 with the allocation site. We stick an undefined dummy value here | 3419 // Load r5 with the allocation site. We stick an undefined dummy value here |
| 3258 // and replace it with the real allocation site later when we instantiate this | 3420 // and replace it with the real allocation site later when we instantiate this |
| 3259 // stub in BinaryOpICWithAllocationSiteStub::GetCodeCopyFromTemplate(). | 3421 // stub in BinaryOpICWithAllocationSiteStub::GetCodeCopyFromTemplate(). |
| 3260 __ Move(r2, handle(isolate()->heap()->undefined_value())); | 3422 __ Move(r5, handle(isolate()->heap()->undefined_value())); |
| 3261 | 3423 |
| 3262 // Make sure that we actually patched the allocation site. | 3424 // Make sure that we actually patched the allocation site. |
| 3263 if (FLAG_debug_code) { | 3425 if (FLAG_debug_code) { |
| 3264 __ tst(r2, Operand(kSmiTagMask)); | 3426 __ TestIfSmi(r5, r0); |
| 3265 __ Assert(ne, kExpectedAllocationSite); | 3427 __ Assert(ne, kExpectedAllocationSite, cr0); |
| 3266 __ push(r2); | 3428 __ push(r5); |
| 3267 __ ldr(r2, FieldMemOperand(r2, HeapObject::kMapOffset)); | 3429 __ LoadP(r5, FieldMemOperand(r5, HeapObject::kMapOffset)); |
| 3268 __ LoadRoot(ip, Heap::kAllocationSiteMapRootIndex); | 3430 __ LoadRoot(ip, Heap::kAllocationSiteMapRootIndex); |
| 3269 __ cmp(r2, ip); | 3431 __ cmp(r5, ip); |
| 3270 __ pop(r2); | 3432 __ pop(r5); |
| 3271 __ Assert(eq, kExpectedAllocationSite); | 3433 __ Assert(eq, kExpectedAllocationSite); |
| 3272 } | 3434 } |
| 3273 | 3435 |
| 3274 // Tail call into the stub that handles binary operations with allocation | 3436 // Tail call into the stub that handles binary operations with allocation |
| 3275 // sites. | 3437 // sites. |
| 3276 BinaryOpWithAllocationSiteStub stub(isolate(), state()); | 3438 BinaryOpWithAllocationSiteStub stub(isolate(), state()); |
| 3277 __ TailCallStub(&stub); | 3439 __ TailCallStub(&stub); |
| 3278 } | 3440 } |
| 3279 | 3441 |
| 3280 | 3442 |
| 3281 void CompareICStub::GenerateSmis(MacroAssembler* masm) { | 3443 void CompareICStub::GenerateSmis(MacroAssembler* masm) { |
| 3282 DCHECK(state() == CompareIC::SMI); | 3444 DCHECK(state() == CompareICState::SMI); |
| 3283 Label miss; | 3445 Label miss; |
| 3284 __ orr(r2, r1, r0); | 3446 __ orx(r5, r4, r3); |
| 3285 __ JumpIfNotSmi(r2, &miss); | 3447 __ JumpIfNotSmi(r5, &miss); |
| 3286 | 3448 |
| 3287 if (GetCondition() == eq) { | 3449 if (GetCondition() == eq) { |
| 3288 // For equality we do not care about the sign of the result. | 3450 // For equality we do not care about the sign of the result. |
| 3289 __ sub(r0, r0, r1, SetCC); | 3451 // __ sub(r3, r3, r4, SetCC); |
| 3452 __ sub(r3, r3, r4); |
| 3290 } else { | 3453 } else { |
| 3291 // Untag before subtracting to avoid handling overflow. | 3454 // Untag before subtracting to avoid handling overflow. |
| 3292 __ SmiUntag(r1); | 3455 __ SmiUntag(r4); |
| 3293 __ sub(r0, r1, Operand::SmiUntag(r0)); | 3456 __ SmiUntag(r3); |
| 3457 __ sub(r3, r4, r3); |
| 3294 } | 3458 } |
| 3295 __ Ret(); | 3459 __ Ret(); |
| 3296 | 3460 |
| 3297 __ bind(&miss); | 3461 __ bind(&miss); |
| 3298 GenerateMiss(masm); | 3462 GenerateMiss(masm); |
| 3299 } | 3463 } |
| 3300 | 3464 |
| 3301 | 3465 |
| 3302 void CompareICStub::GenerateNumbers(MacroAssembler* masm) { | 3466 void CompareICStub::GenerateNumbers(MacroAssembler* masm) { |
| 3303 DCHECK(state() == CompareIC::NUMBER); | 3467 DCHECK(state() == CompareICState::NUMBER); |
| 3304 | 3468 |
| 3305 Label generic_stub; | 3469 Label generic_stub; |
| 3306 Label unordered, maybe_undefined1, maybe_undefined2; | 3470 Label unordered, maybe_undefined1, maybe_undefined2; |
| 3307 Label miss; | 3471 Label miss; |
| 3472 Label equal, less_than; |
| 3308 | 3473 |
| 3309 if (left() == CompareIC::SMI) { | 3474 if (left() == CompareICState::SMI) { |
| 3310 __ JumpIfNotSmi(r1, &miss); | 3475 __ JumpIfNotSmi(r4, &miss); |
| 3311 } | 3476 } |
| 3312 if (right() == CompareIC::SMI) { | 3477 if (right() == CompareICState::SMI) { |
| 3313 __ JumpIfNotSmi(r0, &miss); | 3478 __ JumpIfNotSmi(r3, &miss); |
| 3314 } | 3479 } |
| 3315 | 3480 |
| 3316 // Inlining the double comparison and falling back to the general compare | 3481 // Inlining the double comparison and falling back to the general compare |
| 3317 // stub if NaN is involved. | 3482 // stub if NaN is involved. |
| 3318 // Load left and right operand. | 3483 // Load left and right operand. |
| 3319 Label done, left, left_smi, right_smi; | 3484 Label done, left, left_smi, right_smi; |
| 3320 __ JumpIfSmi(r0, &right_smi); | 3485 __ JumpIfSmi(r3, &right_smi); |
| 3321 __ CheckMap(r0, r2, Heap::kHeapNumberMapRootIndex, &maybe_undefined1, | 3486 __ CheckMap(r3, r5, Heap::kHeapNumberMapRootIndex, &maybe_undefined1, |
| 3322 DONT_DO_SMI_CHECK); | 3487 DONT_DO_SMI_CHECK); |
| 3323 __ sub(r2, r0, Operand(kHeapObjectTag)); | 3488 __ lfd(d1, FieldMemOperand(r3, HeapNumber::kValueOffset)); |
| 3324 __ vldr(d1, r2, HeapNumber::kValueOffset); | |
| 3325 __ b(&left); | 3489 __ b(&left); |
| 3326 __ bind(&right_smi); | 3490 __ bind(&right_smi); |
| 3327 __ SmiToDouble(d1, r0); | 3491 __ SmiToDouble(d1, r3); |
| 3328 | 3492 |
| 3329 __ bind(&left); | 3493 __ bind(&left); |
| 3330 __ JumpIfSmi(r1, &left_smi); | 3494 __ JumpIfSmi(r4, &left_smi); |
| 3331 __ CheckMap(r1, r2, Heap::kHeapNumberMapRootIndex, &maybe_undefined2, | 3495 __ CheckMap(r4, r5, Heap::kHeapNumberMapRootIndex, &maybe_undefined2, |
| 3332 DONT_DO_SMI_CHECK); | 3496 DONT_DO_SMI_CHECK); |
| 3333 __ sub(r2, r1, Operand(kHeapObjectTag)); | 3497 __ lfd(d0, FieldMemOperand(r4, HeapNumber::kValueOffset)); |
| 3334 __ vldr(d0, r2, HeapNumber::kValueOffset); | |
| 3335 __ b(&done); | 3498 __ b(&done); |
| 3336 __ bind(&left_smi); | 3499 __ bind(&left_smi); |
| 3337 __ SmiToDouble(d0, r1); | 3500 __ SmiToDouble(d0, r4); |
| 3338 | 3501 |
| 3339 __ bind(&done); | 3502 __ bind(&done); |
| 3340 // Compare operands. | 3503 |
| 3341 __ VFPCompareAndSetFlags(d0, d1); | 3504 // Compare operands |
| 3505 __ fcmpu(d0, d1); |
| 3342 | 3506 |
| 3343 // Don't base result on status bits when a NaN is involved. | 3507 // Don't base result on status bits when a NaN is involved. |
| 3344 __ b(vs, &unordered); | 3508 __ bunordered(&unordered); |
| 3345 | 3509 |
| 3346 // Return a result of -1, 0, or 1, based on status bits. | 3510 // Return a result of -1, 0, or 1, based on status bits. |
| 3347 __ mov(r0, Operand(EQUAL), LeaveCC, eq); | 3511 __ beq(&equal); |
| 3348 __ mov(r0, Operand(LESS), LeaveCC, lt); | 3512 __ blt(&less_than); |
| 3349 __ mov(r0, Operand(GREATER), LeaveCC, gt); | 3513 // assume greater than |
| 3514 __ li(r3, Operand(GREATER)); |
| 3515 __ Ret(); |
| 3516 __ bind(&equal); |
| 3517 __ li(r3, Operand(EQUAL)); |
| 3518 __ Ret(); |
| 3519 __ bind(&less_than); |
| 3520 __ li(r3, Operand(LESS)); |
| 3350 __ Ret(); | 3521 __ Ret(); |
| 3351 | 3522 |
| 3352 __ bind(&unordered); | 3523 __ bind(&unordered); |
| 3353 __ bind(&generic_stub); | 3524 __ bind(&generic_stub); |
| 3354 CompareICStub stub(isolate(), op(), CompareIC::GENERIC, CompareIC::GENERIC, | 3525 CompareICStub stub(isolate(), op(), CompareICState::GENERIC, |
| 3355 CompareIC::GENERIC); | 3526 CompareICState::GENERIC, CompareICState::GENERIC); |
| 3356 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); | 3527 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); |
| 3357 | 3528 |
| 3358 __ bind(&maybe_undefined1); | 3529 __ bind(&maybe_undefined1); |
| 3359 if (Token::IsOrderedRelationalCompareOp(op())) { | 3530 if (Token::IsOrderedRelationalCompareOp(op())) { |
| 3360 __ CompareRoot(r0, Heap::kUndefinedValueRootIndex); | 3531 __ CompareRoot(r3, Heap::kUndefinedValueRootIndex); |
| 3361 __ b(ne, &miss); | 3532 __ bne(&miss); |
| 3362 __ JumpIfSmi(r1, &unordered); | 3533 __ JumpIfSmi(r4, &unordered); |
| 3363 __ CompareObjectType(r1, r2, r2, HEAP_NUMBER_TYPE); | 3534 __ CompareObjectType(r4, r5, r5, HEAP_NUMBER_TYPE); |
| 3364 __ b(ne, &maybe_undefined2); | 3535 __ bne(&maybe_undefined2); |
| 3365 __ jmp(&unordered); | 3536 __ b(&unordered); |
| 3366 } | 3537 } |
| 3367 | 3538 |
| 3368 __ bind(&maybe_undefined2); | 3539 __ bind(&maybe_undefined2); |
| 3369 if (Token::IsOrderedRelationalCompareOp(op())) { | 3540 if (Token::IsOrderedRelationalCompareOp(op())) { |
| 3370 __ CompareRoot(r1, Heap::kUndefinedValueRootIndex); | 3541 __ CompareRoot(r4, Heap::kUndefinedValueRootIndex); |
| 3371 __ b(eq, &unordered); | 3542 __ beq(&unordered); |
| 3372 } | 3543 } |
| 3373 | 3544 |
| 3374 __ bind(&miss); | 3545 __ bind(&miss); |
| 3375 GenerateMiss(masm); | 3546 GenerateMiss(masm); |
| 3376 } | 3547 } |
| 3377 | 3548 |
| 3378 | 3549 |
| 3379 void CompareICStub::GenerateInternalizedStrings(MacroAssembler* masm) { | 3550 void CompareICStub::GenerateInternalizedStrings(MacroAssembler* masm) { |
| 3380 DCHECK(state() == CompareIC::INTERNALIZED_STRING); | 3551 DCHECK(state() == CompareICState::INTERNALIZED_STRING); |
| 3381 Label miss; | 3552 Label miss, not_equal; |
| 3382 | 3553 |
| 3383 // Registers containing left and right operands respectively. | 3554 // Registers containing left and right operands respectively. |
| 3384 Register left = r1; | 3555 Register left = r4; |
| 3385 Register right = r0; | 3556 Register right = r3; |
| 3386 Register tmp1 = r2; | 3557 Register tmp1 = r5; |
| 3387 Register tmp2 = r3; | 3558 Register tmp2 = r6; |
| 3388 | 3559 |
| 3389 // Check that both operands are heap objects. | 3560 // Check that both operands are heap objects. |
| 3390 __ JumpIfEitherSmi(left, right, &miss); | 3561 __ JumpIfEitherSmi(left, right, &miss); |
| 3391 | 3562 |
| 3392 // Check that both operands are internalized strings. | 3563 // Check that both operands are symbols. |
| 3393 __ ldr(tmp1, FieldMemOperand(left, HeapObject::kMapOffset)); | 3564 __ LoadP(tmp1, FieldMemOperand(left, HeapObject::kMapOffset)); |
| 3394 __ ldr(tmp2, FieldMemOperand(right, HeapObject::kMapOffset)); | 3565 __ LoadP(tmp2, FieldMemOperand(right, HeapObject::kMapOffset)); |
| 3395 __ ldrb(tmp1, FieldMemOperand(tmp1, Map::kInstanceTypeOffset)); | 3566 __ lbz(tmp1, FieldMemOperand(tmp1, Map::kInstanceTypeOffset)); |
| 3396 __ ldrb(tmp2, FieldMemOperand(tmp2, Map::kInstanceTypeOffset)); | 3567 __ lbz(tmp2, FieldMemOperand(tmp2, Map::kInstanceTypeOffset)); |
| 3397 STATIC_ASSERT(kInternalizedTag == 0 && kStringTag == 0); | 3568 STATIC_ASSERT(kInternalizedTag == 0 && kStringTag == 0); |
| 3398 __ orr(tmp1, tmp1, Operand(tmp2)); | 3569 __ orx(tmp1, tmp1, tmp2); |
| 3399 __ tst(tmp1, Operand(kIsNotStringMask | kIsNotInternalizedMask)); | 3570 __ andi(r0, tmp1, Operand(kIsNotStringMask | kIsNotInternalizedMask)); |
| 3400 __ b(ne, &miss); | 3571 __ bne(&miss, cr0); |
| 3401 | 3572 |
| 3402 // Internalized strings are compared by identity. | 3573 // Internalized strings are compared by identity. |
| 3403 __ cmp(left, right); | 3574 __ cmp(left, right); |
| 3404 // Make sure r0 is non-zero. At this point input operands are | 3575 __ bne(¬_equal); |
| 3576 // Make sure r3 is non-zero. At this point input operands are |
| 3405 // guaranteed to be non-zero. | 3577 // guaranteed to be non-zero. |
| 3406 DCHECK(right.is(r0)); | 3578 DCHECK(right.is(r3)); |
| 3407 STATIC_ASSERT(EQUAL == 0); | 3579 STATIC_ASSERT(EQUAL == 0); |
| 3408 STATIC_ASSERT(kSmiTag == 0); | 3580 STATIC_ASSERT(kSmiTag == 0); |
| 3409 __ mov(r0, Operand(Smi::FromInt(EQUAL)), LeaveCC, eq); | 3581 __ LoadSmiLiteral(r3, Smi::FromInt(EQUAL)); |
| 3582 __ bind(¬_equal); |
| 3410 __ Ret(); | 3583 __ Ret(); |
| 3411 | 3584 |
| 3412 __ bind(&miss); | 3585 __ bind(&miss); |
| 3413 GenerateMiss(masm); | 3586 GenerateMiss(masm); |
| 3414 } | 3587 } |
| 3415 | 3588 |
| 3416 | 3589 |
| 3417 void CompareICStub::GenerateUniqueNames(MacroAssembler* masm) { | 3590 void CompareICStub::GenerateUniqueNames(MacroAssembler* masm) { |
| 3418 DCHECK(state() == CompareIC::UNIQUE_NAME); | 3591 DCHECK(state() == CompareICState::UNIQUE_NAME); |
| 3419 DCHECK(GetCondition() == eq); | 3592 DCHECK(GetCondition() == eq); |
| 3420 Label miss; | 3593 Label miss; |
| 3421 | 3594 |
| 3422 // Registers containing left and right operands respectively. | 3595 // Registers containing left and right operands respectively. |
| 3423 Register left = r1; | 3596 Register left = r4; |
| 3424 Register right = r0; | 3597 Register right = r3; |
| 3425 Register tmp1 = r2; | 3598 Register tmp1 = r5; |
| 3426 Register tmp2 = r3; | 3599 Register tmp2 = r6; |
| 3427 | 3600 |
| 3428 // Check that both operands are heap objects. | 3601 // Check that both operands are heap objects. |
| 3429 __ JumpIfEitherSmi(left, right, &miss); | 3602 __ JumpIfEitherSmi(left, right, &miss); |
| 3430 | 3603 |
| 3431 // Check that both operands are unique names. This leaves the instance | 3604 // Check that both operands are unique names. This leaves the instance |
| 3432 // types loaded in tmp1 and tmp2. | 3605 // types loaded in tmp1 and tmp2. |
| 3433 __ ldr(tmp1, FieldMemOperand(left, HeapObject::kMapOffset)); | 3606 __ LoadP(tmp1, FieldMemOperand(left, HeapObject::kMapOffset)); |
| 3434 __ ldr(tmp2, FieldMemOperand(right, HeapObject::kMapOffset)); | 3607 __ LoadP(tmp2, FieldMemOperand(right, HeapObject::kMapOffset)); |
| 3435 __ ldrb(tmp1, FieldMemOperand(tmp1, Map::kInstanceTypeOffset)); | 3608 __ lbz(tmp1, FieldMemOperand(tmp1, Map::kInstanceTypeOffset)); |
| 3436 __ ldrb(tmp2, FieldMemOperand(tmp2, Map::kInstanceTypeOffset)); | 3609 __ lbz(tmp2, FieldMemOperand(tmp2, Map::kInstanceTypeOffset)); |
| 3437 | 3610 |
| 3438 __ JumpIfNotUniqueName(tmp1, &miss); | 3611 __ JumpIfNotUniqueName(tmp1, &miss); |
| 3439 __ JumpIfNotUniqueName(tmp2, &miss); | 3612 __ JumpIfNotUniqueName(tmp2, &miss); |
| 3440 | 3613 |
| 3441 // Unique names are compared by identity. | 3614 // Unique names are compared by identity. |
| 3442 __ cmp(left, right); | 3615 __ cmp(left, right); |
| 3443 // Make sure r0 is non-zero. At this point input operands are | 3616 __ bne(&miss); |
| 3617 // Make sure r3 is non-zero. At this point input operands are |
| 3444 // guaranteed to be non-zero. | 3618 // guaranteed to be non-zero. |
| 3445 DCHECK(right.is(r0)); | 3619 DCHECK(right.is(r3)); |
| 3446 STATIC_ASSERT(EQUAL == 0); | 3620 STATIC_ASSERT(EQUAL == 0); |
| 3447 STATIC_ASSERT(kSmiTag == 0); | 3621 STATIC_ASSERT(kSmiTag == 0); |
| 3448 __ mov(r0, Operand(Smi::FromInt(EQUAL)), LeaveCC, eq); | 3622 __ LoadSmiLiteral(r3, Smi::FromInt(EQUAL)); |
| 3449 __ Ret(); | 3623 __ Ret(); |
| 3450 | 3624 |
| 3451 __ bind(&miss); | 3625 __ bind(&miss); |
| 3452 GenerateMiss(masm); | 3626 GenerateMiss(masm); |
| 3453 } | 3627 } |
| 3454 | 3628 |
| 3455 | 3629 |
| 3456 void CompareICStub::GenerateStrings(MacroAssembler* masm) { | 3630 void CompareICStub::GenerateStrings(MacroAssembler* masm) { |
| 3457 DCHECK(state() == CompareIC::STRING); | 3631 DCHECK(state() == CompareICState::STRING); |
| 3458 Label miss; | 3632 Label miss, not_identical, is_symbol; |
| 3459 | 3633 |
| 3460 bool equality = Token::IsEqualityOp(op()); | 3634 bool equality = Token::IsEqualityOp(op()); |
| 3461 | 3635 |
| 3462 // Registers containing left and right operands respectively. | 3636 // Registers containing left and right operands respectively. |
| 3463 Register left = r1; | 3637 Register left = r4; |
| 3464 Register right = r0; | 3638 Register right = r3; |
| 3465 Register tmp1 = r2; | 3639 Register tmp1 = r5; |
| 3466 Register tmp2 = r3; | 3640 Register tmp2 = r6; |
| 3467 Register tmp3 = r4; | 3641 Register tmp3 = r7; |
| 3468 Register tmp4 = r5; | 3642 Register tmp4 = r8; |
| 3469 | 3643 |
| 3470 // Check that both operands are heap objects. | 3644 // Check that both operands are heap objects. |
| 3471 __ JumpIfEitherSmi(left, right, &miss); | 3645 __ JumpIfEitherSmi(left, right, &miss); |
| 3472 | 3646 |
| 3473 // Check that both operands are strings. This leaves the instance | 3647 // Check that both operands are strings. This leaves the instance |
| 3474 // types loaded in tmp1 and tmp2. | 3648 // types loaded in tmp1 and tmp2. |
| 3475 __ ldr(tmp1, FieldMemOperand(left, HeapObject::kMapOffset)); | 3649 __ LoadP(tmp1, FieldMemOperand(left, HeapObject::kMapOffset)); |
| 3476 __ ldr(tmp2, FieldMemOperand(right, HeapObject::kMapOffset)); | 3650 __ LoadP(tmp2, FieldMemOperand(right, HeapObject::kMapOffset)); |
| 3477 __ ldrb(tmp1, FieldMemOperand(tmp1, Map::kInstanceTypeOffset)); | 3651 __ lbz(tmp1, FieldMemOperand(tmp1, Map::kInstanceTypeOffset)); |
| 3478 __ ldrb(tmp2, FieldMemOperand(tmp2, Map::kInstanceTypeOffset)); | 3652 __ lbz(tmp2, FieldMemOperand(tmp2, Map::kInstanceTypeOffset)); |
| 3479 STATIC_ASSERT(kNotStringTag != 0); | 3653 STATIC_ASSERT(kNotStringTag != 0); |
| 3480 __ orr(tmp3, tmp1, tmp2); | 3654 __ orx(tmp3, tmp1, tmp2); |
| 3481 __ tst(tmp3, Operand(kIsNotStringMask)); | 3655 __ andi(r0, tmp3, Operand(kIsNotStringMask)); |
| 3482 __ b(ne, &miss); | 3656 __ bne(&miss, cr0); |
| 3483 | 3657 |
| 3484 // Fast check for identical strings. | 3658 // Fast check for identical strings. |
| 3485 __ cmp(left, right); | 3659 __ cmp(left, right); |
| 3486 STATIC_ASSERT(EQUAL == 0); | 3660 STATIC_ASSERT(EQUAL == 0); |
| 3487 STATIC_ASSERT(kSmiTag == 0); | 3661 STATIC_ASSERT(kSmiTag == 0); |
| 3488 __ mov(r0, Operand(Smi::FromInt(EQUAL)), LeaveCC, eq); | 3662 __ bne(¬_identical); |
| 3489 __ Ret(eq); | 3663 __ LoadSmiLiteral(r3, Smi::FromInt(EQUAL)); |
| 3664 __ Ret(); |
| 3665 __ bind(¬_identical); |
| 3490 | 3666 |
| 3491 // Handle not identical strings. | 3667 // Handle not identical strings. |
| 3492 | 3668 |
| 3493 // Check that both strings are internalized strings. If they are, we're done | 3669 // Check that both strings are internalized strings. If they are, we're done |
| 3494 // because we already know they are not identical. We know they are both | 3670 // because we already know they are not identical. We know they are both |
| 3495 // strings. | 3671 // strings. |
| 3496 if (equality) { | 3672 if (equality) { |
| 3497 DCHECK(GetCondition() == eq); | 3673 DCHECK(GetCondition() == eq); |
| 3498 STATIC_ASSERT(kInternalizedTag == 0); | 3674 STATIC_ASSERT(kInternalizedTag == 0); |
| 3499 __ orr(tmp3, tmp1, Operand(tmp2)); | 3675 __ orx(tmp3, tmp1, tmp2); |
| 3500 __ tst(tmp3, Operand(kIsNotInternalizedMask)); | 3676 __ andi(r0, tmp3, Operand(kIsNotInternalizedMask)); |
| 3501 // Make sure r0 is non-zero. At this point input operands are | 3677 __ bne(&is_symbol, cr0); |
| 3678 // Make sure r3 is non-zero. At this point input operands are |
| 3502 // guaranteed to be non-zero. | 3679 // guaranteed to be non-zero. |
| 3503 DCHECK(right.is(r0)); | 3680 DCHECK(right.is(r3)); |
| 3504 __ Ret(eq); | 3681 __ Ret(); |
| 3682 __ bind(&is_symbol); |
| 3505 } | 3683 } |
| 3506 | 3684 |
| 3507 // Check that both strings are sequential one-byte. | 3685 // Check that both strings are sequential one-byte. |
| 3508 Label runtime; | 3686 Label runtime; |
| 3509 __ JumpIfBothInstanceTypesAreNotSequentialOneByte(tmp1, tmp2, tmp3, tmp4, | 3687 __ JumpIfBothInstanceTypesAreNotSequentialOneByte(tmp1, tmp2, tmp3, tmp4, |
| 3510 &runtime); | 3688 &runtime); |
| 3511 | 3689 |
| 3512 // Compare flat one-byte strings. Returns when done. | 3690 // Compare flat one-byte strings. Returns when done. |
| 3513 if (equality) { | 3691 if (equality) { |
| 3514 StringHelper::GenerateFlatOneByteStringEquals(masm, left, right, tmp1, tmp2, | 3692 StringHelper::GenerateFlatOneByteStringEquals(masm, left, right, tmp1, |
| 3515 tmp3); | 3693 tmp2); |
| 3516 } else { | 3694 } else { |
| 3517 StringHelper::GenerateCompareFlatOneByteStrings(masm, left, right, tmp1, | 3695 StringHelper::GenerateCompareFlatOneByteStrings(masm, left, right, tmp1, |
| 3518 tmp2, tmp3, tmp4); | 3696 tmp2, tmp3); |
| 3519 } | 3697 } |
| 3520 | 3698 |
| 3521 // Handle more complex cases in runtime. | 3699 // Handle more complex cases in runtime. |
| 3522 __ bind(&runtime); | 3700 __ bind(&runtime); |
| 3523 __ Push(left, right); | 3701 __ Push(left, right); |
| 3524 if (equality) { | 3702 if (equality) { |
| 3525 __ TailCallRuntime(Runtime::kStringEquals, 2, 1); | 3703 __ TailCallRuntime(Runtime::kStringEquals, 2, 1); |
| 3526 } else { | 3704 } else { |
| 3527 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); | 3705 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); |
| 3528 } | 3706 } |
| 3529 | 3707 |
| 3530 __ bind(&miss); | 3708 __ bind(&miss); |
| 3531 GenerateMiss(masm); | 3709 GenerateMiss(masm); |
| 3532 } | 3710 } |
| 3533 | 3711 |
| 3534 | 3712 |
| 3535 void CompareICStub::GenerateObjects(MacroAssembler* masm) { | 3713 void CompareICStub::GenerateObjects(MacroAssembler* masm) { |
| 3536 DCHECK(state() == CompareIC::OBJECT); | 3714 DCHECK(state() == CompareICState::OBJECT); |
| 3537 Label miss; | 3715 Label miss; |
| 3538 __ and_(r2, r1, Operand(r0)); | 3716 __ and_(r5, r4, r3); |
| 3539 __ JumpIfSmi(r2, &miss); | 3717 __ JumpIfSmi(r5, &miss); |
| 3540 | 3718 |
| 3541 __ CompareObjectType(r0, r2, r2, JS_OBJECT_TYPE); | 3719 __ CompareObjectType(r3, r5, r5, JS_OBJECT_TYPE); |
| 3542 __ b(ne, &miss); | 3720 __ bne(&miss); |
| 3543 __ CompareObjectType(r1, r2, r2, JS_OBJECT_TYPE); | 3721 __ CompareObjectType(r4, r5, r5, JS_OBJECT_TYPE); |
| 3544 __ b(ne, &miss); | 3722 __ bne(&miss); |
| 3545 | 3723 |
| 3546 DCHECK(GetCondition() == eq); | 3724 DCHECK(GetCondition() == eq); |
| 3547 __ sub(r0, r0, Operand(r1)); | 3725 __ sub(r3, r3, r4); |
| 3548 __ Ret(); | 3726 __ Ret(); |
| 3549 | 3727 |
| 3550 __ bind(&miss); | 3728 __ bind(&miss); |
| 3551 GenerateMiss(masm); | 3729 GenerateMiss(masm); |
| 3552 } | 3730 } |
| 3553 | 3731 |
| 3554 | 3732 |
| 3555 void CompareICStub::GenerateKnownObjects(MacroAssembler* masm) { | 3733 void CompareICStub::GenerateKnownObjects(MacroAssembler* masm) { |
| 3556 Label miss; | 3734 Label miss; |
| 3557 __ and_(r2, r1, Operand(r0)); | 3735 __ and_(r5, r4, r3); |
| 3558 __ JumpIfSmi(r2, &miss); | 3736 __ JumpIfSmi(r5, &miss); |
| 3559 __ ldr(r2, FieldMemOperand(r0, HeapObject::kMapOffset)); | 3737 __ LoadP(r5, FieldMemOperand(r3, HeapObject::kMapOffset)); |
| 3560 __ ldr(r3, FieldMemOperand(r1, HeapObject::kMapOffset)); | 3738 __ LoadP(r6, FieldMemOperand(r4, HeapObject::kMapOffset)); |
| 3561 __ cmp(r2, Operand(known_map_)); | 3739 __ Cmpi(r5, Operand(known_map_), r0); |
| 3562 __ b(ne, &miss); | 3740 __ bne(&miss); |
| 3563 __ cmp(r3, Operand(known_map_)); | 3741 __ Cmpi(r6, Operand(known_map_), r0); |
| 3564 __ b(ne, &miss); | 3742 __ bne(&miss); |
| 3565 | 3743 |
| 3566 __ sub(r0, r0, Operand(r1)); | 3744 __ sub(r3, r3, r4); |
| 3567 __ Ret(); | 3745 __ Ret(); |
| 3568 | 3746 |
| 3569 __ bind(&miss); | 3747 __ bind(&miss); |
| 3570 GenerateMiss(masm); | 3748 GenerateMiss(masm); |
| 3571 } | 3749 } |
| 3572 | 3750 |
| 3573 | 3751 |
| 3574 void CompareICStub::GenerateMiss(MacroAssembler* masm) { | 3752 void CompareICStub::GenerateMiss(MacroAssembler* masm) { |
| 3575 { | 3753 { |
| 3576 // Call the runtime system in a fresh internal frame. | 3754 // Call the runtime system in a fresh internal frame. |
| 3577 ExternalReference miss = | 3755 ExternalReference miss = |
| 3578 ExternalReference(IC_Utility(IC::kCompareIC_Miss), isolate()); | 3756 ExternalReference(IC_Utility(IC::kCompareIC_Miss), isolate()); |
| 3579 | 3757 |
| 3580 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 3758 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
| 3581 __ Push(r1, r0); | 3759 __ Push(r4, r3); |
| 3582 __ Push(lr, r1, r0); | 3760 __ mflr(r0); |
| 3583 __ mov(ip, Operand(Smi::FromInt(op()))); | 3761 __ Push(r0, r4, r3); |
| 3762 __ LoadSmiLiteral(ip, Smi::FromInt(op())); |
| 3584 __ push(ip); | 3763 __ push(ip); |
| 3585 __ CallExternalReference(miss, 3); | 3764 __ CallExternalReference(miss, 3); |
| 3586 // Compute the entry point of the rewritten stub. | 3765 // Compute the entry point of the rewritten stub. |
| 3587 __ add(r2, r0, Operand(Code::kHeaderSize - kHeapObjectTag)); | 3766 __ addi(r5, r3, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 3588 // Restore registers. | 3767 // Restore registers. |
| 3589 __ pop(lr); | 3768 __ pop(r0); |
| 3590 __ Pop(r1, r0); | 3769 __ mtlr(r0); |
| 3770 __ Pop(r4, r3); |
| 3591 } | 3771 } |
| 3592 | 3772 |
| 3593 __ Jump(r2); | 3773 __ Jump(r5); |
| 3594 } | 3774 } |
| 3595 | 3775 |
| 3596 | 3776 |
| 3777 // This stub is paired with DirectCEntryStub::GenerateCall |
| 3597 void DirectCEntryStub::Generate(MacroAssembler* masm) { | 3778 void DirectCEntryStub::Generate(MacroAssembler* masm) { |
| 3598 // Place the return address on the stack, making the call | 3779 // Place the return address on the stack, making the call |
| 3599 // GC safe. The RegExp backend also relies on this. | 3780 // GC safe. The RegExp backend also relies on this. |
| 3600 __ str(lr, MemOperand(sp, 0)); | 3781 __ mflr(r0); |
| 3601 __ blx(ip); // Call the C++ function. | 3782 __ StoreP(r0, MemOperand(sp, kStackFrameExtraParamSlot * kPointerSize)); |
| 3602 __ VFPEnsureFPSCRState(r2); | 3783 __ Call(ip); // Call the C++ function. |
| 3603 __ ldr(pc, MemOperand(sp, 0)); | 3784 __ LoadP(r0, MemOperand(sp, kStackFrameExtraParamSlot * kPointerSize)); |
| 3785 __ mtlr(r0); |
| 3786 __ blr(); |
| 3604 } | 3787 } |
| 3605 | 3788 |
| 3606 | 3789 |
| 3607 void DirectCEntryStub::GenerateCall(MacroAssembler* masm, | 3790 void DirectCEntryStub::GenerateCall(MacroAssembler* masm, Register target) { |
| 3608 Register target) { | 3791 #if ABI_USES_FUNCTION_DESCRIPTORS && !defined(USE_SIMULATOR) |
| 3609 intptr_t code = | 3792 // Native AIX/PPC64 Linux use a function descriptor. |
| 3610 reinterpret_cast<intptr_t>(GetCode().location()); | 3793 __ LoadP(ToRegister(ABI_TOC_REGISTER), MemOperand(target, kPointerSize)); |
| 3794 __ LoadP(ip, MemOperand(target, 0)); // Instruction address |
| 3795 #else |
| 3796 // ip needs to be set for DirectCEentryStub::Generate, and also |
| 3797 // for ABI_TOC_ADDRESSABILITY_VIA_IP. |
| 3611 __ Move(ip, target); | 3798 __ Move(ip, target); |
| 3612 __ mov(lr, Operand(code, RelocInfo::CODE_TARGET)); | 3799 #endif |
| 3613 __ blx(lr); // Call the stub. | 3800 |
| 3801 intptr_t code = reinterpret_cast<intptr_t>(GetCode().location()); |
| 3802 __ mov(r0, Operand(code, RelocInfo::CODE_TARGET)); |
| 3803 __ Call(r0); // Call the stub. |
| 3614 } | 3804 } |
| 3615 | 3805 |
| 3616 | 3806 |
| 3617 void NameDictionaryLookupStub::GenerateNegativeLookup(MacroAssembler* masm, | 3807 void NameDictionaryLookupStub::GenerateNegativeLookup( |
| 3618 Label* miss, | 3808 MacroAssembler* masm, Label* miss, Label* done, Register receiver, |
| 3619 Label* done, | 3809 Register properties, Handle<Name> name, Register scratch0) { |
| 3620 Register receiver, | |
| 3621 Register properties, | |
| 3622 Handle<Name> name, | |
| 3623 Register scratch0) { | |
| 3624 DCHECK(name->IsUniqueName()); | 3810 DCHECK(name->IsUniqueName()); |
| 3625 // If names of slots in range from 1 to kProbes - 1 for the hash value are | 3811 // If names of slots in range from 1 to kProbes - 1 for the hash value are |
| 3626 // not equal to the name and kProbes-th slot is not used (its name is the | 3812 // not equal to the name and kProbes-th slot is not used (its name is the |
| 3627 // undefined value), it guarantees the hash table doesn't contain the | 3813 // undefined value), it guarantees the hash table doesn't contain the |
| 3628 // property. It's true even if some slots represent deleted properties | 3814 // property. It's true even if some slots represent deleted properties |
| 3629 // (their names are the hole value). | 3815 // (their names are the hole value). |
| 3630 for (int i = 0; i < kInlinedProbes; i++) { | 3816 for (int i = 0; i < kInlinedProbes; i++) { |
| 3631 // scratch0 points to properties hash. | 3817 // scratch0 points to properties hash. |
| 3632 // Compute the masked index: (hash + i + i * i) & mask. | 3818 // Compute the masked index: (hash + i + i * i) & mask. |
| 3633 Register index = scratch0; | 3819 Register index = scratch0; |
| 3634 // Capacity is smi 2^n. | 3820 // Capacity is smi 2^n. |
| 3635 __ ldr(index, FieldMemOperand(properties, kCapacityOffset)); | 3821 __ LoadP(index, FieldMemOperand(properties, kCapacityOffset)); |
| 3636 __ sub(index, index, Operand(1)); | 3822 __ subi(index, index, Operand(1)); |
| 3637 __ and_(index, index, Operand( | 3823 __ LoadSmiLiteral( |
| 3638 Smi::FromInt(name->Hash() + NameDictionary::GetProbeOffset(i)))); | 3824 ip, Smi::FromInt(name->Hash() + NameDictionary::GetProbeOffset(i))); |
| 3825 __ and_(index, index, ip); |
| 3639 | 3826 |
| 3640 // Scale the index by multiplying by the entry size. | 3827 // Scale the index by multiplying by the entry size. |
| 3641 DCHECK(NameDictionary::kEntrySize == 3); | 3828 DCHECK(NameDictionary::kEntrySize == 3); |
| 3642 __ add(index, index, Operand(index, LSL, 1)); // index *= 3. | 3829 __ ShiftLeftImm(ip, index, Operand(1)); |
| 3830 __ add(index, index, ip); // index *= 3. |
| 3643 | 3831 |
| 3644 Register entity_name = scratch0; | 3832 Register entity_name = scratch0; |
| 3645 // Having undefined at this place means the name is not contained. | 3833 // Having undefined at this place means the name is not contained. |
| 3646 DCHECK_EQ(kSmiTagSize, 1); | |
| 3647 Register tmp = properties; | 3834 Register tmp = properties; |
| 3648 __ add(tmp, properties, Operand(index, LSL, 1)); | 3835 __ SmiToPtrArrayOffset(ip, index); |
| 3649 __ ldr(entity_name, FieldMemOperand(tmp, kElementsStartOffset)); | 3836 __ add(tmp, properties, ip); |
| 3837 __ LoadP(entity_name, FieldMemOperand(tmp, kElementsStartOffset)); |
| 3650 | 3838 |
| 3651 DCHECK(!tmp.is(entity_name)); | 3839 DCHECK(!tmp.is(entity_name)); |
| 3652 __ LoadRoot(tmp, Heap::kUndefinedValueRootIndex); | 3840 __ LoadRoot(tmp, Heap::kUndefinedValueRootIndex); |
| 3653 __ cmp(entity_name, tmp); | 3841 __ cmp(entity_name, tmp); |
| 3654 __ b(eq, done); | 3842 __ beq(done); |
| 3655 | 3843 |
| 3656 // Load the hole ready for use below: | 3844 // Load the hole ready for use below: |
| 3657 __ LoadRoot(tmp, Heap::kTheHoleValueRootIndex); | 3845 __ LoadRoot(tmp, Heap::kTheHoleValueRootIndex); |
| 3658 | 3846 |
| 3659 // Stop if found the property. | 3847 // Stop if found the property. |
| 3660 __ cmp(entity_name, Operand(Handle<Name>(name))); | 3848 __ Cmpi(entity_name, Operand(Handle<Name>(name)), r0); |
| 3661 __ b(eq, miss); | 3849 __ beq(miss); |
| 3662 | 3850 |
| 3663 Label good; | 3851 Label good; |
| 3664 __ cmp(entity_name, tmp); | 3852 __ cmp(entity_name, tmp); |
| 3665 __ b(eq, &good); | 3853 __ beq(&good); |
| 3666 | 3854 |
| 3667 // Check if the entry name is not a unique name. | 3855 // Check if the entry name is not a unique name. |
| 3668 __ ldr(entity_name, FieldMemOperand(entity_name, HeapObject::kMapOffset)); | 3856 __ LoadP(entity_name, FieldMemOperand(entity_name, HeapObject::kMapOffset)); |
| 3669 __ ldrb(entity_name, | 3857 __ lbz(entity_name, FieldMemOperand(entity_name, Map::kInstanceTypeOffset)); |
| 3670 FieldMemOperand(entity_name, Map::kInstanceTypeOffset)); | |
| 3671 __ JumpIfNotUniqueName(entity_name, miss); | 3858 __ JumpIfNotUniqueName(entity_name, miss); |
| 3672 __ bind(&good); | 3859 __ bind(&good); |
| 3673 | 3860 |
| 3674 // Restore the properties. | 3861 // Restore the properties. |
| 3675 __ ldr(properties, | 3862 __ LoadP(properties, |
| 3676 FieldMemOperand(receiver, JSObject::kPropertiesOffset)); | 3863 FieldMemOperand(receiver, JSObject::kPropertiesOffset)); |
| 3677 } | 3864 } |
| 3678 | 3865 |
| 3679 const int spill_mask = | 3866 const int spill_mask = (r0.bit() | r9.bit() | r8.bit() | r7.bit() | r6.bit() | |
| 3680 (lr.bit() | r6.bit() | r5.bit() | r4.bit() | r3.bit() | | 3867 r5.bit() | r4.bit() | r3.bit()); |
| 3681 r2.bit() | r1.bit() | r0.bit()); | |
| 3682 | 3868 |
| 3683 __ stm(db_w, sp, spill_mask); | 3869 __ mflr(r0); |
| 3684 __ ldr(r0, FieldMemOperand(receiver, JSObject::kPropertiesOffset)); | 3870 __ MultiPush(spill_mask); |
| 3685 __ mov(r1, Operand(Handle<Name>(name))); | 3871 |
| 3872 __ LoadP(r3, FieldMemOperand(receiver, JSObject::kPropertiesOffset)); |
| 3873 __ mov(r4, Operand(Handle<Name>(name))); |
| 3686 NameDictionaryLookupStub stub(masm->isolate(), NEGATIVE_LOOKUP); | 3874 NameDictionaryLookupStub stub(masm->isolate(), NEGATIVE_LOOKUP); |
| 3687 __ CallStub(&stub); | 3875 __ CallStub(&stub); |
| 3688 __ cmp(r0, Operand::Zero()); | 3876 __ cmpi(r3, Operand::Zero()); |
| 3689 __ ldm(ia_w, sp, spill_mask); | |
| 3690 | 3877 |
| 3691 __ b(eq, done); | 3878 __ MultiPop(spill_mask); // MultiPop does not touch condition flags |
| 3692 __ b(ne, miss); | 3879 __ mtlr(r0); |
| 3880 |
| 3881 __ beq(done); |
| 3882 __ bne(miss); |
| 3693 } | 3883 } |
| 3694 | 3884 |
| 3695 | 3885 |
| 3696 // Probe the name dictionary in the |elements| register. Jump to the | 3886 // Probe the name dictionary in the |elements| register. Jump to the |
| 3697 // |done| label if a property with the given name is found. Jump to | 3887 // |done| label if a property with the given name is found. Jump to |
| 3698 // the |miss| label otherwise. | 3888 // the |miss| label otherwise. |
| 3699 // If lookup was successful |scratch2| will be equal to elements + 4 * index. | 3889 // If lookup was successful |scratch2| will be equal to elements + 4 * index. |
| 3700 void NameDictionaryLookupStub::GeneratePositiveLookup(MacroAssembler* masm, | 3890 void NameDictionaryLookupStub::GeneratePositiveLookup( |
| 3701 Label* miss, | 3891 MacroAssembler* masm, Label* miss, Label* done, Register elements, |
| 3702 Label* done, | 3892 Register name, Register scratch1, Register scratch2) { |
| 3703 Register elements, | |
| 3704 Register name, | |
| 3705 Register scratch1, | |
| 3706 Register scratch2) { | |
| 3707 DCHECK(!elements.is(scratch1)); | 3893 DCHECK(!elements.is(scratch1)); |
| 3708 DCHECK(!elements.is(scratch2)); | 3894 DCHECK(!elements.is(scratch2)); |
| 3709 DCHECK(!name.is(scratch1)); | 3895 DCHECK(!name.is(scratch1)); |
| 3710 DCHECK(!name.is(scratch2)); | 3896 DCHECK(!name.is(scratch2)); |
| 3711 | 3897 |
| 3712 __ AssertName(name); | 3898 __ AssertName(name); |
| 3713 | 3899 |
| 3714 // Compute the capacity mask. | 3900 // Compute the capacity mask. |
| 3715 __ ldr(scratch1, FieldMemOperand(elements, kCapacityOffset)); | 3901 __ LoadP(scratch1, FieldMemOperand(elements, kCapacityOffset)); |
| 3716 __ SmiUntag(scratch1); | 3902 __ SmiUntag(scratch1); // convert smi to int |
| 3717 __ sub(scratch1, scratch1, Operand(1)); | 3903 __ subi(scratch1, scratch1, Operand(1)); |
| 3718 | 3904 |
| 3719 // Generate an unrolled loop that performs a few probes before | 3905 // Generate an unrolled loop that performs a few probes before |
| 3720 // giving up. Measurements done on Gmail indicate that 2 probes | 3906 // giving up. Measurements done on Gmail indicate that 2 probes |
| 3721 // cover ~93% of loads from dictionaries. | 3907 // cover ~93% of loads from dictionaries. |
| 3722 for (int i = 0; i < kInlinedProbes; i++) { | 3908 for (int i = 0; i < kInlinedProbes; i++) { |
| 3723 // Compute the masked index: (hash + i + i * i) & mask. | 3909 // Compute the masked index: (hash + i + i * i) & mask. |
| 3724 __ ldr(scratch2, FieldMemOperand(name, Name::kHashFieldOffset)); | 3910 __ lwz(scratch2, FieldMemOperand(name, Name::kHashFieldOffset)); |
| 3725 if (i > 0) { | 3911 if (i > 0) { |
| 3726 // Add the probe offset (i + i * i) left shifted to avoid right shifting | 3912 // Add the probe offset (i + i * i) left shifted to avoid right shifting |
| 3727 // the hash in a separate instruction. The value hash + i + i * i is right | 3913 // the hash in a separate instruction. The value hash + i + i * i is right |
| 3728 // shifted in the following and instruction. | 3914 // shifted in the following and instruction. |
| 3729 DCHECK(NameDictionary::GetProbeOffset(i) < | 3915 DCHECK(NameDictionary::GetProbeOffset(i) < |
| 3730 1 << (32 - Name::kHashFieldOffset)); | 3916 1 << (32 - Name::kHashFieldOffset)); |
| 3731 __ add(scratch2, scratch2, Operand( | 3917 __ addi(scratch2, scratch2, |
| 3732 NameDictionary::GetProbeOffset(i) << Name::kHashShift)); | 3918 Operand(NameDictionary::GetProbeOffset(i) << Name::kHashShift)); |
| 3733 } | 3919 } |
| 3734 __ and_(scratch2, scratch1, Operand(scratch2, LSR, Name::kHashShift)); | 3920 __ srwi(scratch2, scratch2, Operand(Name::kHashShift)); |
| 3921 __ and_(scratch2, scratch1, scratch2); |
| 3735 | 3922 |
| 3736 // Scale the index by multiplying by the element size. | 3923 // Scale the index by multiplying by the element size. |
| 3737 DCHECK(NameDictionary::kEntrySize == 3); | 3924 DCHECK(NameDictionary::kEntrySize == 3); |
| 3738 // scratch2 = scratch2 * 3. | 3925 // scratch2 = scratch2 * 3. |
| 3739 __ add(scratch2, scratch2, Operand(scratch2, LSL, 1)); | 3926 __ ShiftLeftImm(ip, scratch2, Operand(1)); |
| 3927 __ add(scratch2, scratch2, ip); |
| 3740 | 3928 |
| 3741 // Check if the key is identical to the name. | 3929 // Check if the key is identical to the name. |
| 3742 __ add(scratch2, elements, Operand(scratch2, LSL, 2)); | 3930 __ ShiftLeftImm(ip, scratch2, Operand(kPointerSizeLog2)); |
| 3743 __ ldr(ip, FieldMemOperand(scratch2, kElementsStartOffset)); | 3931 __ add(scratch2, elements, ip); |
| 3744 __ cmp(name, Operand(ip)); | 3932 __ LoadP(ip, FieldMemOperand(scratch2, kElementsStartOffset)); |
| 3745 __ b(eq, done); | 3933 __ cmp(name, ip); |
| 3934 __ beq(done); |
| 3746 } | 3935 } |
| 3747 | 3936 |
| 3748 const int spill_mask = | 3937 const int spill_mask = (r0.bit() | r9.bit() | r8.bit() | r7.bit() | r6.bit() | |
| 3749 (lr.bit() | r6.bit() | r5.bit() | r4.bit() | | 3938 r5.bit() | r4.bit() | r3.bit()) & |
| 3750 r3.bit() | r2.bit() | r1.bit() | r0.bit()) & | 3939 ~(scratch1.bit() | scratch2.bit()); |
| 3751 ~(scratch1.bit() | scratch2.bit()); | |
| 3752 | 3940 |
| 3753 __ stm(db_w, sp, spill_mask); | 3941 __ mflr(r0); |
| 3754 if (name.is(r0)) { | 3942 __ MultiPush(spill_mask); |
| 3755 DCHECK(!elements.is(r1)); | 3943 if (name.is(r3)) { |
| 3756 __ Move(r1, name); | 3944 DCHECK(!elements.is(r4)); |
| 3757 __ Move(r0, elements); | 3945 __ mr(r4, name); |
| 3946 __ mr(r3, elements); |
| 3758 } else { | 3947 } else { |
| 3759 __ Move(r0, elements); | 3948 __ mr(r3, elements); |
| 3760 __ Move(r1, name); | 3949 __ mr(r4, name); |
| 3761 } | 3950 } |
| 3762 NameDictionaryLookupStub stub(masm->isolate(), POSITIVE_LOOKUP); | 3951 NameDictionaryLookupStub stub(masm->isolate(), POSITIVE_LOOKUP); |
| 3763 __ CallStub(&stub); | 3952 __ CallStub(&stub); |
| 3764 __ cmp(r0, Operand::Zero()); | 3953 __ cmpi(r3, Operand::Zero()); |
| 3765 __ mov(scratch2, Operand(r2)); | 3954 __ mr(scratch2, r5); |
| 3766 __ ldm(ia_w, sp, spill_mask); | 3955 __ MultiPop(spill_mask); |
| 3956 __ mtlr(r0); |
| 3767 | 3957 |
| 3768 __ b(ne, done); | 3958 __ bne(done); |
| 3769 __ b(eq, miss); | 3959 __ beq(miss); |
| 3770 } | 3960 } |
| 3771 | 3961 |
| 3772 | 3962 |
| 3773 void NameDictionaryLookupStub::Generate(MacroAssembler* masm) { | 3963 void NameDictionaryLookupStub::Generate(MacroAssembler* masm) { |
| 3774 // This stub overrides SometimesSetsUpAFrame() to return false. That means | 3964 // This stub overrides SometimesSetsUpAFrame() to return false. That means |
| 3775 // we cannot call anything that could cause a GC from this stub. | 3965 // we cannot call anything that could cause a GC from this stub. |
| 3776 // Registers: | 3966 // Registers: |
| 3777 // result: NameDictionary to probe | 3967 // result: NameDictionary to probe |
| 3778 // r1: key | 3968 // r4: key |
| 3779 // dictionary: NameDictionary to probe. | 3969 // dictionary: NameDictionary to probe. |
| 3780 // index: will hold an index of entry if lookup is successful. | 3970 // index: will hold an index of entry if lookup is successful. |
| 3781 // might alias with result_. | 3971 // might alias with result_. |
| 3782 // Returns: | 3972 // Returns: |
| 3783 // result_ is zero if lookup failed, non zero otherwise. | 3973 // result_ is zero if lookup failed, non zero otherwise. |
| 3784 | 3974 |
| 3785 Register result = r0; | 3975 Register result = r3; |
| 3786 Register dictionary = r0; | 3976 Register dictionary = r3; |
| 3787 Register key = r1; | 3977 Register key = r4; |
| 3788 Register index = r2; | 3978 Register index = r5; |
| 3789 Register mask = r3; | 3979 Register mask = r6; |
| 3790 Register hash = r4; | 3980 Register hash = r7; |
| 3791 Register undefined = r5; | 3981 Register undefined = r8; |
| 3792 Register entry_key = r6; | 3982 Register entry_key = r9; |
| 3983 Register scratch = r9; |
| 3793 | 3984 |
| 3794 Label in_dictionary, maybe_in_dictionary, not_in_dictionary; | 3985 Label in_dictionary, maybe_in_dictionary, not_in_dictionary; |
| 3795 | 3986 |
| 3796 __ ldr(mask, FieldMemOperand(dictionary, kCapacityOffset)); | 3987 __ LoadP(mask, FieldMemOperand(dictionary, kCapacityOffset)); |
| 3797 __ SmiUntag(mask); | 3988 __ SmiUntag(mask); |
| 3798 __ sub(mask, mask, Operand(1)); | 3989 __ subi(mask, mask, Operand(1)); |
| 3799 | 3990 |
| 3800 __ ldr(hash, FieldMemOperand(key, Name::kHashFieldOffset)); | 3991 __ lwz(hash, FieldMemOperand(key, Name::kHashFieldOffset)); |
| 3801 | 3992 |
| 3802 __ LoadRoot(undefined, Heap::kUndefinedValueRootIndex); | 3993 __ LoadRoot(undefined, Heap::kUndefinedValueRootIndex); |
| 3803 | 3994 |
| 3804 for (int i = kInlinedProbes; i < kTotalProbes; i++) { | 3995 for (int i = kInlinedProbes; i < kTotalProbes; i++) { |
| 3805 // Compute the masked index: (hash + i + i * i) & mask. | 3996 // Compute the masked index: (hash + i + i * i) & mask. |
| 3806 // Capacity is smi 2^n. | 3997 // Capacity is smi 2^n. |
| 3807 if (i > 0) { | 3998 if (i > 0) { |
| 3808 // Add the probe offset (i + i * i) left shifted to avoid right shifting | 3999 // Add the probe offset (i + i * i) left shifted to avoid right shifting |
| 3809 // the hash in a separate instruction. The value hash + i + i * i is right | 4000 // the hash in a separate instruction. The value hash + i + i * i is right |
| 3810 // shifted in the following and instruction. | 4001 // shifted in the following and instruction. |
| 3811 DCHECK(NameDictionary::GetProbeOffset(i) < | 4002 DCHECK(NameDictionary::GetProbeOffset(i) < |
| 3812 1 << (32 - Name::kHashFieldOffset)); | 4003 1 << (32 - Name::kHashFieldOffset)); |
| 3813 __ add(index, hash, Operand( | 4004 __ addi(index, hash, |
| 3814 NameDictionary::GetProbeOffset(i) << Name::kHashShift)); | 4005 Operand(NameDictionary::GetProbeOffset(i) << Name::kHashShift)); |
| 3815 } else { | 4006 } else { |
| 3816 __ mov(index, Operand(hash)); | 4007 __ mr(index, hash); |
| 3817 } | 4008 } |
| 3818 __ and_(index, mask, Operand(index, LSR, Name::kHashShift)); | 4009 __ srwi(r0, index, Operand(Name::kHashShift)); |
| 4010 __ and_(index, mask, r0); |
| 3819 | 4011 |
| 3820 // Scale the index by multiplying by the entry size. | 4012 // Scale the index by multiplying by the entry size. |
| 3821 DCHECK(NameDictionary::kEntrySize == 3); | 4013 DCHECK(NameDictionary::kEntrySize == 3); |
| 3822 __ add(index, index, Operand(index, LSL, 1)); // index *= 3. | 4014 __ ShiftLeftImm(scratch, index, Operand(1)); |
| 4015 __ add(index, index, scratch); // index *= 3. |
| 3823 | 4016 |
| 3824 DCHECK_EQ(kSmiTagSize, 1); | 4017 DCHECK_EQ(kSmiTagSize, 1); |
| 3825 __ add(index, dictionary, Operand(index, LSL, 2)); | 4018 __ ShiftLeftImm(scratch, index, Operand(kPointerSizeLog2)); |
| 3826 __ ldr(entry_key, FieldMemOperand(index, kElementsStartOffset)); | 4019 __ add(index, dictionary, scratch); |
| 4020 __ LoadP(entry_key, FieldMemOperand(index, kElementsStartOffset)); |
| 3827 | 4021 |
| 3828 // Having undefined at this place means the name is not contained. | 4022 // Having undefined at this place means the name is not contained. |
| 3829 __ cmp(entry_key, Operand(undefined)); | 4023 __ cmp(entry_key, undefined); |
| 3830 __ b(eq, ¬_in_dictionary); | 4024 __ beq(¬_in_dictionary); |
| 3831 | 4025 |
| 3832 // Stop if found the property. | 4026 // Stop if found the property. |
| 3833 __ cmp(entry_key, Operand(key)); | 4027 __ cmp(entry_key, key); |
| 3834 __ b(eq, &in_dictionary); | 4028 __ beq(&in_dictionary); |
| 3835 | 4029 |
| 3836 if (i != kTotalProbes - 1 && mode() == NEGATIVE_LOOKUP) { | 4030 if (i != kTotalProbes - 1 && mode() == NEGATIVE_LOOKUP) { |
| 3837 // Check if the entry name is not a unique name. | 4031 // Check if the entry name is not a unique name. |
| 3838 __ ldr(entry_key, FieldMemOperand(entry_key, HeapObject::kMapOffset)); | 4032 __ LoadP(entry_key, FieldMemOperand(entry_key, HeapObject::kMapOffset)); |
| 3839 __ ldrb(entry_key, | 4033 __ lbz(entry_key, FieldMemOperand(entry_key, Map::kInstanceTypeOffset)); |
| 3840 FieldMemOperand(entry_key, Map::kInstanceTypeOffset)); | |
| 3841 __ JumpIfNotUniqueName(entry_key, &maybe_in_dictionary); | 4034 __ JumpIfNotUniqueName(entry_key, &maybe_in_dictionary); |
| 3842 } | 4035 } |
| 3843 } | 4036 } |
| 3844 | 4037 |
| 3845 __ bind(&maybe_in_dictionary); | 4038 __ bind(&maybe_in_dictionary); |
| 3846 // If we are doing negative lookup then probing failure should be | 4039 // If we are doing negative lookup then probing failure should be |
| 3847 // treated as a lookup success. For positive lookup probing failure | 4040 // treated as a lookup success. For positive lookup probing failure |
| 3848 // should be treated as lookup failure. | 4041 // should be treated as lookup failure. |
| 3849 if (mode() == POSITIVE_LOOKUP) { | 4042 if (mode() == POSITIVE_LOOKUP) { |
| 3850 __ mov(result, Operand::Zero()); | 4043 __ li(result, Operand::Zero()); |
| 3851 __ Ret(); | 4044 __ Ret(); |
| 3852 } | 4045 } |
| 3853 | 4046 |
| 3854 __ bind(&in_dictionary); | 4047 __ bind(&in_dictionary); |
| 3855 __ mov(result, Operand(1)); | 4048 __ li(result, Operand(1)); |
| 3856 __ Ret(); | 4049 __ Ret(); |
| 3857 | 4050 |
| 3858 __ bind(¬_in_dictionary); | 4051 __ bind(¬_in_dictionary); |
| 3859 __ mov(result, Operand::Zero()); | 4052 __ li(result, Operand::Zero()); |
| 3860 __ Ret(); | 4053 __ Ret(); |
| 3861 } | 4054 } |
| 3862 | 4055 |
| 3863 | 4056 |
| 3864 void StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime( | 4057 void StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime( |
| 3865 Isolate* isolate) { | 4058 Isolate* isolate) { |
| 3866 StoreBufferOverflowStub stub1(isolate, kDontSaveFPRegs); | 4059 StoreBufferOverflowStub stub1(isolate, kDontSaveFPRegs); |
| 3867 stub1.GetCode(); | 4060 stub1.GetCode(); |
| 3868 // Hydrogen code stubs need stub2 at snapshot time. | 4061 // Hydrogen code stubs need stub2 at snapshot time. |
| 3869 StoreBufferOverflowStub stub2(isolate, kSaveFPRegs); | 4062 StoreBufferOverflowStub stub2(isolate, kSaveFPRegs); |
| 3870 stub2.GetCode(); | 4063 stub2.GetCode(); |
| 3871 } | 4064 } |
| 3872 | 4065 |
| 3873 | 4066 |
| 3874 // Takes the input in 3 registers: address_ value_ and object_. A pointer to | 4067 // Takes the input in 3 registers: address_ value_ and object_. A pointer to |
| 3875 // the value has just been written into the object, now this stub makes sure | 4068 // the value has just been written into the object, now this stub makes sure |
| 3876 // we keep the GC informed. The word in the object where the value has been | 4069 // we keep the GC informed. The word in the object where the value has been |
| 3877 // written is in the address register. | 4070 // written is in the address register. |
| 3878 void RecordWriteStub::Generate(MacroAssembler* masm) { | 4071 void RecordWriteStub::Generate(MacroAssembler* masm) { |
| 3879 Label skip_to_incremental_noncompacting; | 4072 Label skip_to_incremental_noncompacting; |
| 3880 Label skip_to_incremental_compacting; | 4073 Label skip_to_incremental_compacting; |
| 3881 | 4074 |
| 3882 // The first two instructions are generated with labels so as to get the | 4075 // The first two branch instructions are generated with labels so as to |
| 3883 // offset fixed up correctly by the bind(Label*) call. We patch it back and | 4076 // get the offset fixed up correctly by the bind(Label*) call. We patch |
| 3884 // forth between a compare instructions (a nop in this position) and the | 4077 // it back and forth between branch condition True and False |
| 3885 // real branch when we start and stop incremental heap marking. | 4078 // when we start and stop incremental heap marking. |
| 3886 // See RecordWriteStub::Patch for details. | 4079 // See RecordWriteStub::Patch for details. |
| 3887 { | 4080 |
| 3888 // Block literal pool emission, as the position of these two instructions | 4081 // Clear the bit, branch on True for NOP action initially |
| 3889 // is assumed by the patching code. | 4082 __ crclr(Assembler::encode_crbit(cr2, CR_LT)); |
| 3890 Assembler::BlockConstPoolScope block_const_pool(masm); | 4083 __ blt(&skip_to_incremental_noncompacting, cr2); |
| 3891 __ b(&skip_to_incremental_noncompacting); | 4084 __ blt(&skip_to_incremental_compacting, cr2); |
| 3892 __ b(&skip_to_incremental_compacting); | |
| 3893 } | |
| 3894 | 4085 |
| 3895 if (remembered_set_action() == EMIT_REMEMBERED_SET) { | 4086 if (remembered_set_action() == EMIT_REMEMBERED_SET) { |
| 3896 __ RememberedSetHelper(object(), address(), value(), save_fp_regs_mode(), | 4087 __ RememberedSetHelper(object(), address(), value(), save_fp_regs_mode(), |
| 3897 MacroAssembler::kReturnAtEnd); | 4088 MacroAssembler::kReturnAtEnd); |
| 3898 } | 4089 } |
| 3899 __ Ret(); | 4090 __ Ret(); |
| 3900 | 4091 |
| 3901 __ bind(&skip_to_incremental_noncompacting); | 4092 __ bind(&skip_to_incremental_noncompacting); |
| 3902 GenerateIncremental(masm, INCREMENTAL); | 4093 GenerateIncremental(masm, INCREMENTAL); |
| 3903 | 4094 |
| 3904 __ bind(&skip_to_incremental_compacting); | 4095 __ bind(&skip_to_incremental_compacting); |
| 3905 GenerateIncremental(masm, INCREMENTAL_COMPACTION); | 4096 GenerateIncremental(masm, INCREMENTAL_COMPACTION); |
| 3906 | 4097 |
| 3907 // Initial mode of the stub is expected to be STORE_BUFFER_ONLY. | 4098 // Initial mode of the stub is expected to be STORE_BUFFER_ONLY. |
| 3908 // Will be checked in IncrementalMarking::ActivateGeneratedStub. | 4099 // Will be checked in IncrementalMarking::ActivateGeneratedStub. |
| 3909 DCHECK(Assembler::GetBranchOffset(masm->instr_at(0)) < (1 << 12)); | 4100 // patching not required on PPC as the initial path is effectively NOP |
| 3910 DCHECK(Assembler::GetBranchOffset(masm->instr_at(4)) < (1 << 12)); | |
| 3911 PatchBranchIntoNop(masm, 0); | |
| 3912 PatchBranchIntoNop(masm, Assembler::kInstrSize); | |
| 3913 } | 4101 } |
| 3914 | 4102 |
| 3915 | 4103 |
| 3916 void RecordWriteStub::GenerateIncremental(MacroAssembler* masm, Mode mode) { | 4104 void RecordWriteStub::GenerateIncremental(MacroAssembler* masm, Mode mode) { |
| 3917 regs_.Save(masm); | 4105 regs_.Save(masm); |
| 3918 | 4106 |
| 3919 if (remembered_set_action() == EMIT_REMEMBERED_SET) { | 4107 if (remembered_set_action() == EMIT_REMEMBERED_SET) { |
| 3920 Label dont_need_remembered_set; | 4108 Label dont_need_remembered_set; |
| 3921 | 4109 |
| 3922 __ ldr(regs_.scratch0(), MemOperand(regs_.address(), 0)); | 4110 __ LoadP(regs_.scratch0(), MemOperand(regs_.address(), 0)); |
| 3923 __ JumpIfNotInNewSpace(regs_.scratch0(), // Value. | 4111 __ JumpIfNotInNewSpace(regs_.scratch0(), // Value. |
| 3924 regs_.scratch0(), | 4112 regs_.scratch0(), &dont_need_remembered_set); |
| 3925 &dont_need_remembered_set); | |
| 3926 | 4113 |
| 3927 __ CheckPageFlag(regs_.object(), | 4114 __ CheckPageFlag(regs_.object(), regs_.scratch0(), |
| 3928 regs_.scratch0(), | 4115 1 << MemoryChunk::SCAN_ON_SCAVENGE, ne, |
| 3929 1 << MemoryChunk::SCAN_ON_SCAVENGE, | |
| 3930 ne, | |
| 3931 &dont_need_remembered_set); | 4116 &dont_need_remembered_set); |
| 3932 | 4117 |
| 3933 // First notify the incremental marker if necessary, then update the | 4118 // First notify the incremental marker if necessary, then update the |
| 3934 // remembered set. | 4119 // remembered set. |
| 3935 CheckNeedsToInformIncrementalMarker( | 4120 CheckNeedsToInformIncrementalMarker( |
| 3936 masm, kUpdateRememberedSetOnNoNeedToInformIncrementalMarker, mode); | 4121 masm, kUpdateRememberedSetOnNoNeedToInformIncrementalMarker, mode); |
| 3937 InformIncrementalMarker(masm); | 4122 InformIncrementalMarker(masm); |
| 3938 regs_.Restore(masm); | 4123 regs_.Restore(masm); |
| 3939 __ RememberedSetHelper(object(), address(), value(), save_fp_regs_mode(), | 4124 __ RememberedSetHelper(object(), address(), value(), save_fp_regs_mode(), |
| 3940 MacroAssembler::kReturnAtEnd); | 4125 MacroAssembler::kReturnAtEnd); |
| 3941 | 4126 |
| 3942 __ bind(&dont_need_remembered_set); | 4127 __ bind(&dont_need_remembered_set); |
| 3943 } | 4128 } |
| 3944 | 4129 |
| 3945 CheckNeedsToInformIncrementalMarker( | 4130 CheckNeedsToInformIncrementalMarker( |
| 3946 masm, kReturnOnNoNeedToInformIncrementalMarker, mode); | 4131 masm, kReturnOnNoNeedToInformIncrementalMarker, mode); |
| 3947 InformIncrementalMarker(masm); | 4132 InformIncrementalMarker(masm); |
| 3948 regs_.Restore(masm); | 4133 regs_.Restore(masm); |
| 3949 __ Ret(); | 4134 __ Ret(); |
| 3950 } | 4135 } |
| 3951 | 4136 |
| 3952 | 4137 |
| 3953 void RecordWriteStub::InformIncrementalMarker(MacroAssembler* masm) { | 4138 void RecordWriteStub::InformIncrementalMarker(MacroAssembler* masm) { |
| 3954 regs_.SaveCallerSaveRegisters(masm, save_fp_regs_mode()); | 4139 regs_.SaveCallerSaveRegisters(masm, save_fp_regs_mode()); |
| 3955 int argument_count = 3; | 4140 int argument_count = 3; |
| 3956 __ PrepareCallCFunction(argument_count, regs_.scratch0()); | 4141 __ PrepareCallCFunction(argument_count, regs_.scratch0()); |
| 3957 Register address = | 4142 Register address = |
| 3958 r0.is(regs_.address()) ? regs_.scratch0() : regs_.address(); | 4143 r3.is(regs_.address()) ? regs_.scratch0() : regs_.address(); |
| 3959 DCHECK(!address.is(regs_.object())); | 4144 DCHECK(!address.is(regs_.object())); |
| 3960 DCHECK(!address.is(r0)); | 4145 DCHECK(!address.is(r3)); |
| 3961 __ Move(address, regs_.address()); | 4146 __ mr(address, regs_.address()); |
| 3962 __ Move(r0, regs_.object()); | 4147 __ mr(r3, regs_.object()); |
| 3963 __ Move(r1, address); | 4148 __ mr(r4, address); |
| 3964 __ mov(r2, Operand(ExternalReference::isolate_address(isolate()))); | 4149 __ mov(r5, Operand(ExternalReference::isolate_address(isolate()))); |
| 3965 | 4150 |
| 3966 AllowExternalCallThatCantCauseGC scope(masm); | 4151 AllowExternalCallThatCantCauseGC scope(masm); |
| 3967 __ CallCFunction( | 4152 __ CallCFunction( |
| 3968 ExternalReference::incremental_marking_record_write_function(isolate()), | 4153 ExternalReference::incremental_marking_record_write_function(isolate()), |
| 3969 argument_count); | 4154 argument_count); |
| 3970 regs_.RestoreCallerSaveRegisters(masm, save_fp_regs_mode()); | 4155 regs_.RestoreCallerSaveRegisters(masm, save_fp_regs_mode()); |
| 3971 } | 4156 } |
| 3972 | 4157 |
| 3973 | 4158 |
| 3974 void RecordWriteStub::CheckNeedsToInformIncrementalMarker( | 4159 void RecordWriteStub::CheckNeedsToInformIncrementalMarker( |
| 3975 MacroAssembler* masm, | 4160 MacroAssembler* masm, OnNoNeedToInformIncrementalMarker on_no_need, |
| 3976 OnNoNeedToInformIncrementalMarker on_no_need, | |
| 3977 Mode mode) { | 4161 Mode mode) { |
| 3978 Label on_black; | 4162 Label on_black; |
| 3979 Label need_incremental; | 4163 Label need_incremental; |
| 3980 Label need_incremental_pop_scratch; | 4164 Label need_incremental_pop_scratch; |
| 3981 | 4165 |
| 3982 __ and_(regs_.scratch0(), regs_.object(), Operand(~Page::kPageAlignmentMask)); | 4166 DCHECK((~Page::kPageAlignmentMask & 0xffff) == 0); |
| 3983 __ ldr(regs_.scratch1(), | 4167 __ lis(r0, Operand((~Page::kPageAlignmentMask >> 16))); |
| 3984 MemOperand(regs_.scratch0(), | 4168 __ and_(regs_.scratch0(), regs_.object(), r0); |
| 3985 MemoryChunk::kWriteBarrierCounterOffset)); | 4169 __ LoadP( |
| 3986 __ sub(regs_.scratch1(), regs_.scratch1(), Operand(1), SetCC); | 4170 regs_.scratch1(), |
| 3987 __ str(regs_.scratch1(), | 4171 MemOperand(regs_.scratch0(), MemoryChunk::kWriteBarrierCounterOffset)); |
| 3988 MemOperand(regs_.scratch0(), | 4172 __ subi(regs_.scratch1(), regs_.scratch1(), Operand(1)); |
| 3989 MemoryChunk::kWriteBarrierCounterOffset)); | 4173 __ StoreP( |
| 3990 __ b(mi, &need_incremental); | 4174 regs_.scratch1(), |
| 4175 MemOperand(regs_.scratch0(), MemoryChunk::kWriteBarrierCounterOffset)); |
| 4176 __ cmpi(regs_.scratch1(), Operand::Zero()); // PPC, we could do better here |
| 4177 __ blt(&need_incremental); |
| 3991 | 4178 |
| 3992 // Let's look at the color of the object: If it is not black we don't have | 4179 // Let's look at the color of the object: If it is not black we don't have |
| 3993 // to inform the incremental marker. | 4180 // to inform the incremental marker. |
| 3994 __ JumpIfBlack(regs_.object(), regs_.scratch0(), regs_.scratch1(), &on_black); | 4181 __ JumpIfBlack(regs_.object(), regs_.scratch0(), regs_.scratch1(), &on_black); |
| 3995 | 4182 |
| 3996 regs_.Restore(masm); | 4183 regs_.Restore(masm); |
| 3997 if (on_no_need == kUpdateRememberedSetOnNoNeedToInformIncrementalMarker) { | 4184 if (on_no_need == kUpdateRememberedSetOnNoNeedToInformIncrementalMarker) { |
| 3998 __ RememberedSetHelper(object(), address(), value(), save_fp_regs_mode(), | 4185 __ RememberedSetHelper(object(), address(), value(), save_fp_regs_mode(), |
| 3999 MacroAssembler::kReturnAtEnd); | 4186 MacroAssembler::kReturnAtEnd); |
| 4000 } else { | 4187 } else { |
| 4001 __ Ret(); | 4188 __ Ret(); |
| 4002 } | 4189 } |
| 4003 | 4190 |
| 4004 __ bind(&on_black); | 4191 __ bind(&on_black); |
| 4005 | 4192 |
| 4006 // Get the value from the slot. | 4193 // Get the value from the slot. |
| 4007 __ ldr(regs_.scratch0(), MemOperand(regs_.address(), 0)); | 4194 __ LoadP(regs_.scratch0(), MemOperand(regs_.address(), 0)); |
| 4008 | 4195 |
| 4009 if (mode == INCREMENTAL_COMPACTION) { | 4196 if (mode == INCREMENTAL_COMPACTION) { |
| 4010 Label ensure_not_white; | 4197 Label ensure_not_white; |
| 4011 | 4198 |
| 4012 __ CheckPageFlag(regs_.scratch0(), // Contains value. | 4199 __ CheckPageFlag(regs_.scratch0(), // Contains value. |
| 4013 regs_.scratch1(), // Scratch. | 4200 regs_.scratch1(), // Scratch. |
| 4014 MemoryChunk::kEvacuationCandidateMask, | 4201 MemoryChunk::kEvacuationCandidateMask, eq, |
| 4015 eq, | |
| 4016 &ensure_not_white); | 4202 &ensure_not_white); |
| 4017 | 4203 |
| 4018 __ CheckPageFlag(regs_.object(), | 4204 __ CheckPageFlag(regs_.object(), |
| 4019 regs_.scratch1(), // Scratch. | 4205 regs_.scratch1(), // Scratch. |
| 4020 MemoryChunk::kSkipEvacuationSlotsRecordingMask, | 4206 MemoryChunk::kSkipEvacuationSlotsRecordingMask, eq, |
| 4021 eq, | |
| 4022 &need_incremental); | 4207 &need_incremental); |
| 4023 | 4208 |
| 4024 __ bind(&ensure_not_white); | 4209 __ bind(&ensure_not_white); |
| 4025 } | 4210 } |
| 4026 | 4211 |
| 4027 // We need extra registers for this, so we push the object and the address | 4212 // We need extra registers for this, so we push the object and the address |
| 4028 // register temporarily. | 4213 // register temporarily. |
| 4029 __ Push(regs_.object(), regs_.address()); | 4214 __ Push(regs_.object(), regs_.address()); |
| 4030 __ EnsureNotWhite(regs_.scratch0(), // The value. | 4215 __ EnsureNotWhite(regs_.scratch0(), // The value. |
| 4031 regs_.scratch1(), // Scratch. | 4216 regs_.scratch1(), // Scratch. |
| 4032 regs_.object(), // Scratch. | 4217 regs_.object(), // Scratch. |
| 4033 regs_.address(), // Scratch. | 4218 regs_.address(), // Scratch. |
| 4034 &need_incremental_pop_scratch); | 4219 &need_incremental_pop_scratch); |
| 4035 __ Pop(regs_.object(), regs_.address()); | 4220 __ Pop(regs_.object(), regs_.address()); |
| 4036 | 4221 |
| 4037 regs_.Restore(masm); | 4222 regs_.Restore(masm); |
| 4038 if (on_no_need == kUpdateRememberedSetOnNoNeedToInformIncrementalMarker) { | 4223 if (on_no_need == kUpdateRememberedSetOnNoNeedToInformIncrementalMarker) { |
| 4039 __ RememberedSetHelper(object(), address(), value(), save_fp_regs_mode(), | 4224 __ RememberedSetHelper(object(), address(), value(), save_fp_regs_mode(), |
| 4040 MacroAssembler::kReturnAtEnd); | 4225 MacroAssembler::kReturnAtEnd); |
| 4041 } else { | 4226 } else { |
| 4042 __ Ret(); | 4227 __ Ret(); |
| 4043 } | 4228 } |
| 4044 | 4229 |
| 4045 __ bind(&need_incremental_pop_scratch); | 4230 __ bind(&need_incremental_pop_scratch); |
| 4046 __ Pop(regs_.object(), regs_.address()); | 4231 __ Pop(regs_.object(), regs_.address()); |
| 4047 | 4232 |
| 4048 __ bind(&need_incremental); | 4233 __ bind(&need_incremental); |
| 4049 | 4234 |
| 4050 // Fall through when we need to inform the incremental marker. | 4235 // Fall through when we need to inform the incremental marker. |
| 4051 } | 4236 } |
| 4052 | 4237 |
| 4053 | 4238 |
| 4054 void StoreArrayLiteralElementStub::Generate(MacroAssembler* masm) { | 4239 void StoreArrayLiteralElementStub::Generate(MacroAssembler* masm) { |
| 4055 // ----------- S t a t e ------------- | 4240 // ----------- S t a t e ------------- |
| 4056 // -- r0 : element value to store | 4241 // -- r3 : element value to store |
| 4057 // -- r3 : element index as smi | 4242 // -- r6 : element index as smi |
| 4058 // -- sp[0] : array literal index in function as smi | 4243 // -- sp[0] : array literal index in function as smi |
| 4059 // -- sp[4] : array literal | 4244 // -- sp[4] : array literal |
| 4060 // clobbers r1, r2, r4 | 4245 // clobbers r3, r5, r7 |
| 4061 // ----------------------------------- | 4246 // ----------------------------------- |
| 4062 | 4247 |
| 4063 Label element_done; | 4248 Label element_done; |
| 4064 Label double_elements; | 4249 Label double_elements; |
| 4065 Label smi_element; | 4250 Label smi_element; |
| 4066 Label slow_elements; | 4251 Label slow_elements; |
| 4067 Label fast_elements; | 4252 Label fast_elements; |
| 4068 | 4253 |
| 4069 // Get array literal index, array literal and its map. | 4254 // Get array literal index, array literal and its map. |
| 4070 __ ldr(r4, MemOperand(sp, 0 * kPointerSize)); | 4255 __ LoadP(r7, MemOperand(sp, 0 * kPointerSize)); |
| 4071 __ ldr(r1, MemOperand(sp, 1 * kPointerSize)); | 4256 __ LoadP(r4, MemOperand(sp, 1 * kPointerSize)); |
| 4072 __ ldr(r2, FieldMemOperand(r1, JSObject::kMapOffset)); | 4257 __ LoadP(r5, FieldMemOperand(r4, JSObject::kMapOffset)); |
| 4073 | 4258 |
| 4074 __ CheckFastElements(r2, r5, &double_elements); | 4259 __ CheckFastElements(r5, r8, &double_elements); |
| 4075 // FAST_*_SMI_ELEMENTS or FAST_*_ELEMENTS | 4260 // FAST_*_SMI_ELEMENTS or FAST_*_ELEMENTS |
| 4076 __ JumpIfSmi(r0, &smi_element); | 4261 __ JumpIfSmi(r3, &smi_element); |
| 4077 __ CheckFastSmiElements(r2, r5, &fast_elements); | 4262 __ CheckFastSmiElements(r5, r8, &fast_elements); |
| 4078 | 4263 |
| 4079 // Store into the array literal requires a elements transition. Call into | 4264 // Store into the array literal requires a elements transition. Call into |
| 4080 // the runtime. | 4265 // the runtime. |
| 4081 __ bind(&slow_elements); | 4266 __ bind(&slow_elements); |
| 4082 // call. | 4267 // call. |
| 4083 __ Push(r1, r3, r0); | 4268 __ Push(r4, r6, r3); |
| 4084 __ ldr(r5, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 4269 __ LoadP(r8, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 4085 __ ldr(r5, FieldMemOperand(r5, JSFunction::kLiteralsOffset)); | 4270 __ LoadP(r8, FieldMemOperand(r8, JSFunction::kLiteralsOffset)); |
| 4086 __ Push(r5, r4); | 4271 __ Push(r8, r7); |
| 4087 __ TailCallRuntime(Runtime::kStoreArrayLiteralElement, 5, 1); | 4272 __ TailCallRuntime(Runtime::kStoreArrayLiteralElement, 5, 1); |
| 4088 | 4273 |
| 4089 // Array literal has ElementsKind of FAST_*_ELEMENTS and value is an object. | 4274 // Array literal has ElementsKind of FAST_*_ELEMENTS and value is an object. |
| 4090 __ bind(&fast_elements); | 4275 __ bind(&fast_elements); |
| 4091 __ ldr(r5, FieldMemOperand(r1, JSObject::kElementsOffset)); | 4276 __ LoadP(r8, FieldMemOperand(r4, JSObject::kElementsOffset)); |
| 4092 __ add(r6, r5, Operand::PointerOffsetFromSmiKey(r3)); | 4277 __ SmiToPtrArrayOffset(r9, r6); |
| 4093 __ add(r6, r6, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | 4278 __ add(r9, r8, r9); |
| 4094 __ str(r0, MemOperand(r6, 0)); | 4279 #if V8_TARGET_ARCH_PPC64 |
| 4280 // add due to offset alignment requirements of StorePU |
| 4281 __ addi(r9, r9, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
| 4282 __ StoreP(r3, MemOperand(r9)); |
| 4283 #else |
| 4284 __ StorePU(r3, MemOperand(r9, FixedArray::kHeaderSize - kHeapObjectTag)); |
| 4285 #endif |
| 4095 // Update the write barrier for the array store. | 4286 // Update the write barrier for the array store. |
| 4096 __ RecordWrite(r5, r6, r0, kLRHasNotBeenSaved, kDontSaveFPRegs, | 4287 __ RecordWrite(r8, r9, r3, kLRHasNotBeenSaved, kDontSaveFPRegs, |
| 4097 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); | 4288 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); |
| 4098 __ Ret(); | 4289 __ Ret(); |
| 4099 | 4290 |
| 4100 // Array literal has ElementsKind of FAST_*_SMI_ELEMENTS or FAST_*_ELEMENTS, | 4291 // Array literal has ElementsKind of FAST_*_SMI_ELEMENTS or FAST_*_ELEMENTS, |
| 4101 // and value is Smi. | 4292 // and value is Smi. |
| 4102 __ bind(&smi_element); | 4293 __ bind(&smi_element); |
| 4103 __ ldr(r5, FieldMemOperand(r1, JSObject::kElementsOffset)); | 4294 __ LoadP(r8, FieldMemOperand(r4, JSObject::kElementsOffset)); |
| 4104 __ add(r6, r5, Operand::PointerOffsetFromSmiKey(r3)); | 4295 __ SmiToPtrArrayOffset(r9, r6); |
| 4105 __ str(r0, FieldMemOperand(r6, FixedArray::kHeaderSize)); | 4296 __ add(r9, r8, r9); |
| 4297 __ StoreP(r3, FieldMemOperand(r9, FixedArray::kHeaderSize), r0); |
| 4106 __ Ret(); | 4298 __ Ret(); |
| 4107 | 4299 |
| 4108 // Array literal has ElementsKind of FAST_DOUBLE_ELEMENTS. | 4300 // Array literal has ElementsKind of FAST_DOUBLE_ELEMENTS. |
| 4109 __ bind(&double_elements); | 4301 __ bind(&double_elements); |
| 4110 __ ldr(r5, FieldMemOperand(r1, JSObject::kElementsOffset)); | 4302 __ LoadP(r8, FieldMemOperand(r4, JSObject::kElementsOffset)); |
| 4111 __ StoreNumberToDoubleElements(r0, r3, r5, r6, d0, &slow_elements); | 4303 __ StoreNumberToDoubleElements(r3, r6, r8, r9, d0, &slow_elements); |
| 4112 __ Ret(); | 4304 __ Ret(); |
| 4113 } | 4305 } |
| 4114 | 4306 |
| 4115 | 4307 |
| 4116 void StubFailureTrampolineStub::Generate(MacroAssembler* masm) { | 4308 void StubFailureTrampolineStub::Generate(MacroAssembler* masm) { |
| 4117 CEntryStub ces(isolate(), 1, kSaveFPRegs); | 4309 CEntryStub ces(isolate(), 1, kSaveFPRegs); |
| 4118 __ Call(ces.GetCode(), RelocInfo::CODE_TARGET); | 4310 __ Call(ces.GetCode(), RelocInfo::CODE_TARGET); |
| 4119 int parameter_count_offset = | 4311 int parameter_count_offset = |
| 4120 StubFailureTrampolineFrame::kCallerStackParameterCountFrameOffset; | 4312 StubFailureTrampolineFrame::kCallerStackParameterCountFrameOffset; |
| 4121 __ ldr(r1, MemOperand(fp, parameter_count_offset)); | 4313 __ LoadP(r4, MemOperand(fp, parameter_count_offset)); |
| 4122 if (function_mode() == JS_FUNCTION_STUB_MODE) { | 4314 if (function_mode() == JS_FUNCTION_STUB_MODE) { |
| 4123 __ add(r1, r1, Operand(1)); | 4315 __ addi(r4, r4, Operand(1)); |
| 4124 } | 4316 } |
| 4125 masm->LeaveFrame(StackFrame::STUB_FAILURE_TRAMPOLINE); | 4317 masm->LeaveFrame(StackFrame::STUB_FAILURE_TRAMPOLINE); |
| 4126 __ mov(r1, Operand(r1, LSL, kPointerSizeLog2)); | 4318 __ slwi(r4, r4, Operand(kPointerSizeLog2)); |
| 4127 __ add(sp, sp, r1); | 4319 __ add(sp, sp, r4); |
| 4128 __ Ret(); | 4320 __ Ret(); |
| 4129 } | 4321 } |
| 4130 | 4322 |
| 4131 | 4323 |
| 4132 void LoadICTrampolineStub::Generate(MacroAssembler* masm) { | 4324 void LoadICTrampolineStub::Generate(MacroAssembler* masm) { |
| 4133 EmitLoadTypeFeedbackVector(masm, VectorLoadICDescriptor::VectorRegister()); | 4325 EmitLoadTypeFeedbackVector(masm, VectorLoadICDescriptor::VectorRegister()); |
| 4134 VectorLoadStub stub(isolate(), state()); | 4326 VectorLoadStub stub(isolate(), state()); |
| 4135 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); | 4327 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); |
| 4136 } | 4328 } |
| 4137 | 4329 |
| 4138 | 4330 |
| 4139 void KeyedLoadICTrampolineStub::Generate(MacroAssembler* masm) { | 4331 void KeyedLoadICTrampolineStub::Generate(MacroAssembler* masm) { |
| 4140 EmitLoadTypeFeedbackVector(masm, VectorLoadICDescriptor::VectorRegister()); | 4332 EmitLoadTypeFeedbackVector(masm, VectorLoadICDescriptor::VectorRegister()); |
| 4141 VectorKeyedLoadStub stub(isolate()); | 4333 VectorKeyedLoadStub stub(isolate()); |
| 4142 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); | 4334 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); |
| 4143 } | 4335 } |
| 4144 | 4336 |
| 4145 | 4337 |
| 4146 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { | 4338 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { |
| 4147 if (masm->isolate()->function_entry_hook() != NULL) { | 4339 if (masm->isolate()->function_entry_hook() != NULL) { |
| 4340 PredictableCodeSizeScope predictable(masm, |
| 4341 #if V8_TARGET_ARCH_PPC64 |
| 4342 12 * Assembler::kInstrSize); |
| 4343 #else |
| 4344 9 * Assembler::kInstrSize); |
| 4345 #endif |
| 4148 ProfileEntryHookStub stub(masm->isolate()); | 4346 ProfileEntryHookStub stub(masm->isolate()); |
| 4149 int code_size = masm->CallStubSize(&stub) + 2 * Assembler::kInstrSize; | 4347 __ mflr(r0); |
| 4150 PredictableCodeSizeScope predictable(masm, code_size); | 4348 __ push(r0); |
| 4151 __ push(lr); | |
| 4152 __ CallStub(&stub); | 4349 __ CallStub(&stub); |
| 4153 __ pop(lr); | 4350 __ pop(r0); |
| 4351 __ mtlr(r0); |
| 4154 } | 4352 } |
| 4155 } | 4353 } |
| 4156 | 4354 |
| 4157 | 4355 |
| 4158 void ProfileEntryHookStub::Generate(MacroAssembler* masm) { | 4356 void ProfileEntryHookStub::Generate(MacroAssembler* masm) { |
| 4159 // The entry hook is a "push lr" instruction, followed by a call. | 4357 // The entry hook is a "push lr" instruction, followed by a call. |
| 4160 const int32_t kReturnAddressDistanceFromFunctionStart = | 4358 const int32_t kReturnAddressDistanceFromFunctionStart = |
| 4161 3 * Assembler::kInstrSize; | 4359 Assembler::kCallTargetAddressOffset + 2 * Assembler::kInstrSize; |
| 4162 | 4360 |
| 4163 // This should contain all kCallerSaved registers. | 4361 // This should contain all kJSCallerSaved registers. |
| 4164 const RegList kSavedRegs = | 4362 const RegList kSavedRegs = kJSCallerSaved | // Caller saved registers. |
| 4165 1 << 0 | // r0 | 4363 r15.bit(); // Saved stack pointer. |
| 4166 1 << 1 | // r1 | 4364 |
| 4167 1 << 2 | // r2 | |
| 4168 1 << 3 | // r3 | |
| 4169 1 << 5 | // r5 | |
| 4170 1 << 9; // r9 | |
| 4171 // We also save lr, so the count here is one higher than the mask indicates. | 4365 // We also save lr, so the count here is one higher than the mask indicates. |
| 4172 const int32_t kNumSavedRegs = 7; | 4366 const int32_t kNumSavedRegs = kNumJSCallerSaved + 2; |
| 4173 | |
| 4174 DCHECK((kCallerSaved & kSavedRegs) == kCallerSaved); | |
| 4175 | 4367 |
| 4176 // Save all caller-save registers as this may be called from anywhere. | 4368 // Save all caller-save registers as this may be called from anywhere. |
| 4177 __ stm(db_w, sp, kSavedRegs | lr.bit()); | 4369 __ mflr(r0); |
| 4370 __ MultiPush(kSavedRegs | r0.bit()); |
| 4178 | 4371 |
| 4179 // Compute the function's address for the first argument. | 4372 // Compute the function's address for the first argument. |
| 4180 __ sub(r0, lr, Operand(kReturnAddressDistanceFromFunctionStart)); | 4373 __ mr(r3, r0); |
| 4374 __ subi(r3, r3, Operand(kReturnAddressDistanceFromFunctionStart)); |
| 4181 | 4375 |
| 4182 // The caller's return address is above the saved temporaries. | 4376 // The caller's return address is above the saved temporaries. |
| 4183 // Grab that for the second argument to the hook. | 4377 // Grab that for the second argument to the hook. |
| 4184 __ add(r1, sp, Operand(kNumSavedRegs * kPointerSize)); | 4378 __ addi(r4, sp, Operand(kNumSavedRegs * kPointerSize)); |
| 4185 | 4379 |
| 4186 // Align the stack if necessary. | 4380 // Align the stack if necessary. |
| 4187 int frame_alignment = masm->ActivationFrameAlignment(); | 4381 int frame_alignment = masm->ActivationFrameAlignment(); |
| 4188 if (frame_alignment > kPointerSize) { | 4382 if (frame_alignment > kPointerSize) { |
| 4189 __ mov(r5, sp); | 4383 __ mr(r15, sp); |
| 4190 DCHECK(base::bits::IsPowerOfTwo32(frame_alignment)); | 4384 DCHECK(base::bits::IsPowerOfTwo32(frame_alignment)); |
| 4191 __ and_(sp, sp, Operand(-frame_alignment)); | 4385 __ ClearRightImm(sp, sp, Operand(WhichPowerOf2(frame_alignment))); |
| 4192 } | 4386 } |
| 4193 | 4387 |
| 4194 #if V8_HOST_ARCH_ARM | 4388 #if !defined(USE_SIMULATOR) |
| 4195 int32_t entry_hook = | 4389 uintptr_t entry_hook = |
| 4196 reinterpret_cast<int32_t>(isolate()->function_entry_hook()); | 4390 reinterpret_cast<uintptr_t>(isolate()->function_entry_hook()); |
| 4197 __ mov(ip, Operand(entry_hook)); | 4391 __ mov(ip, Operand(entry_hook)); |
| 4392 |
| 4393 #if ABI_USES_FUNCTION_DESCRIPTORS |
| 4394 // Function descriptor |
| 4395 __ LoadP(ToRegister(ABI_TOC_REGISTER), MemOperand(ip, kPointerSize)); |
| 4396 __ LoadP(ip, MemOperand(ip, 0)); |
| 4397 #elif ABI_TOC_ADDRESSABILITY_VIA_IP |
| 4398 // ip set above, so nothing to do. |
| 4399 #endif |
| 4400 |
| 4401 // PPC LINUX ABI: |
| 4402 __ li(r0, Operand::Zero()); |
| 4403 __ StorePU(r0, MemOperand(sp, -kNumRequiredStackFrameSlots * kPointerSize)); |
| 4198 #else | 4404 #else |
| 4199 // Under the simulator we need to indirect the entry hook through a | 4405 // Under the simulator we need to indirect the entry hook through a |
| 4200 // trampoline function at a known address. | 4406 // trampoline function at a known address. |
| 4201 // It additionally takes an isolate as a third parameter | 4407 // It additionally takes an isolate as a third parameter |
| 4202 __ mov(r2, Operand(ExternalReference::isolate_address(isolate()))); | 4408 __ mov(r5, Operand(ExternalReference::isolate_address(isolate()))); |
| 4203 | 4409 |
| 4204 ApiFunction dispatcher(FUNCTION_ADDR(EntryHookTrampoline)); | 4410 ApiFunction dispatcher(FUNCTION_ADDR(EntryHookTrampoline)); |
| 4205 __ mov(ip, Operand(ExternalReference(&dispatcher, | 4411 __ mov(ip, Operand(ExternalReference( |
| 4206 ExternalReference::BUILTIN_CALL, | 4412 &dispatcher, ExternalReference::BUILTIN_CALL, isolate()))); |
| 4207 isolate()))); | |
| 4208 #endif | 4413 #endif |
| 4209 __ Call(ip); | 4414 __ Call(ip); |
| 4210 | 4415 |
| 4416 #if !defined(USE_SIMULATOR) |
| 4417 __ addi(sp, sp, Operand(kNumRequiredStackFrameSlots * kPointerSize)); |
| 4418 #endif |
| 4419 |
| 4211 // Restore the stack pointer if needed. | 4420 // Restore the stack pointer if needed. |
| 4212 if (frame_alignment > kPointerSize) { | 4421 if (frame_alignment > kPointerSize) { |
| 4213 __ mov(sp, r5); | 4422 __ mr(sp, r15); |
| 4214 } | 4423 } |
| 4215 | 4424 |
| 4216 // Also pop pc to get Ret(0). | 4425 // Also pop lr to get Ret(0). |
| 4217 __ ldm(ia_w, sp, kSavedRegs | pc.bit()); | 4426 __ MultiPop(kSavedRegs | r0.bit()); |
| 4427 __ mtlr(r0); |
| 4428 __ Ret(); |
| 4218 } | 4429 } |
| 4219 | 4430 |
| 4220 | 4431 |
| 4221 template<class T> | 4432 template <class T> |
| 4222 static void CreateArrayDispatch(MacroAssembler* masm, | 4433 static void CreateArrayDispatch(MacroAssembler* masm, |
| 4223 AllocationSiteOverrideMode mode) { | 4434 AllocationSiteOverrideMode mode) { |
| 4224 if (mode == DISABLE_ALLOCATION_SITES) { | 4435 if (mode == DISABLE_ALLOCATION_SITES) { |
| 4225 T stub(masm->isolate(), GetInitialFastElementsKind(), mode); | 4436 T stub(masm->isolate(), GetInitialFastElementsKind(), mode); |
| 4226 __ TailCallStub(&stub); | 4437 __ TailCallStub(&stub); |
| 4227 } else if (mode == DONT_OVERRIDE) { | 4438 } else if (mode == DONT_OVERRIDE) { |
| 4228 int last_index = GetSequenceIndexFromFastElementsKind( | 4439 int last_index = |
| 4229 TERMINAL_FAST_ELEMENTS_KIND); | 4440 GetSequenceIndexFromFastElementsKind(TERMINAL_FAST_ELEMENTS_KIND); |
| 4230 for (int i = 0; i <= last_index; ++i) { | 4441 for (int i = 0; i <= last_index; ++i) { |
| 4231 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); | 4442 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); |
| 4232 __ cmp(r3, Operand(kind)); | 4443 __ Cmpi(r6, Operand(kind), r0); |
| 4233 T stub(masm->isolate(), kind); | 4444 T stub(masm->isolate(), kind); |
| 4234 __ TailCallStub(&stub, eq); | 4445 __ TailCallStub(&stub, eq); |
| 4235 } | 4446 } |
| 4236 | 4447 |
| 4237 // If we reached this point there is a problem. | 4448 // If we reached this point there is a problem. |
| 4238 __ Abort(kUnexpectedElementsKindInArrayConstructor); | 4449 __ Abort(kUnexpectedElementsKindInArrayConstructor); |
| 4239 } else { | 4450 } else { |
| 4240 UNREACHABLE(); | 4451 UNREACHABLE(); |
| 4241 } | 4452 } |
| 4242 } | 4453 } |
| 4243 | 4454 |
| 4244 | 4455 |
| 4245 static void CreateArrayDispatchOneArgument(MacroAssembler* masm, | 4456 static void CreateArrayDispatchOneArgument(MacroAssembler* masm, |
| 4246 AllocationSiteOverrideMode mode) { | 4457 AllocationSiteOverrideMode mode) { |
| 4247 // r2 - allocation site (if mode != DISABLE_ALLOCATION_SITES) | 4458 // r5 - allocation site (if mode != DISABLE_ALLOCATION_SITES) |
| 4248 // r3 - kind (if mode != DISABLE_ALLOCATION_SITES) | 4459 // r6 - kind (if mode != DISABLE_ALLOCATION_SITES) |
| 4249 // r0 - number of arguments | 4460 // r3 - number of arguments |
| 4250 // r1 - constructor? | 4461 // r4 - constructor? |
| 4251 // sp[0] - last argument | 4462 // sp[0] - last argument |
| 4252 Label normal_sequence; | 4463 Label normal_sequence; |
| 4253 if (mode == DONT_OVERRIDE) { | 4464 if (mode == DONT_OVERRIDE) { |
| 4254 DCHECK(FAST_SMI_ELEMENTS == 0); | 4465 DCHECK(FAST_SMI_ELEMENTS == 0); |
| 4255 DCHECK(FAST_HOLEY_SMI_ELEMENTS == 1); | 4466 DCHECK(FAST_HOLEY_SMI_ELEMENTS == 1); |
| 4256 DCHECK(FAST_ELEMENTS == 2); | 4467 DCHECK(FAST_ELEMENTS == 2); |
| 4257 DCHECK(FAST_HOLEY_ELEMENTS == 3); | 4468 DCHECK(FAST_HOLEY_ELEMENTS == 3); |
| 4258 DCHECK(FAST_DOUBLE_ELEMENTS == 4); | 4469 DCHECK(FAST_DOUBLE_ELEMENTS == 4); |
| 4259 DCHECK(FAST_HOLEY_DOUBLE_ELEMENTS == 5); | 4470 DCHECK(FAST_HOLEY_DOUBLE_ELEMENTS == 5); |
| 4260 | 4471 |
| 4261 // is the low bit set? If so, we are holey and that is good. | 4472 // is the low bit set? If so, we are holey and that is good. |
| 4262 __ tst(r3, Operand(1)); | 4473 __ andi(r0, r6, Operand(1)); |
| 4263 __ b(ne, &normal_sequence); | 4474 __ bne(&normal_sequence, cr0); |
| 4264 } | 4475 } |
| 4265 | 4476 |
| 4266 // look at the first argument | 4477 // look at the first argument |
| 4267 __ ldr(r5, MemOperand(sp, 0)); | 4478 __ LoadP(r8, MemOperand(sp, 0)); |
| 4268 __ cmp(r5, Operand::Zero()); | 4479 __ cmpi(r8, Operand::Zero()); |
| 4269 __ b(eq, &normal_sequence); | 4480 __ beq(&normal_sequence); |
| 4270 | 4481 |
| 4271 if (mode == DISABLE_ALLOCATION_SITES) { | 4482 if (mode == DISABLE_ALLOCATION_SITES) { |
| 4272 ElementsKind initial = GetInitialFastElementsKind(); | 4483 ElementsKind initial = GetInitialFastElementsKind(); |
| 4273 ElementsKind holey_initial = GetHoleyElementsKind(initial); | 4484 ElementsKind holey_initial = GetHoleyElementsKind(initial); |
| 4274 | 4485 |
| 4275 ArraySingleArgumentConstructorStub stub_holey(masm->isolate(), | 4486 ArraySingleArgumentConstructorStub stub_holey( |
| 4276 holey_initial, | 4487 masm->isolate(), holey_initial, DISABLE_ALLOCATION_SITES); |
| 4277 DISABLE_ALLOCATION_SITES); | |
| 4278 __ TailCallStub(&stub_holey); | 4488 __ TailCallStub(&stub_holey); |
| 4279 | 4489 |
| 4280 __ bind(&normal_sequence); | 4490 __ bind(&normal_sequence); |
| 4281 ArraySingleArgumentConstructorStub stub(masm->isolate(), | 4491 ArraySingleArgumentConstructorStub stub(masm->isolate(), initial, |
| 4282 initial, | |
| 4283 DISABLE_ALLOCATION_SITES); | 4492 DISABLE_ALLOCATION_SITES); |
| 4284 __ TailCallStub(&stub); | 4493 __ TailCallStub(&stub); |
| 4285 } else if (mode == DONT_OVERRIDE) { | 4494 } else if (mode == DONT_OVERRIDE) { |
| 4286 // We are going to create a holey array, but our kind is non-holey. | 4495 // We are going to create a holey array, but our kind is non-holey. |
| 4287 // Fix kind and retry (only if we have an allocation site in the slot). | 4496 // Fix kind and retry (only if we have an allocation site in the slot). |
| 4288 __ add(r3, r3, Operand(1)); | 4497 __ addi(r6, r6, Operand(1)); |
| 4289 | 4498 |
| 4290 if (FLAG_debug_code) { | 4499 if (FLAG_debug_code) { |
| 4291 __ ldr(r5, FieldMemOperand(r2, 0)); | 4500 __ LoadP(r8, FieldMemOperand(r5, 0)); |
| 4292 __ CompareRoot(r5, Heap::kAllocationSiteMapRootIndex); | 4501 __ CompareRoot(r8, Heap::kAllocationSiteMapRootIndex); |
| 4293 __ Assert(eq, kExpectedAllocationSite); | 4502 __ Assert(eq, kExpectedAllocationSite); |
| 4294 } | 4503 } |
| 4295 | 4504 |
| 4296 // Save the resulting elements kind in type info. We can't just store r3 | 4505 // Save the resulting elements kind in type info. We can't just store r6 |
| 4297 // in the AllocationSite::transition_info field because elements kind is | 4506 // in the AllocationSite::transition_info field because elements kind is |
| 4298 // restricted to a portion of the field...upper bits need to be left alone. | 4507 // restricted to a portion of the field...upper bits need to be left alone. |
| 4299 STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0); | 4508 STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0); |
| 4300 __ ldr(r4, FieldMemOperand(r2, AllocationSite::kTransitionInfoOffset)); | 4509 __ LoadP(r7, FieldMemOperand(r5, AllocationSite::kTransitionInfoOffset)); |
| 4301 __ add(r4, r4, Operand(Smi::FromInt(kFastElementsKindPackedToHoley))); | 4510 __ AddSmiLiteral(r7, r7, Smi::FromInt(kFastElementsKindPackedToHoley), r0); |
| 4302 __ str(r4, FieldMemOperand(r2, AllocationSite::kTransitionInfoOffset)); | 4511 __ StoreP(r7, FieldMemOperand(r5, AllocationSite::kTransitionInfoOffset), |
| 4512 r0); |
| 4303 | 4513 |
| 4304 __ bind(&normal_sequence); | 4514 __ bind(&normal_sequence); |
| 4305 int last_index = GetSequenceIndexFromFastElementsKind( | 4515 int last_index = |
| 4306 TERMINAL_FAST_ELEMENTS_KIND); | 4516 GetSequenceIndexFromFastElementsKind(TERMINAL_FAST_ELEMENTS_KIND); |
| 4307 for (int i = 0; i <= last_index; ++i) { | 4517 for (int i = 0; i <= last_index; ++i) { |
| 4308 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); | 4518 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); |
| 4309 __ cmp(r3, Operand(kind)); | 4519 __ mov(r0, Operand(kind)); |
| 4520 __ cmp(r6, r0); |
| 4310 ArraySingleArgumentConstructorStub stub(masm->isolate(), kind); | 4521 ArraySingleArgumentConstructorStub stub(masm->isolate(), kind); |
| 4311 __ TailCallStub(&stub, eq); | 4522 __ TailCallStub(&stub, eq); |
| 4312 } | 4523 } |
| 4313 | 4524 |
| 4314 // If we reached this point there is a problem. | 4525 // If we reached this point there is a problem. |
| 4315 __ Abort(kUnexpectedElementsKindInArrayConstructor); | 4526 __ Abort(kUnexpectedElementsKindInArrayConstructor); |
| 4316 } else { | 4527 } else { |
| 4317 UNREACHABLE(); | 4528 UNREACHABLE(); |
| 4318 } | 4529 } |
| 4319 } | 4530 } |
| 4320 | 4531 |
| 4321 | 4532 |
| 4322 template<class T> | 4533 template <class T> |
| 4323 static void ArrayConstructorStubAheadOfTimeHelper(Isolate* isolate) { | 4534 static void ArrayConstructorStubAheadOfTimeHelper(Isolate* isolate) { |
| 4324 int to_index = GetSequenceIndexFromFastElementsKind( | 4535 int to_index = |
| 4325 TERMINAL_FAST_ELEMENTS_KIND); | 4536 GetSequenceIndexFromFastElementsKind(TERMINAL_FAST_ELEMENTS_KIND); |
| 4326 for (int i = 0; i <= to_index; ++i) { | 4537 for (int i = 0; i <= to_index; ++i) { |
| 4327 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); | 4538 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); |
| 4328 T stub(isolate, kind); | 4539 T stub(isolate, kind); |
| 4329 stub.GetCode(); | 4540 stub.GetCode(); |
| 4330 if (AllocationSite::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE) { | 4541 if (AllocationSite::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE) { |
| 4331 T stub1(isolate, kind, DISABLE_ALLOCATION_SITES); | 4542 T stub1(isolate, kind, DISABLE_ALLOCATION_SITES); |
| 4332 stub1.GetCode(); | 4543 stub1.GetCode(); |
| 4333 } | 4544 } |
| 4334 } | 4545 } |
| 4335 } | 4546 } |
| 4336 | 4547 |
| 4337 | 4548 |
| 4338 void ArrayConstructorStubBase::GenerateStubsAheadOfTime(Isolate* isolate) { | 4549 void ArrayConstructorStubBase::GenerateStubsAheadOfTime(Isolate* isolate) { |
| 4339 ArrayConstructorStubAheadOfTimeHelper<ArrayNoArgumentConstructorStub>( | 4550 ArrayConstructorStubAheadOfTimeHelper<ArrayNoArgumentConstructorStub>( |
| 4340 isolate); | 4551 isolate); |
| 4341 ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>( | 4552 ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>( |
| 4342 isolate); | 4553 isolate); |
| 4343 ArrayConstructorStubAheadOfTimeHelper<ArrayNArgumentsConstructorStub>( | 4554 ArrayConstructorStubAheadOfTimeHelper<ArrayNArgumentsConstructorStub>( |
| 4344 isolate); | 4555 isolate); |
| 4345 } | 4556 } |
| 4346 | 4557 |
| 4347 | 4558 |
| 4348 void InternalArrayConstructorStubBase::GenerateStubsAheadOfTime( | 4559 void InternalArrayConstructorStubBase::GenerateStubsAheadOfTime( |
| 4349 Isolate* isolate) { | 4560 Isolate* isolate) { |
| 4350 ElementsKind kinds[2] = { FAST_ELEMENTS, FAST_HOLEY_ELEMENTS }; | 4561 ElementsKind kinds[2] = {FAST_ELEMENTS, FAST_HOLEY_ELEMENTS}; |
| 4351 for (int i = 0; i < 2; i++) { | 4562 for (int i = 0; i < 2; i++) { |
| 4352 // For internal arrays we only need a few things | 4563 // For internal arrays we only need a few things |
| 4353 InternalArrayNoArgumentConstructorStub stubh1(isolate, kinds[i]); | 4564 InternalArrayNoArgumentConstructorStub stubh1(isolate, kinds[i]); |
| 4354 stubh1.GetCode(); | 4565 stubh1.GetCode(); |
| 4355 InternalArraySingleArgumentConstructorStub stubh2(isolate, kinds[i]); | 4566 InternalArraySingleArgumentConstructorStub stubh2(isolate, kinds[i]); |
| 4356 stubh2.GetCode(); | 4567 stubh2.GetCode(); |
| 4357 InternalArrayNArgumentsConstructorStub stubh3(isolate, kinds[i]); | 4568 InternalArrayNArgumentsConstructorStub stubh3(isolate, kinds[i]); |
| 4358 stubh3.GetCode(); | 4569 stubh3.GetCode(); |
| 4359 } | 4570 } |
| 4360 } | 4571 } |
| 4361 | 4572 |
| 4362 | 4573 |
| 4363 void ArrayConstructorStub::GenerateDispatchToArrayStub( | 4574 void ArrayConstructorStub::GenerateDispatchToArrayStub( |
| 4364 MacroAssembler* masm, | 4575 MacroAssembler* masm, AllocationSiteOverrideMode mode) { |
| 4365 AllocationSiteOverrideMode mode) { | |
| 4366 if (argument_count() == ANY) { | 4576 if (argument_count() == ANY) { |
| 4367 Label not_zero_case, not_one_case; | 4577 Label not_zero_case, not_one_case; |
| 4368 __ tst(r0, r0); | 4578 __ cmpi(r3, Operand::Zero()); |
| 4369 __ b(ne, ¬_zero_case); | 4579 __ bne(¬_zero_case); |
| 4370 CreateArrayDispatch<ArrayNoArgumentConstructorStub>(masm, mode); | 4580 CreateArrayDispatch<ArrayNoArgumentConstructorStub>(masm, mode); |
| 4371 | 4581 |
| 4372 __ bind(¬_zero_case); | 4582 __ bind(¬_zero_case); |
| 4373 __ cmp(r0, Operand(1)); | 4583 __ cmpi(r3, Operand(1)); |
| 4374 __ b(gt, ¬_one_case); | 4584 __ bgt(¬_one_case); |
| 4375 CreateArrayDispatchOneArgument(masm, mode); | 4585 CreateArrayDispatchOneArgument(masm, mode); |
| 4376 | 4586 |
| 4377 __ bind(¬_one_case); | 4587 __ bind(¬_one_case); |
| 4378 CreateArrayDispatch<ArrayNArgumentsConstructorStub>(masm, mode); | 4588 CreateArrayDispatch<ArrayNArgumentsConstructorStub>(masm, mode); |
| 4379 } else if (argument_count() == NONE) { | 4589 } else if (argument_count() == NONE) { |
| 4380 CreateArrayDispatch<ArrayNoArgumentConstructorStub>(masm, mode); | 4590 CreateArrayDispatch<ArrayNoArgumentConstructorStub>(masm, mode); |
| 4381 } else if (argument_count() == ONE) { | 4591 } else if (argument_count() == ONE) { |
| 4382 CreateArrayDispatchOneArgument(masm, mode); | 4592 CreateArrayDispatchOneArgument(masm, mode); |
| 4383 } else if (argument_count() == MORE_THAN_ONE) { | 4593 } else if (argument_count() == MORE_THAN_ONE) { |
| 4384 CreateArrayDispatch<ArrayNArgumentsConstructorStub>(masm, mode); | 4594 CreateArrayDispatch<ArrayNArgumentsConstructorStub>(masm, mode); |
| 4385 } else { | 4595 } else { |
| 4386 UNREACHABLE(); | 4596 UNREACHABLE(); |
| 4387 } | 4597 } |
| 4388 } | 4598 } |
| 4389 | 4599 |
| 4390 | 4600 |
| 4391 void ArrayConstructorStub::Generate(MacroAssembler* masm) { | 4601 void ArrayConstructorStub::Generate(MacroAssembler* masm) { |
| 4392 // ----------- S t a t e ------------- | 4602 // ----------- S t a t e ------------- |
| 4393 // -- r0 : argc (only if argument_count() == ANY) | 4603 // -- r3 : argc (only if argument_count() == ANY) |
| 4394 // -- r1 : constructor | 4604 // -- r4 : constructor |
| 4395 // -- r2 : AllocationSite or undefined | 4605 // -- r5 : AllocationSite or undefined |
| 4396 // -- sp[0] : return address | 4606 // -- sp[0] : return address |
| 4397 // -- sp[4] : last argument | 4607 // -- sp[4] : last argument |
| 4398 // ----------------------------------- | 4608 // ----------------------------------- |
| 4399 | 4609 |
| 4400 if (FLAG_debug_code) { | 4610 if (FLAG_debug_code) { |
| 4401 // The array construct code is only set for the global and natives | 4611 // The array construct code is only set for the global and natives |
| 4402 // builtin Array functions which always have maps. | 4612 // builtin Array functions which always have maps. |
| 4403 | 4613 |
| 4404 // Initial map for the builtin Array function should be a map. | 4614 // Initial map for the builtin Array function should be a map. |
| 4405 __ ldr(r4, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset)); | 4615 __ LoadP(r7, FieldMemOperand(r4, JSFunction::kPrototypeOrInitialMapOffset)); |
| 4406 // Will both indicate a NULL and a Smi. | 4616 // Will both indicate a NULL and a Smi. |
| 4407 __ tst(r4, Operand(kSmiTagMask)); | 4617 __ TestIfSmi(r7, r0); |
| 4408 __ Assert(ne, kUnexpectedInitialMapForArrayFunction); | 4618 __ Assert(ne, kUnexpectedInitialMapForArrayFunction, cr0); |
| 4409 __ CompareObjectType(r4, r4, r5, MAP_TYPE); | 4619 __ CompareObjectType(r7, r7, r8, MAP_TYPE); |
| 4410 __ Assert(eq, kUnexpectedInitialMapForArrayFunction); | 4620 __ Assert(eq, kUnexpectedInitialMapForArrayFunction); |
| 4411 | 4621 |
| 4412 // We should either have undefined in r2 or a valid AllocationSite | 4622 // We should either have undefined in r5 or a valid AllocationSite |
| 4413 __ AssertUndefinedOrAllocationSite(r2, r4); | 4623 __ AssertUndefinedOrAllocationSite(r5, r7); |
| 4414 } | 4624 } |
| 4415 | 4625 |
| 4416 Label no_info; | 4626 Label no_info; |
| 4417 // Get the elements kind and case on that. | 4627 // Get the elements kind and case on that. |
| 4418 __ CompareRoot(r2, Heap::kUndefinedValueRootIndex); | 4628 __ CompareRoot(r5, Heap::kUndefinedValueRootIndex); |
| 4419 __ b(eq, &no_info); | 4629 __ beq(&no_info); |
| 4420 | 4630 |
| 4421 __ ldr(r3, FieldMemOperand(r2, AllocationSite::kTransitionInfoOffset)); | 4631 __ LoadP(r6, FieldMemOperand(r5, AllocationSite::kTransitionInfoOffset)); |
| 4422 __ SmiUntag(r3); | 4632 __ SmiUntag(r6); |
| 4423 STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0); | 4633 STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0); |
| 4424 __ and_(r3, r3, Operand(AllocationSite::ElementsKindBits::kMask)); | 4634 __ And(r6, r6, Operand(AllocationSite::ElementsKindBits::kMask)); |
| 4425 GenerateDispatchToArrayStub(masm, DONT_OVERRIDE); | 4635 GenerateDispatchToArrayStub(masm, DONT_OVERRIDE); |
| 4426 | 4636 |
| 4427 __ bind(&no_info); | 4637 __ bind(&no_info); |
| 4428 GenerateDispatchToArrayStub(masm, DISABLE_ALLOCATION_SITES); | 4638 GenerateDispatchToArrayStub(masm, DISABLE_ALLOCATION_SITES); |
| 4429 } | 4639 } |
| 4430 | 4640 |
| 4431 | 4641 |
| 4432 void InternalArrayConstructorStub::GenerateCase( | 4642 void InternalArrayConstructorStub::GenerateCase(MacroAssembler* masm, |
| 4433 MacroAssembler* masm, ElementsKind kind) { | 4643 ElementsKind kind) { |
| 4434 __ cmp(r0, Operand(1)); | 4644 __ cmpli(r3, Operand(1)); |
| 4435 | 4645 |
| 4436 InternalArrayNoArgumentConstructorStub stub0(isolate(), kind); | 4646 InternalArrayNoArgumentConstructorStub stub0(isolate(), kind); |
| 4437 __ TailCallStub(&stub0, lo); | 4647 __ TailCallStub(&stub0, lt); |
| 4438 | 4648 |
| 4439 InternalArrayNArgumentsConstructorStub stubN(isolate(), kind); | 4649 InternalArrayNArgumentsConstructorStub stubN(isolate(), kind); |
| 4440 __ TailCallStub(&stubN, hi); | 4650 __ TailCallStub(&stubN, gt); |
| 4441 | 4651 |
| 4442 if (IsFastPackedElementsKind(kind)) { | 4652 if (IsFastPackedElementsKind(kind)) { |
| 4443 // We might need to create a holey array | 4653 // We might need to create a holey array |
| 4444 // look at the first argument | 4654 // look at the first argument |
| 4445 __ ldr(r3, MemOperand(sp, 0)); | 4655 __ LoadP(r6, MemOperand(sp, 0)); |
| 4446 __ cmp(r3, Operand::Zero()); | 4656 __ cmpi(r6, Operand::Zero()); |
| 4447 | 4657 |
| 4448 InternalArraySingleArgumentConstructorStub | 4658 InternalArraySingleArgumentConstructorStub stub1_holey( |
| 4449 stub1_holey(isolate(), GetHoleyElementsKind(kind)); | 4659 isolate(), GetHoleyElementsKind(kind)); |
| 4450 __ TailCallStub(&stub1_holey, ne); | 4660 __ TailCallStub(&stub1_holey, ne); |
| 4451 } | 4661 } |
| 4452 | 4662 |
| 4453 InternalArraySingleArgumentConstructorStub stub1(isolate(), kind); | 4663 InternalArraySingleArgumentConstructorStub stub1(isolate(), kind); |
| 4454 __ TailCallStub(&stub1); | 4664 __ TailCallStub(&stub1); |
| 4455 } | 4665 } |
| 4456 | 4666 |
| 4457 | 4667 |
| 4458 void InternalArrayConstructorStub::Generate(MacroAssembler* masm) { | 4668 void InternalArrayConstructorStub::Generate(MacroAssembler* masm) { |
| 4459 // ----------- S t a t e ------------- | 4669 // ----------- S t a t e ------------- |
| 4460 // -- r0 : argc | 4670 // -- r3 : argc |
| 4461 // -- r1 : constructor | 4671 // -- r4 : constructor |
| 4462 // -- sp[0] : return address | 4672 // -- sp[0] : return address |
| 4463 // -- sp[4] : last argument | 4673 // -- sp[4] : last argument |
| 4464 // ----------------------------------- | 4674 // ----------------------------------- |
| 4465 | 4675 |
| 4466 if (FLAG_debug_code) { | 4676 if (FLAG_debug_code) { |
| 4467 // The array construct code is only set for the global and natives | 4677 // The array construct code is only set for the global and natives |
| 4468 // builtin Array functions which always have maps. | 4678 // builtin Array functions which always have maps. |
| 4469 | 4679 |
| 4470 // Initial map for the builtin Array function should be a map. | 4680 // Initial map for the builtin Array function should be a map. |
| 4471 __ ldr(r3, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset)); | 4681 __ LoadP(r6, FieldMemOperand(r4, JSFunction::kPrototypeOrInitialMapOffset)); |
| 4472 // Will both indicate a NULL and a Smi. | 4682 // Will both indicate a NULL and a Smi. |
| 4473 __ tst(r3, Operand(kSmiTagMask)); | 4683 __ TestIfSmi(r6, r0); |
| 4474 __ Assert(ne, kUnexpectedInitialMapForArrayFunction); | 4684 __ Assert(ne, kUnexpectedInitialMapForArrayFunction, cr0); |
| 4475 __ CompareObjectType(r3, r3, r4, MAP_TYPE); | 4685 __ CompareObjectType(r6, r6, r7, MAP_TYPE); |
| 4476 __ Assert(eq, kUnexpectedInitialMapForArrayFunction); | 4686 __ Assert(eq, kUnexpectedInitialMapForArrayFunction); |
| 4477 } | 4687 } |
| 4478 | 4688 |
| 4479 // Figure out the right elements kind | 4689 // Figure out the right elements kind |
| 4480 __ ldr(r3, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset)); | 4690 __ LoadP(r6, FieldMemOperand(r4, JSFunction::kPrototypeOrInitialMapOffset)); |
| 4481 // Load the map's "bit field 2" into |result|. We only need the first byte, | 4691 // Load the map's "bit field 2" into |result|. |
| 4482 // but the following bit field extraction takes care of that anyway. | 4692 __ lbz(r6, FieldMemOperand(r6, Map::kBitField2Offset)); |
| 4483 __ ldr(r3, FieldMemOperand(r3, Map::kBitField2Offset)); | |
| 4484 // Retrieve elements_kind from bit field 2. | 4693 // Retrieve elements_kind from bit field 2. |
| 4485 __ DecodeField<Map::ElementsKindBits>(r3); | 4694 __ DecodeField<Map::ElementsKindBits>(r6); |
| 4486 | 4695 |
| 4487 if (FLAG_debug_code) { | 4696 if (FLAG_debug_code) { |
| 4488 Label done; | 4697 Label done; |
| 4489 __ cmp(r3, Operand(FAST_ELEMENTS)); | 4698 __ cmpi(r6, Operand(FAST_ELEMENTS)); |
| 4490 __ b(eq, &done); | 4699 __ beq(&done); |
| 4491 __ cmp(r3, Operand(FAST_HOLEY_ELEMENTS)); | 4700 __ cmpi(r6, Operand(FAST_HOLEY_ELEMENTS)); |
| 4492 __ Assert(eq, | 4701 __ Assert(eq, kInvalidElementsKindForInternalArrayOrInternalPackedArray); |
| 4493 kInvalidElementsKindForInternalArrayOrInternalPackedArray); | |
| 4494 __ bind(&done); | 4702 __ bind(&done); |
| 4495 } | 4703 } |
| 4496 | 4704 |
| 4497 Label fast_elements_case; | 4705 Label fast_elements_case; |
| 4498 __ cmp(r3, Operand(FAST_ELEMENTS)); | 4706 __ cmpi(r6, Operand(FAST_ELEMENTS)); |
| 4499 __ b(eq, &fast_elements_case); | 4707 __ beq(&fast_elements_case); |
| 4500 GenerateCase(masm, FAST_HOLEY_ELEMENTS); | 4708 GenerateCase(masm, FAST_HOLEY_ELEMENTS); |
| 4501 | 4709 |
| 4502 __ bind(&fast_elements_case); | 4710 __ bind(&fast_elements_case); |
| 4503 GenerateCase(masm, FAST_ELEMENTS); | 4711 GenerateCase(masm, FAST_ELEMENTS); |
| 4504 } | 4712 } |
| 4505 | 4713 |
| 4506 | 4714 |
| 4507 void CallApiFunctionStub::Generate(MacroAssembler* masm) { | 4715 void CallApiFunctionStub::Generate(MacroAssembler* masm) { |
| 4508 // ----------- S t a t e ------------- | 4716 // ----------- S t a t e ------------- |
| 4509 // -- r0 : callee | 4717 // -- r3 : callee |
| 4510 // -- r4 : call_data | 4718 // -- r7 : call_data |
| 4511 // -- r2 : holder | 4719 // -- r5 : holder |
| 4512 // -- r1 : api_function_address | 4720 // -- r4 : api_function_address |
| 4513 // -- cp : context | 4721 // -- cp : context |
| 4514 // -- | 4722 // -- |
| 4515 // -- sp[0] : last argument | 4723 // -- sp[0] : last argument |
| 4516 // -- ... | 4724 // -- ... |
| 4517 // -- sp[(argc - 1)* 4] : first argument | 4725 // -- sp[(argc - 1)* 4] : first argument |
| 4518 // -- sp[argc * 4] : receiver | 4726 // -- sp[argc * 4] : receiver |
| 4519 // ----------------------------------- | 4727 // ----------------------------------- |
| 4520 | 4728 |
| 4521 Register callee = r0; | 4729 Register callee = r3; |
| 4522 Register call_data = r4; | 4730 Register call_data = r7; |
| 4523 Register holder = r2; | 4731 Register holder = r5; |
| 4524 Register api_function_address = r1; | 4732 Register api_function_address = r4; |
| 4525 Register context = cp; | 4733 Register context = cp; |
| 4526 | 4734 |
| 4527 int argc = this->argc(); | 4735 int argc = this->argc(); |
| 4528 bool is_store = this->is_store(); | 4736 bool is_store = this->is_store(); |
| 4529 bool call_data_undefined = this->call_data_undefined(); | 4737 bool call_data_undefined = this->call_data_undefined(); |
| 4530 | 4738 |
| 4531 typedef FunctionCallbackArguments FCA; | 4739 typedef FunctionCallbackArguments FCA; |
| 4532 | 4740 |
| 4533 STATIC_ASSERT(FCA::kContextSaveIndex == 6); | 4741 STATIC_ASSERT(FCA::kContextSaveIndex == 6); |
| 4534 STATIC_ASSERT(FCA::kCalleeIndex == 5); | 4742 STATIC_ASSERT(FCA::kCalleeIndex == 5); |
| 4535 STATIC_ASSERT(FCA::kDataIndex == 4); | 4743 STATIC_ASSERT(FCA::kDataIndex == 4); |
| 4536 STATIC_ASSERT(FCA::kReturnValueOffset == 3); | 4744 STATIC_ASSERT(FCA::kReturnValueOffset == 3); |
| 4537 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); | 4745 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); |
| 4538 STATIC_ASSERT(FCA::kIsolateIndex == 1); | 4746 STATIC_ASSERT(FCA::kIsolateIndex == 1); |
| 4539 STATIC_ASSERT(FCA::kHolderIndex == 0); | 4747 STATIC_ASSERT(FCA::kHolderIndex == 0); |
| 4540 STATIC_ASSERT(FCA::kArgsLength == 7); | 4748 STATIC_ASSERT(FCA::kArgsLength == 7); |
| 4541 | 4749 |
| 4542 // context save | 4750 // context save |
| 4543 __ push(context); | 4751 __ push(context); |
| 4544 // load context from callee | 4752 // load context from callee |
| 4545 __ ldr(context, FieldMemOperand(callee, JSFunction::kContextOffset)); | 4753 __ LoadP(context, FieldMemOperand(callee, JSFunction::kContextOffset)); |
| 4546 | 4754 |
| 4547 // callee | 4755 // callee |
| 4548 __ push(callee); | 4756 __ push(callee); |
| 4549 | 4757 |
| 4550 // call data | 4758 // call data |
| 4551 __ push(call_data); | 4759 __ push(call_data); |
| 4552 | 4760 |
| 4553 Register scratch = call_data; | 4761 Register scratch = call_data; |
| 4554 if (!call_data_undefined) { | 4762 if (!call_data_undefined) { |
| 4555 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); | 4763 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); |
| 4556 } | 4764 } |
| 4557 // return value | 4765 // return value |
| 4558 __ push(scratch); | 4766 __ push(scratch); |
| 4559 // return value default | 4767 // return value default |
| 4560 __ push(scratch); | 4768 __ push(scratch); |
| 4561 // isolate | 4769 // isolate |
| 4562 __ mov(scratch, | 4770 __ mov(scratch, Operand(ExternalReference::isolate_address(isolate()))); |
| 4563 Operand(ExternalReference::isolate_address(isolate()))); | |
| 4564 __ push(scratch); | 4771 __ push(scratch); |
| 4565 // holder | 4772 // holder |
| 4566 __ push(holder); | 4773 __ push(holder); |
| 4567 | 4774 |
| 4568 // Prepare arguments. | 4775 // Prepare arguments. |
| 4569 __ mov(scratch, sp); | 4776 __ mr(scratch, sp); |
| 4570 | 4777 |
| 4571 // Allocate the v8::Arguments structure in the arguments' space since | 4778 // Allocate the v8::Arguments structure in the arguments' space since |
| 4572 // it's not controlled by GC. | 4779 // it's not controlled by GC. |
| 4573 const int kApiStackSpace = 4; | 4780 // PPC LINUX ABI: |
| 4781 // |
| 4782 // Create 5 extra slots on stack: |
| 4783 // [0] space for DirectCEntryStub's LR save |
| 4784 // [1-4] FunctionCallbackInfo |
| 4785 const int kApiStackSpace = 5; |
| 4574 | 4786 |
| 4575 FrameScope frame_scope(masm, StackFrame::MANUAL); | 4787 FrameScope frame_scope(masm, StackFrame::MANUAL); |
| 4576 __ EnterExitFrame(false, kApiStackSpace); | 4788 __ EnterExitFrame(false, kApiStackSpace); |
| 4577 | 4789 |
| 4578 DCHECK(!api_function_address.is(r0) && !scratch.is(r0)); | 4790 DCHECK(!api_function_address.is(r3) && !scratch.is(r3)); |
| 4579 // r0 = FunctionCallbackInfo& | 4791 // r3 = FunctionCallbackInfo& |
| 4580 // Arguments is after the return address. | 4792 // Arguments is after the return address. |
| 4581 __ add(r0, sp, Operand(1 * kPointerSize)); | 4793 __ addi(r3, sp, Operand((kStackFrameExtraParamSlot + 1) * kPointerSize)); |
| 4582 // FunctionCallbackInfo::implicit_args_ | 4794 // FunctionCallbackInfo::implicit_args_ |
| 4583 __ str(scratch, MemOperand(r0, 0 * kPointerSize)); | 4795 __ StoreP(scratch, MemOperand(r3, 0 * kPointerSize)); |
| 4584 // FunctionCallbackInfo::values_ | 4796 // FunctionCallbackInfo::values_ |
| 4585 __ add(ip, scratch, Operand((FCA::kArgsLength - 1 + argc) * kPointerSize)); | 4797 __ addi(ip, scratch, Operand((FCA::kArgsLength - 1 + argc) * kPointerSize)); |
| 4586 __ str(ip, MemOperand(r0, 1 * kPointerSize)); | 4798 __ StoreP(ip, MemOperand(r3, 1 * kPointerSize)); |
| 4587 // FunctionCallbackInfo::length_ = argc | 4799 // FunctionCallbackInfo::length_ = argc |
| 4588 __ mov(ip, Operand(argc)); | 4800 __ li(ip, Operand(argc)); |
| 4589 __ str(ip, MemOperand(r0, 2 * kPointerSize)); | 4801 __ stw(ip, MemOperand(r3, 2 * kPointerSize)); |
| 4590 // FunctionCallbackInfo::is_construct_call = 0 | 4802 // FunctionCallbackInfo::is_construct_call = 0 |
| 4591 __ mov(ip, Operand::Zero()); | 4803 __ li(ip, Operand::Zero()); |
| 4592 __ str(ip, MemOperand(r0, 3 * kPointerSize)); | 4804 __ stw(ip, MemOperand(r3, 2 * kPointerSize + kIntSize)); |
| 4593 | 4805 |
| 4594 const int kStackUnwindSpace = argc + FCA::kArgsLength + 1; | 4806 const int kStackUnwindSpace = argc + FCA::kArgsLength + 1; |
| 4595 ExternalReference thunk_ref = | 4807 ExternalReference thunk_ref = |
| 4596 ExternalReference::invoke_function_callback(isolate()); | 4808 ExternalReference::invoke_function_callback(isolate()); |
| 4597 | 4809 |
| 4598 AllowExternalCallThatCantCauseGC scope(masm); | 4810 AllowExternalCallThatCantCauseGC scope(masm); |
| 4599 MemOperand context_restore_operand( | 4811 MemOperand context_restore_operand( |
| 4600 fp, (2 + FCA::kContextSaveIndex) * kPointerSize); | 4812 fp, (2 + FCA::kContextSaveIndex) * kPointerSize); |
| 4601 // Stores return the first js argument | 4813 // Stores return the first js argument |
| 4602 int return_value_offset = 0; | 4814 int return_value_offset = 0; |
| 4603 if (is_store) { | 4815 if (is_store) { |
| 4604 return_value_offset = 2 + FCA::kArgsLength; | 4816 return_value_offset = 2 + FCA::kArgsLength; |
| 4605 } else { | 4817 } else { |
| 4606 return_value_offset = 2 + FCA::kReturnValueOffset; | 4818 return_value_offset = 2 + FCA::kReturnValueOffset; |
| 4607 } | 4819 } |
| 4608 MemOperand return_value_operand(fp, return_value_offset * kPointerSize); | 4820 MemOperand return_value_operand(fp, return_value_offset * kPointerSize); |
| 4609 | 4821 |
| 4610 __ CallApiFunctionAndReturn(api_function_address, | 4822 __ CallApiFunctionAndReturn(api_function_address, thunk_ref, |
| 4611 thunk_ref, | 4823 kStackUnwindSpace, return_value_operand, |
| 4612 kStackUnwindSpace, | |
| 4613 return_value_operand, | |
| 4614 &context_restore_operand); | 4824 &context_restore_operand); |
| 4615 } | 4825 } |
| 4616 | 4826 |
| 4617 | 4827 |
| 4618 void CallApiGetterStub::Generate(MacroAssembler* masm) { | 4828 void CallApiGetterStub::Generate(MacroAssembler* masm) { |
| 4619 // ----------- S t a t e ------------- | 4829 // ----------- S t a t e ------------- |
| 4620 // -- sp[0] : name | 4830 // -- sp[0] : name |
| 4621 // -- sp[4 - kArgsLength*4] : PropertyCallbackArguments object | 4831 // -- sp[4 - kArgsLength*4] : PropertyCallbackArguments object |
| 4622 // -- ... | 4832 // -- ... |
| 4623 // -- r2 : api_function_address | 4833 // -- r5 : api_function_address |
| 4624 // ----------------------------------- | 4834 // ----------------------------------- |
| 4625 | 4835 |
| 4626 Register api_function_address = ApiGetterDescriptor::function_address(); | 4836 Register api_function_address = ApiGetterDescriptor::function_address(); |
| 4627 DCHECK(api_function_address.is(r2)); | 4837 DCHECK(api_function_address.is(r5)); |
| 4628 | 4838 |
| 4629 __ mov(r0, sp); // r0 = Handle<Name> | 4839 __ mr(r3, sp); // r0 = Handle<Name> |
| 4630 __ add(r1, r0, Operand(1 * kPointerSize)); // r1 = PCA | 4840 __ addi(r4, r3, Operand(1 * kPointerSize)); // r4 = PCA |
| 4631 | 4841 |
| 4632 const int kApiStackSpace = 1; | 4842 // If ABI passes Handles (pointer-sized struct) in a register: |
| 4843 // |
| 4844 // Create 2 extra slots on stack: |
| 4845 // [0] space for DirectCEntryStub's LR save |
| 4846 // [1] AccessorInfo& |
| 4847 // |
| 4848 // Otherwise: |
| 4849 // |
| 4850 // Create 3 extra slots on stack: |
| 4851 // [0] space for DirectCEntryStub's LR save |
| 4852 // [1] copy of Handle (first arg) |
| 4853 // [2] AccessorInfo& |
| 4854 #if ABI_PASSES_HANDLES_IN_REGS |
| 4855 const int kAccessorInfoSlot = kStackFrameExtraParamSlot + 1; |
| 4856 const int kApiStackSpace = 2; |
| 4857 #else |
| 4858 const int kArg0Slot = kStackFrameExtraParamSlot + 1; |
| 4859 const int kAccessorInfoSlot = kArg0Slot + 1; |
| 4860 const int kApiStackSpace = 3; |
| 4861 #endif |
| 4862 |
| 4633 FrameScope frame_scope(masm, StackFrame::MANUAL); | 4863 FrameScope frame_scope(masm, StackFrame::MANUAL); |
| 4634 __ EnterExitFrame(false, kApiStackSpace); | 4864 __ EnterExitFrame(false, kApiStackSpace); |
| 4635 | 4865 |
| 4866 #if !ABI_PASSES_HANDLES_IN_REGS |
| 4867 // pass 1st arg by reference |
| 4868 __ StoreP(r3, MemOperand(sp, kArg0Slot * kPointerSize)); |
| 4869 __ addi(r3, sp, Operand(kArg0Slot * kPointerSize)); |
| 4870 #endif |
| 4871 |
| 4636 // Create PropertyAccessorInfo instance on the stack above the exit frame with | 4872 // Create PropertyAccessorInfo instance on the stack above the exit frame with |
| 4637 // r1 (internal::Object** args_) as the data. | 4873 // r4 (internal::Object** args_) as the data. |
| 4638 __ str(r1, MemOperand(sp, 1 * kPointerSize)); | 4874 __ StoreP(r4, MemOperand(sp, kAccessorInfoSlot * kPointerSize)); |
| 4639 __ add(r1, sp, Operand(1 * kPointerSize)); // r1 = AccessorInfo& | 4875 // r4 = AccessorInfo& |
| 4876 __ addi(r4, sp, Operand(kAccessorInfoSlot * kPointerSize)); |
| 4640 | 4877 |
| 4641 const int kStackUnwindSpace = PropertyCallbackArguments::kArgsLength + 1; | 4878 const int kStackUnwindSpace = PropertyCallbackArguments::kArgsLength + 1; |
| 4642 | 4879 |
| 4643 ExternalReference thunk_ref = | 4880 ExternalReference thunk_ref = |
| 4644 ExternalReference::invoke_accessor_getter_callback(isolate()); | 4881 ExternalReference::invoke_accessor_getter_callback(isolate()); |
| 4645 __ CallApiFunctionAndReturn(api_function_address, | 4882 __ CallApiFunctionAndReturn(api_function_address, thunk_ref, |
| 4646 thunk_ref, | |
| 4647 kStackUnwindSpace, | 4883 kStackUnwindSpace, |
| 4648 MemOperand(fp, 6 * kPointerSize), | 4884 MemOperand(fp, 6 * kPointerSize), NULL); |
| 4649 NULL); | |
| 4650 } | 4885 } |
| 4651 | 4886 |
| 4652 | 4887 |
| 4653 #undef __ | 4888 #undef __ |
| 4889 } |
| 4890 } // namespace v8::internal |
| 4654 | 4891 |
| 4655 } } // namespace v8::internal | 4892 #endif // V8_TARGET_ARCH_PPC |
| 4656 | |
| 4657 #endif // V8_TARGET_ARCH_ARM | |
| OLD | NEW |