OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_ARM | 7 #if V8_TARGET_ARCH_PPC |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
11 #include "src/code-stubs.h" | 11 #include "src/code-stubs.h" |
12 #include "src/codegen.h" | 12 #include "src/codegen.h" |
13 #include "src/ic/handler-compiler.h" | 13 #include "src/ic/handler-compiler.h" |
14 #include "src/ic/ic.h" | 14 #include "src/ic/ic.h" |
15 #include "src/isolate.h" | 15 #include "src/isolate.h" |
16 #include "src/jsregexp.h" | 16 #include "src/jsregexp.h" |
17 #include "src/regexp-macro-assembler.h" | 17 #include "src/regexp-macro-assembler.h" |
18 #include "src/runtime/runtime.h" | 18 #include "src/runtime/runtime.h" |
19 | 19 |
20 namespace v8 { | 20 namespace v8 { |
21 namespace internal { | 21 namespace internal { |
22 | 22 |
23 | 23 |
24 static void InitializeArrayConstructorDescriptor( | 24 static void InitializeArrayConstructorDescriptor( |
25 Isolate* isolate, CodeStubDescriptor* descriptor, | 25 Isolate* isolate, CodeStubDescriptor* descriptor, |
26 int constant_stack_parameter_count) { | 26 int constant_stack_parameter_count) { |
27 Address deopt_handler = Runtime::FunctionForId( | 27 Address deopt_handler = |
28 Runtime::kArrayConstructor)->entry; | 28 Runtime::FunctionForId(Runtime::kArrayConstructor)->entry; |
29 | 29 |
30 if (constant_stack_parameter_count == 0) { | 30 if (constant_stack_parameter_count == 0) { |
31 descriptor->Initialize(deopt_handler, constant_stack_parameter_count, | 31 descriptor->Initialize(deopt_handler, constant_stack_parameter_count, |
32 JS_FUNCTION_STUB_MODE); | 32 JS_FUNCTION_STUB_MODE); |
33 } else { | 33 } else { |
34 descriptor->Initialize(r0, deopt_handler, constant_stack_parameter_count, | 34 descriptor->Initialize(r3, deopt_handler, constant_stack_parameter_count, |
35 JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS); | 35 JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS); |
36 } | 36 } |
37 } | 37 } |
38 | 38 |
39 | 39 |
40 static void InitializeInternalArrayConstructorDescriptor( | 40 static void InitializeInternalArrayConstructorDescriptor( |
41 Isolate* isolate, CodeStubDescriptor* descriptor, | 41 Isolate* isolate, CodeStubDescriptor* descriptor, |
42 int constant_stack_parameter_count) { | 42 int constant_stack_parameter_count) { |
43 Address deopt_handler = Runtime::FunctionForId( | 43 Address deopt_handler = |
44 Runtime::kInternalArrayConstructor)->entry; | 44 Runtime::FunctionForId(Runtime::kInternalArrayConstructor)->entry; |
45 | 45 |
46 if (constant_stack_parameter_count == 0) { | 46 if (constant_stack_parameter_count == 0) { |
47 descriptor->Initialize(deopt_handler, constant_stack_parameter_count, | 47 descriptor->Initialize(deopt_handler, constant_stack_parameter_count, |
48 JS_FUNCTION_STUB_MODE); | 48 JS_FUNCTION_STUB_MODE); |
49 } else { | 49 } else { |
50 descriptor->Initialize(r0, deopt_handler, constant_stack_parameter_count, | 50 descriptor->Initialize(r3, deopt_handler, constant_stack_parameter_count, |
51 JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS); | 51 JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS); |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 | 55 |
56 void ArrayNoArgumentConstructorStub::InitializeDescriptor( | 56 void ArrayNoArgumentConstructorStub::InitializeDescriptor( |
57 CodeStubDescriptor* descriptor) { | 57 CodeStubDescriptor* descriptor) { |
58 InitializeArrayConstructorDescriptor(isolate(), descriptor, 0); | 58 InitializeArrayConstructorDescriptor(isolate(), descriptor, 0); |
59 } | 59 } |
60 | 60 |
(...skipping 24 matching lines...) Expand all Loading... |
85 | 85 |
86 void InternalArrayNArgumentsConstructorStub::InitializeDescriptor( | 86 void InternalArrayNArgumentsConstructorStub::InitializeDescriptor( |
87 CodeStubDescriptor* descriptor) { | 87 CodeStubDescriptor* descriptor) { |
88 InitializeInternalArrayConstructorDescriptor(isolate(), descriptor, -1); | 88 InitializeInternalArrayConstructorDescriptor(isolate(), descriptor, -1); |
89 } | 89 } |
90 | 90 |
91 | 91 |
92 #define __ ACCESS_MASM(masm) | 92 #define __ ACCESS_MASM(masm) |
93 | 93 |
94 | 94 |
95 static void EmitIdenticalObjectComparison(MacroAssembler* masm, | 95 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow, |
96 Label* slow, | |
97 Condition cond); | 96 Condition cond); |
98 static void EmitSmiNonsmiComparison(MacroAssembler* masm, | 97 static void EmitSmiNonsmiComparison(MacroAssembler* masm, Register lhs, |
99 Register lhs, | 98 Register rhs, Label* lhs_not_nan, |
100 Register rhs, | 99 Label* slow, bool strict); |
101 Label* lhs_not_nan, | 100 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm, Register lhs, |
102 Label* slow, | |
103 bool strict); | |
104 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm, | |
105 Register lhs, | |
106 Register rhs); | 101 Register rhs); |
107 | 102 |
108 | 103 |
109 void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm, | 104 void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm, |
110 ExternalReference miss) { | 105 ExternalReference miss) { |
111 // Update the static counter each time a new code stub is generated. | 106 // Update the static counter each time a new code stub is generated. |
112 isolate()->counters()->code_stubs()->Increment(); | 107 isolate()->counters()->code_stubs()->Increment(); |
113 | 108 |
114 CallInterfaceDescriptor descriptor = GetCallInterfaceDescriptor(); | 109 CallInterfaceDescriptor descriptor = GetCallInterfaceDescriptor(); |
115 int param_count = descriptor.GetEnvironmentParameterCount(); | 110 int param_count = descriptor.GetEnvironmentParameterCount(); |
116 { | 111 { |
117 // Call the runtime system in a fresh internal frame. | 112 // Call the runtime system in a fresh internal frame. |
118 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 113 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
119 DCHECK(param_count == 0 || | 114 DCHECK(param_count == 0 || |
120 r0.is(descriptor.GetEnvironmentParameterRegister(param_count - 1))); | 115 r3.is(descriptor.GetEnvironmentParameterRegister(param_count - 1))); |
121 // Push arguments | 116 // Push arguments |
122 for (int i = 0; i < param_count; ++i) { | 117 for (int i = 0; i < param_count; ++i) { |
123 __ push(descriptor.GetEnvironmentParameterRegister(i)); | 118 __ push(descriptor.GetEnvironmentParameterRegister(i)); |
124 } | 119 } |
125 __ CallExternalReference(miss, param_count); | 120 __ CallExternalReference(miss, param_count); |
126 } | 121 } |
127 | 122 |
128 __ Ret(); | 123 __ Ret(); |
129 } | 124 } |
130 | 125 |
131 | 126 |
132 void DoubleToIStub::Generate(MacroAssembler* masm) { | 127 void DoubleToIStub::Generate(MacroAssembler* masm) { |
133 Label out_of_range, only_low, negate, done; | 128 Label out_of_range, only_low, negate, done, fastpath_done; |
134 Register input_reg = source(); | 129 Register input_reg = source(); |
135 Register result_reg = destination(); | 130 Register result_reg = destination(); |
136 DCHECK(is_truncating()); | 131 DCHECK(is_truncating()); |
137 | 132 |
138 int double_offset = offset(); | 133 int double_offset = offset(); |
139 // Account for saved regs if input is sp. | |
140 if (input_reg.is(sp)) double_offset += 3 * kPointerSize; | |
141 | 134 |
| 135 // Immediate values for this stub fit in instructions, so it's safe to use ip. |
142 Register scratch = GetRegisterThatIsNotOneOf(input_reg, result_reg); | 136 Register scratch = GetRegisterThatIsNotOneOf(input_reg, result_reg); |
143 Register scratch_low = | 137 Register scratch_low = |
144 GetRegisterThatIsNotOneOf(input_reg, result_reg, scratch); | 138 GetRegisterThatIsNotOneOf(input_reg, result_reg, scratch); |
145 Register scratch_high = | 139 Register scratch_high = |
146 GetRegisterThatIsNotOneOf(input_reg, result_reg, scratch, scratch_low); | 140 GetRegisterThatIsNotOneOf(input_reg, result_reg, scratch, scratch_low); |
147 LowDwVfpRegister double_scratch = kScratchDoubleReg; | 141 DoubleRegister double_scratch = kScratchDoubleReg; |
148 | 142 |
149 __ Push(scratch_high, scratch_low, scratch); | 143 __ push(scratch); |
| 144 // Account for saved regs if input is sp. |
| 145 if (input_reg.is(sp)) double_offset += kPointerSize; |
150 | 146 |
151 if (!skip_fastpath()) { | 147 if (!skip_fastpath()) { |
152 // Load double input. | 148 // Load double input. |
153 __ vldr(double_scratch, MemOperand(input_reg, double_offset)); | 149 __ lfd(double_scratch, MemOperand(input_reg, double_offset)); |
154 __ vmov(scratch_low, scratch_high, double_scratch); | |
155 | 150 |
156 // Do fast-path convert from double to int. | 151 // Do fast-path convert from double to int. |
157 __ vcvt_s32_f64(double_scratch.low(), double_scratch); | 152 __ ConvertDoubleToInt64(double_scratch, |
158 __ vmov(result_reg, double_scratch.low()); | 153 #if !V8_TARGET_ARCH_PPC64 |
| 154 scratch, |
| 155 #endif |
| 156 result_reg, d0); |
159 | 157 |
160 // If result is not saturated (0x7fffffff or 0x80000000), we are done. | 158 // Test for overflow |
161 __ sub(scratch, result_reg, Operand(1)); | 159 #if V8_TARGET_ARCH_PPC64 |
162 __ cmp(scratch, Operand(0x7ffffffe)); | 160 __ TestIfInt32(result_reg, scratch, r0); |
163 __ b(lt, &done); | 161 #else |
164 } else { | 162 __ TestIfInt32(scratch, result_reg, r0); |
165 // We've already done MacroAssembler::TryFastTruncatedDoubleToILoad, so we | 163 #endif |
166 // know exponent > 31, so we can skip the vcvt_s32_f64 which will saturate. | 164 __ beq(&fastpath_done); |
167 if (double_offset == 0) { | |
168 __ ldm(ia, input_reg, scratch_low.bit() | scratch_high.bit()); | |
169 } else { | |
170 __ ldr(scratch_low, MemOperand(input_reg, double_offset)); | |
171 __ ldr(scratch_high, MemOperand(input_reg, double_offset + kIntSize)); | |
172 } | |
173 } | 165 } |
174 | 166 |
175 __ Ubfx(scratch, scratch_high, | 167 __ Push(scratch_high, scratch_low); |
176 HeapNumber::kExponentShift, HeapNumber::kExponentBits); | 168 // Account for saved regs if input is sp. |
| 169 if (input_reg.is(sp)) double_offset += 2 * kPointerSize; |
| 170 |
| 171 __ lwz(scratch_high, |
| 172 MemOperand(input_reg, double_offset + Register::kExponentOffset)); |
| 173 __ lwz(scratch_low, |
| 174 MemOperand(input_reg, double_offset + Register::kMantissaOffset)); |
| 175 |
| 176 __ ExtractBitMask(scratch, scratch_high, HeapNumber::kExponentMask); |
177 // Load scratch with exponent - 1. This is faster than loading | 177 // Load scratch with exponent - 1. This is faster than loading |
178 // with exponent because Bias + 1 = 1024 which is an *ARM* immediate value. | 178 // with exponent because Bias + 1 = 1024 which is a *PPC* immediate value. |
179 STATIC_ASSERT(HeapNumber::kExponentBias + 1 == 1024); | 179 STATIC_ASSERT(HeapNumber::kExponentBias + 1 == 1024); |
180 __ sub(scratch, scratch, Operand(HeapNumber::kExponentBias + 1)); | 180 __ subi(scratch, scratch, Operand(HeapNumber::kExponentBias + 1)); |
181 // If exponent is greater than or equal to 84, the 32 less significant | 181 // If exponent is greater than or equal to 84, the 32 less significant |
182 // bits are 0s (2^84 = 1, 52 significant bits, 32 uncoded bits), | 182 // bits are 0s (2^84 = 1, 52 significant bits, 32 uncoded bits), |
183 // the result is 0. | 183 // the result is 0. |
184 // Compare exponent with 84 (compare exponent - 1 with 83). | 184 // Compare exponent with 84 (compare exponent - 1 with 83). |
185 __ cmp(scratch, Operand(83)); | 185 __ cmpi(scratch, Operand(83)); |
186 __ b(ge, &out_of_range); | 186 __ bge(&out_of_range); |
187 | 187 |
188 // If we reach this code, 31 <= exponent <= 83. | 188 // If we reach this code, 31 <= exponent <= 83. |
189 // So, we don't have to handle cases where 0 <= exponent <= 20 for | 189 // So, we don't have to handle cases where 0 <= exponent <= 20 for |
190 // which we would need to shift right the high part of the mantissa. | 190 // which we would need to shift right the high part of the mantissa. |
191 // Scratch contains exponent - 1. | 191 // Scratch contains exponent - 1. |
192 // Load scratch with 52 - exponent (load with 51 - (exponent - 1)). | 192 // Load scratch with 52 - exponent (load with 51 - (exponent - 1)). |
193 __ rsb(scratch, scratch, Operand(51), SetCC); | 193 __ subfic(scratch, scratch, Operand(51)); |
194 __ b(ls, &only_low); | 194 __ cmpi(scratch, Operand::Zero()); |
| 195 __ ble(&only_low); |
195 // 21 <= exponent <= 51, shift scratch_low and scratch_high | 196 // 21 <= exponent <= 51, shift scratch_low and scratch_high |
196 // to generate the result. | 197 // to generate the result. |
197 __ mov(scratch_low, Operand(scratch_low, LSR, scratch)); | 198 __ srw(scratch_low, scratch_low, scratch); |
198 // Scratch contains: 52 - exponent. | 199 // Scratch contains: 52 - exponent. |
199 // We needs: exponent - 20. | 200 // We needs: exponent - 20. |
200 // So we use: 32 - scratch = 32 - 52 + exponent = exponent - 20. | 201 // So we use: 32 - scratch = 32 - 52 + exponent = exponent - 20. |
201 __ rsb(scratch, scratch, Operand(32)); | 202 __ subfic(scratch, scratch, Operand(32)); |
202 __ Ubfx(result_reg, scratch_high, | 203 __ ExtractBitMask(result_reg, scratch_high, HeapNumber::kMantissaMask); |
203 0, HeapNumber::kMantissaBitsInTopWord); | |
204 // Set the implicit 1 before the mantissa part in scratch_high. | 204 // Set the implicit 1 before the mantissa part in scratch_high. |
205 __ orr(result_reg, result_reg, | 205 STATIC_ASSERT(HeapNumber::kMantissaBitsInTopWord >= 16); |
206 Operand(1 << HeapNumber::kMantissaBitsInTopWord)); | 206 __ oris(result_reg, result_reg, |
207 __ orr(result_reg, scratch_low, Operand(result_reg, LSL, scratch)); | 207 Operand(1 << ((HeapNumber::kMantissaBitsInTopWord) - 16))); |
| 208 __ slw(r0, result_reg, scratch); |
| 209 __ orx(result_reg, scratch_low, r0); |
208 __ b(&negate); | 210 __ b(&negate); |
209 | 211 |
210 __ bind(&out_of_range); | 212 __ bind(&out_of_range); |
211 __ mov(result_reg, Operand::Zero()); | 213 __ mov(result_reg, Operand::Zero()); |
212 __ b(&done); | 214 __ b(&done); |
213 | 215 |
214 __ bind(&only_low); | 216 __ bind(&only_low); |
215 // 52 <= exponent <= 83, shift only scratch_low. | 217 // 52 <= exponent <= 83, shift only scratch_low. |
216 // On entry, scratch contains: 52 - exponent. | 218 // On entry, scratch contains: 52 - exponent. |
217 __ rsb(scratch, scratch, Operand::Zero()); | 219 __ neg(scratch, scratch); |
218 __ mov(result_reg, Operand(scratch_low, LSL, scratch)); | 220 __ slw(result_reg, scratch_low, scratch); |
219 | 221 |
220 __ bind(&negate); | 222 __ bind(&negate); |
221 // If input was positive, scratch_high ASR 31 equals 0 and | 223 // If input was positive, scratch_high ASR 31 equals 0 and |
222 // scratch_high LSR 31 equals zero. | 224 // scratch_high LSR 31 equals zero. |
223 // New result = (result eor 0) + 0 = result. | 225 // New result = (result eor 0) + 0 = result. |
224 // If the input was negative, we have to negate the result. | 226 // If the input was negative, we have to negate the result. |
225 // Input_high ASR 31 equals 0xffffffff and scratch_high LSR 31 equals 1. | 227 // Input_high ASR 31 equals 0xffffffff and scratch_high LSR 31 equals 1. |
226 // New result = (result eor 0xffffffff) + 1 = 0 - result. | 228 // New result = (result eor 0xffffffff) + 1 = 0 - result. |
227 __ eor(result_reg, result_reg, Operand(scratch_high, ASR, 31)); | 229 __ srawi(r0, scratch_high, 31); |
228 __ add(result_reg, result_reg, Operand(scratch_high, LSR, 31)); | 230 #if V8_TARGET_ARCH_PPC64 |
| 231 __ srdi(r0, r0, Operand(32)); |
| 232 #endif |
| 233 __ xor_(result_reg, result_reg, r0); |
| 234 __ srwi(r0, scratch_high, Operand(31)); |
| 235 __ add(result_reg, result_reg, r0); |
229 | 236 |
230 __ bind(&done); | 237 __ bind(&done); |
| 238 __ Pop(scratch_high, scratch_low); |
231 | 239 |
232 __ Pop(scratch_high, scratch_low, scratch); | 240 __ bind(&fastpath_done); |
| 241 __ pop(scratch); |
| 242 |
233 __ Ret(); | 243 __ Ret(); |
234 } | 244 } |
235 | 245 |
236 | 246 |
237 // Handle the case where the lhs and rhs are the same object. | 247 // Handle the case where the lhs and rhs are the same object. |
238 // Equality is almost reflexive (everything but NaN), so this is a test | 248 // Equality is almost reflexive (everything but NaN), so this is a test |
239 // for "identity and not NaN". | 249 // for "identity and not NaN". |
240 static void EmitIdenticalObjectComparison(MacroAssembler* masm, | 250 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow, |
241 Label* slow, | |
242 Condition cond) { | 251 Condition cond) { |
243 Label not_identical; | 252 Label not_identical; |
244 Label heap_number, return_equal; | 253 Label heap_number, return_equal; |
245 __ cmp(r0, r1); | 254 __ cmp(r3, r4); |
246 __ b(ne, ¬_identical); | 255 __ bne(¬_identical); |
247 | 256 |
248 // Test for NaN. Sadly, we can't just compare to Factory::nan_value(), | 257 // Test for NaN. Sadly, we can't just compare to Factory::nan_value(), |
249 // so we do the second best thing - test it ourselves. | 258 // so we do the second best thing - test it ourselves. |
250 // They are both equal and they are not both Smis so both of them are not | 259 // They are both equal and they are not both Smis so both of them are not |
251 // Smis. If it's not a heap number, then return equal. | 260 // Smis. If it's not a heap number, then return equal. |
252 if (cond == lt || cond == gt) { | 261 if (cond == lt || cond == gt) { |
253 __ CompareObjectType(r0, r4, r4, FIRST_SPEC_OBJECT_TYPE); | 262 __ CompareObjectType(r3, r7, r7, FIRST_SPEC_OBJECT_TYPE); |
254 __ b(ge, slow); | 263 __ bge(slow); |
255 } else { | 264 } else { |
256 __ CompareObjectType(r0, r4, r4, HEAP_NUMBER_TYPE); | 265 __ CompareObjectType(r3, r7, r7, HEAP_NUMBER_TYPE); |
257 __ b(eq, &heap_number); | 266 __ beq(&heap_number); |
258 // Comparing JS objects with <=, >= is complicated. | 267 // Comparing JS objects with <=, >= is complicated. |
259 if (cond != eq) { | 268 if (cond != eq) { |
260 __ cmp(r4, Operand(FIRST_SPEC_OBJECT_TYPE)); | 269 __ cmpi(r7, Operand(FIRST_SPEC_OBJECT_TYPE)); |
261 __ b(ge, slow); | 270 __ bge(slow); |
262 // Normally here we fall through to return_equal, but undefined is | 271 // Normally here we fall through to return_equal, but undefined is |
263 // special: (undefined == undefined) == true, but | 272 // special: (undefined == undefined) == true, but |
264 // (undefined <= undefined) == false! See ECMAScript 11.8.5. | 273 // (undefined <= undefined) == false! See ECMAScript 11.8.5. |
265 if (cond == le || cond == ge) { | 274 if (cond == le || cond == ge) { |
266 __ cmp(r4, Operand(ODDBALL_TYPE)); | 275 __ cmpi(r7, Operand(ODDBALL_TYPE)); |
267 __ b(ne, &return_equal); | 276 __ bne(&return_equal); |
268 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex); | 277 __ LoadRoot(r5, Heap::kUndefinedValueRootIndex); |
269 __ cmp(r0, r2); | 278 __ cmp(r3, r5); |
270 __ b(ne, &return_equal); | 279 __ bne(&return_equal); |
271 if (cond == le) { | 280 if (cond == le) { |
272 // undefined <= undefined should fail. | 281 // undefined <= undefined should fail. |
273 __ mov(r0, Operand(GREATER)); | 282 __ li(r3, Operand(GREATER)); |
274 } else { | 283 } else { |
275 // undefined >= undefined should fail. | 284 // undefined >= undefined should fail. |
276 __ mov(r0, Operand(LESS)); | 285 __ li(r3, Operand(LESS)); |
277 } | 286 } |
278 __ Ret(); | 287 __ Ret(); |
279 } | 288 } |
280 } | 289 } |
281 } | 290 } |
282 | 291 |
283 __ bind(&return_equal); | 292 __ bind(&return_equal); |
284 if (cond == lt) { | 293 if (cond == lt) { |
285 __ mov(r0, Operand(GREATER)); // Things aren't less than themselves. | 294 __ li(r3, Operand(GREATER)); // Things aren't less than themselves. |
286 } else if (cond == gt) { | 295 } else if (cond == gt) { |
287 __ mov(r0, Operand(LESS)); // Things aren't greater than themselves. | 296 __ li(r3, Operand(LESS)); // Things aren't greater than themselves. |
288 } else { | 297 } else { |
289 __ mov(r0, Operand(EQUAL)); // Things are <=, >=, ==, === themselves. | 298 __ li(r3, Operand(EQUAL)); // Things are <=, >=, ==, === themselves. |
290 } | 299 } |
291 __ Ret(); | 300 __ Ret(); |
292 | 301 |
293 // For less and greater we don't have to check for NaN since the result of | 302 // For less and greater we don't have to check for NaN since the result of |
294 // x < x is false regardless. For the others here is some code to check | 303 // x < x is false regardless. For the others here is some code to check |
295 // for NaN. | 304 // for NaN. |
296 if (cond != lt && cond != gt) { | 305 if (cond != lt && cond != gt) { |
297 __ bind(&heap_number); | 306 __ bind(&heap_number); |
298 // It is a heap number, so return non-equal if it's NaN and equal if it's | 307 // It is a heap number, so return non-equal if it's NaN and equal if it's |
299 // not NaN. | 308 // not NaN. |
300 | 309 |
301 // The representation of NaN values has all exponent bits (52..62) set, | 310 // The representation of NaN values has all exponent bits (52..62) set, |
302 // and not all mantissa bits (0..51) clear. | 311 // and not all mantissa bits (0..51) clear. |
303 // Read top bits of double representation (second word of value). | 312 // Read top bits of double representation (second word of value). |
304 __ ldr(r2, FieldMemOperand(r0, HeapNumber::kExponentOffset)); | 313 __ lwz(r5, FieldMemOperand(r3, HeapNumber::kExponentOffset)); |
305 // Test that exponent bits are all set. | 314 // Test that exponent bits are all set. |
306 __ Sbfx(r3, r2, HeapNumber::kExponentShift, HeapNumber::kExponentBits); | 315 STATIC_ASSERT(HeapNumber::kExponentMask == 0x7ff00000u); |
307 // NaNs have all-one exponents so they sign extend to -1. | 316 __ ExtractBitMask(r6, r5, HeapNumber::kExponentMask); |
308 __ cmp(r3, Operand(-1)); | 317 __ cmpli(r6, Operand(0x7ff)); |
309 __ b(ne, &return_equal); | 318 __ bne(&return_equal); |
310 | 319 |
311 // Shift out flag and all exponent bits, retaining only mantissa. | 320 // Shift out flag and all exponent bits, retaining only mantissa. |
312 __ mov(r2, Operand(r2, LSL, HeapNumber::kNonMantissaBitsInTopWord)); | 321 __ slwi(r5, r5, Operand(HeapNumber::kNonMantissaBitsInTopWord)); |
313 // Or with all low-bits of mantissa. | 322 // Or with all low-bits of mantissa. |
314 __ ldr(r3, FieldMemOperand(r0, HeapNumber::kMantissaOffset)); | 323 __ lwz(r6, FieldMemOperand(r3, HeapNumber::kMantissaOffset)); |
315 __ orr(r0, r3, Operand(r2), SetCC); | 324 __ orx(r3, r6, r5); |
316 // For equal we already have the right value in r0: Return zero (equal) | 325 __ cmpi(r3, Operand::Zero()); |
| 326 // For equal we already have the right value in r3: Return zero (equal) |
317 // if all bits in mantissa are zero (it's an Infinity) and non-zero if | 327 // if all bits in mantissa are zero (it's an Infinity) and non-zero if |
318 // not (it's a NaN). For <= and >= we need to load r0 with the failing | 328 // not (it's a NaN). For <= and >= we need to load r0 with the failing |
319 // value if it's a NaN. | 329 // value if it's a NaN. |
320 if (cond != eq) { | 330 if (cond != eq) { |
| 331 Label not_equal; |
| 332 __ bne(¬_equal); |
321 // All-zero means Infinity means equal. | 333 // All-zero means Infinity means equal. |
322 __ Ret(eq); | 334 __ Ret(); |
| 335 __ bind(¬_equal); |
323 if (cond == le) { | 336 if (cond == le) { |
324 __ mov(r0, Operand(GREATER)); // NaN <= NaN should fail. | 337 __ li(r3, Operand(GREATER)); // NaN <= NaN should fail. |
325 } else { | 338 } else { |
326 __ mov(r0, Operand(LESS)); // NaN >= NaN should fail. | 339 __ li(r3, Operand(LESS)); // NaN >= NaN should fail. |
327 } | 340 } |
328 } | 341 } |
329 __ Ret(); | 342 __ Ret(); |
330 } | 343 } |
331 // No fall through here. | 344 // No fall through here. |
332 | 345 |
333 __ bind(¬_identical); | 346 __ bind(¬_identical); |
334 } | 347 } |
335 | 348 |
336 | 349 |
337 // See comment at call site. | 350 // See comment at call site. |
338 static void EmitSmiNonsmiComparison(MacroAssembler* masm, | 351 static void EmitSmiNonsmiComparison(MacroAssembler* masm, Register lhs, |
339 Register lhs, | 352 Register rhs, Label* lhs_not_nan, |
340 Register rhs, | 353 Label* slow, bool strict) { |
341 Label* lhs_not_nan, | 354 DCHECK((lhs.is(r3) && rhs.is(r4)) || (lhs.is(r4) && rhs.is(r3))); |
342 Label* slow, | |
343 bool strict) { | |
344 DCHECK((lhs.is(r0) && rhs.is(r1)) || | |
345 (lhs.is(r1) && rhs.is(r0))); | |
346 | 355 |
347 Label rhs_is_smi; | 356 Label rhs_is_smi; |
348 __ JumpIfSmi(rhs, &rhs_is_smi); | 357 __ JumpIfSmi(rhs, &rhs_is_smi); |
349 | 358 |
350 // Lhs is a Smi. Check whether the rhs is a heap number. | 359 // Lhs is a Smi. Check whether the rhs is a heap number. |
351 __ CompareObjectType(rhs, r4, r4, HEAP_NUMBER_TYPE); | 360 __ CompareObjectType(rhs, r6, r7, HEAP_NUMBER_TYPE); |
352 if (strict) { | 361 if (strict) { |
353 // If rhs is not a number and lhs is a Smi then strict equality cannot | 362 // If rhs is not a number and lhs is a Smi then strict equality cannot |
354 // succeed. Return non-equal | 363 // succeed. Return non-equal |
355 // If rhs is r0 then there is already a non zero value in it. | 364 // If rhs is r3 then there is already a non zero value in it. |
356 if (!rhs.is(r0)) { | 365 Label skip; |
357 __ mov(r0, Operand(NOT_EQUAL), LeaveCC, ne); | 366 __ beq(&skip); |
| 367 if (!rhs.is(r3)) { |
| 368 __ mov(r3, Operand(NOT_EQUAL)); |
358 } | 369 } |
359 __ Ret(ne); | 370 __ Ret(); |
| 371 __ bind(&skip); |
360 } else { | 372 } else { |
361 // Smi compared non-strictly with a non-Smi non-heap-number. Call | 373 // Smi compared non-strictly with a non-Smi non-heap-number. Call |
362 // the runtime. | 374 // the runtime. |
363 __ b(ne, slow); | 375 __ bne(slow); |
364 } | 376 } |
365 | 377 |
366 // Lhs is a smi, rhs is a number. | 378 // Lhs is a smi, rhs is a number. |
367 // Convert lhs to a double in d7. | 379 // Convert lhs to a double in d7. |
368 __ SmiToDouble(d7, lhs); | 380 __ SmiToDouble(d7, lhs); |
369 // Load the double from rhs, tagged HeapNumber r0, to d6. | 381 // Load the double from rhs, tagged HeapNumber r3, to d6. |
370 __ vldr(d6, rhs, HeapNumber::kValueOffset - kHeapObjectTag); | 382 __ lfd(d6, FieldMemOperand(rhs, HeapNumber::kValueOffset)); |
371 | 383 |
372 // We now have both loaded as doubles but we can skip the lhs nan check | 384 // We now have both loaded as doubles but we can skip the lhs nan check |
373 // since it's a smi. | 385 // since it's a smi. |
374 __ jmp(lhs_not_nan); | 386 __ b(lhs_not_nan); |
375 | 387 |
376 __ bind(&rhs_is_smi); | 388 __ bind(&rhs_is_smi); |
377 // Rhs is a smi. Check whether the non-smi lhs is a heap number. | 389 // Rhs is a smi. Check whether the non-smi lhs is a heap number. |
378 __ CompareObjectType(lhs, r4, r4, HEAP_NUMBER_TYPE); | 390 __ CompareObjectType(lhs, r7, r7, HEAP_NUMBER_TYPE); |
379 if (strict) { | 391 if (strict) { |
380 // If lhs is not a number and rhs is a smi then strict equality cannot | 392 // If lhs is not a number and rhs is a smi then strict equality cannot |
381 // succeed. Return non-equal. | 393 // succeed. Return non-equal. |
382 // If lhs is r0 then there is already a non zero value in it. | 394 // If lhs is r3 then there is already a non zero value in it. |
383 if (!lhs.is(r0)) { | 395 Label skip; |
384 __ mov(r0, Operand(NOT_EQUAL), LeaveCC, ne); | 396 __ beq(&skip); |
| 397 if (!lhs.is(r3)) { |
| 398 __ mov(r3, Operand(NOT_EQUAL)); |
385 } | 399 } |
386 __ Ret(ne); | 400 __ Ret(); |
| 401 __ bind(&skip); |
387 } else { | 402 } else { |
388 // Smi compared non-strictly with a non-smi non-heap-number. Call | 403 // Smi compared non-strictly with a non-smi non-heap-number. Call |
389 // the runtime. | 404 // the runtime. |
390 __ b(ne, slow); | 405 __ bne(slow); |
391 } | 406 } |
392 | 407 |
393 // Rhs is a smi, lhs is a heap number. | 408 // Rhs is a smi, lhs is a heap number. |
394 // Load the double from lhs, tagged HeapNumber r1, to d7. | 409 // Load the double from lhs, tagged HeapNumber r4, to d7. |
395 __ vldr(d7, lhs, HeapNumber::kValueOffset - kHeapObjectTag); | 410 __ lfd(d7, FieldMemOperand(lhs, HeapNumber::kValueOffset)); |
396 // Convert rhs to a double in d6 . | 411 // Convert rhs to a double in d6. |
397 __ SmiToDouble(d6, rhs); | 412 __ SmiToDouble(d6, rhs); |
398 // Fall through to both_loaded_as_doubles. | 413 // Fall through to both_loaded_as_doubles. |
399 } | 414 } |
400 | 415 |
401 | 416 |
402 // See comment at call site. | 417 // See comment at call site. |
403 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm, | 418 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm, Register lhs, |
404 Register lhs, | |
405 Register rhs) { | 419 Register rhs) { |
406 DCHECK((lhs.is(r0) && rhs.is(r1)) || | 420 DCHECK((lhs.is(r3) && rhs.is(r4)) || (lhs.is(r4) && rhs.is(r3))); |
407 (lhs.is(r1) && rhs.is(r0))); | |
408 | 421 |
409 // If either operand is a JS object or an oddball value, then they are | 422 // If either operand is a JS object or an oddball value, then they are |
410 // not equal since their pointers are different. | 423 // not equal since their pointers are different. |
411 // There is no test for undetectability in strict equality. | 424 // There is no test for undetectability in strict equality. |
412 STATIC_ASSERT(LAST_TYPE == LAST_SPEC_OBJECT_TYPE); | 425 STATIC_ASSERT(LAST_TYPE == LAST_SPEC_OBJECT_TYPE); |
413 Label first_non_object; | 426 Label first_non_object; |
414 // Get the type of the first operand into r2 and compare it with | 427 // Get the type of the first operand into r5 and compare it with |
415 // FIRST_SPEC_OBJECT_TYPE. | 428 // FIRST_SPEC_OBJECT_TYPE. |
416 __ CompareObjectType(rhs, r2, r2, FIRST_SPEC_OBJECT_TYPE); | 429 __ CompareObjectType(rhs, r5, r5, FIRST_SPEC_OBJECT_TYPE); |
417 __ b(lt, &first_non_object); | 430 __ blt(&first_non_object); |
418 | 431 |
419 // Return non-zero (r0 is not zero) | 432 // Return non-zero (r3 is not zero) |
420 Label return_not_equal; | 433 Label return_not_equal; |
421 __ bind(&return_not_equal); | 434 __ bind(&return_not_equal); |
422 __ Ret(); | 435 __ Ret(); |
423 | 436 |
424 __ bind(&first_non_object); | 437 __ bind(&first_non_object); |
425 // Check for oddballs: true, false, null, undefined. | 438 // Check for oddballs: true, false, null, undefined. |
426 __ cmp(r2, Operand(ODDBALL_TYPE)); | 439 __ cmpi(r5, Operand(ODDBALL_TYPE)); |
427 __ b(eq, &return_not_equal); | 440 __ beq(&return_not_equal); |
428 | 441 |
429 __ CompareObjectType(lhs, r3, r3, FIRST_SPEC_OBJECT_TYPE); | 442 __ CompareObjectType(lhs, r6, r6, FIRST_SPEC_OBJECT_TYPE); |
430 __ b(ge, &return_not_equal); | 443 __ bge(&return_not_equal); |
431 | 444 |
432 // Check for oddballs: true, false, null, undefined. | 445 // Check for oddballs: true, false, null, undefined. |
433 __ cmp(r3, Operand(ODDBALL_TYPE)); | 446 __ cmpi(r6, Operand(ODDBALL_TYPE)); |
434 __ b(eq, &return_not_equal); | 447 __ beq(&return_not_equal); |
435 | 448 |
436 // Now that we have the types we might as well check for | 449 // Now that we have the types we might as well check for |
437 // internalized-internalized. | 450 // internalized-internalized. |
438 STATIC_ASSERT(kInternalizedTag == 0 && kStringTag == 0); | 451 STATIC_ASSERT(kInternalizedTag == 0 && kStringTag == 0); |
439 __ orr(r2, r2, Operand(r3)); | 452 __ orx(r5, r5, r6); |
440 __ tst(r2, Operand(kIsNotStringMask | kIsNotInternalizedMask)); | 453 __ andi(r0, r5, Operand(kIsNotStringMask | kIsNotInternalizedMask)); |
441 __ b(eq, &return_not_equal); | 454 __ beq(&return_not_equal, cr0); |
442 } | 455 } |
443 | 456 |
444 | 457 |
445 // See comment at call site. | 458 // See comment at call site. |
446 static void EmitCheckForTwoHeapNumbers(MacroAssembler* masm, | 459 static void EmitCheckForTwoHeapNumbers(MacroAssembler* masm, Register lhs, |
447 Register lhs, | |
448 Register rhs, | 460 Register rhs, |
449 Label* both_loaded_as_doubles, | 461 Label* both_loaded_as_doubles, |
450 Label* not_heap_numbers, | 462 Label* not_heap_numbers, Label* slow) { |
451 Label* slow) { | 463 DCHECK((lhs.is(r3) && rhs.is(r4)) || (lhs.is(r4) && rhs.is(r3))); |
452 DCHECK((lhs.is(r0) && rhs.is(r1)) || | |
453 (lhs.is(r1) && rhs.is(r0))); | |
454 | 464 |
455 __ CompareObjectType(rhs, r3, r2, HEAP_NUMBER_TYPE); | 465 __ CompareObjectType(rhs, r6, r5, HEAP_NUMBER_TYPE); |
456 __ b(ne, not_heap_numbers); | 466 __ bne(not_heap_numbers); |
457 __ ldr(r2, FieldMemOperand(lhs, HeapObject::kMapOffset)); | 467 __ LoadP(r5, FieldMemOperand(lhs, HeapObject::kMapOffset)); |
458 __ cmp(r2, r3); | 468 __ cmp(r5, r6); |
459 __ b(ne, slow); // First was a heap number, second wasn't. Go slow case. | 469 __ bne(slow); // First was a heap number, second wasn't. Go slow case. |
460 | 470 |
461 // Both are heap numbers. Load them up then jump to the code we have | 471 // Both are heap numbers. Load them up then jump to the code we have |
462 // for that. | 472 // for that. |
463 __ vldr(d6, rhs, HeapNumber::kValueOffset - kHeapObjectTag); | 473 __ lfd(d6, FieldMemOperand(rhs, HeapNumber::kValueOffset)); |
464 __ vldr(d7, lhs, HeapNumber::kValueOffset - kHeapObjectTag); | 474 __ lfd(d7, FieldMemOperand(lhs, HeapNumber::kValueOffset)); |
465 __ jmp(both_loaded_as_doubles); | 475 |
| 476 __ b(both_loaded_as_doubles); |
466 } | 477 } |
467 | 478 |
468 | 479 |
469 // Fast negative check for internalized-to-internalized equality. | 480 // Fast negative check for internalized-to-internalized equality. |
470 static void EmitCheckForInternalizedStringsOrObjects(MacroAssembler* masm, | 481 static void EmitCheckForInternalizedStringsOrObjects(MacroAssembler* masm, |
471 Register lhs, | 482 Register lhs, Register rhs, |
472 Register rhs, | |
473 Label* possible_strings, | 483 Label* possible_strings, |
474 Label* not_both_strings) { | 484 Label* not_both_strings) { |
475 DCHECK((lhs.is(r0) && rhs.is(r1)) || | 485 DCHECK((lhs.is(r3) && rhs.is(r4)) || (lhs.is(r4) && rhs.is(r3))); |
476 (lhs.is(r1) && rhs.is(r0))); | |
477 | 486 |
478 // r2 is object type of rhs. | 487 // r5 is object type of rhs. |
479 Label object_test; | 488 Label object_test; |
480 STATIC_ASSERT(kInternalizedTag == 0 && kStringTag == 0); | 489 STATIC_ASSERT(kInternalizedTag == 0 && kStringTag == 0); |
481 __ tst(r2, Operand(kIsNotStringMask)); | 490 __ andi(r0, r5, Operand(kIsNotStringMask)); |
482 __ b(ne, &object_test); | 491 __ bne(&object_test, cr0); |
483 __ tst(r2, Operand(kIsNotInternalizedMask)); | 492 __ andi(r0, r5, Operand(kIsNotInternalizedMask)); |
484 __ b(ne, possible_strings); | 493 __ bne(possible_strings, cr0); |
485 __ CompareObjectType(lhs, r3, r3, FIRST_NONSTRING_TYPE); | 494 __ CompareObjectType(lhs, r6, r6, FIRST_NONSTRING_TYPE); |
486 __ b(ge, not_both_strings); | 495 __ bge(not_both_strings); |
487 __ tst(r3, Operand(kIsNotInternalizedMask)); | 496 __ andi(r0, r6, Operand(kIsNotInternalizedMask)); |
488 __ b(ne, possible_strings); | 497 __ bne(possible_strings, cr0); |
489 | 498 |
490 // Both are internalized. We already checked they weren't the same pointer | 499 // Both are internalized. We already checked they weren't the same pointer |
491 // so they are not equal. | 500 // so they are not equal. |
492 __ mov(r0, Operand(NOT_EQUAL)); | 501 __ li(r3, Operand(NOT_EQUAL)); |
493 __ Ret(); | 502 __ Ret(); |
494 | 503 |
495 __ bind(&object_test); | 504 __ bind(&object_test); |
496 __ cmp(r2, Operand(FIRST_SPEC_OBJECT_TYPE)); | 505 __ cmpi(r5, Operand(FIRST_SPEC_OBJECT_TYPE)); |
497 __ b(lt, not_both_strings); | 506 __ blt(not_both_strings); |
498 __ CompareObjectType(lhs, r2, r3, FIRST_SPEC_OBJECT_TYPE); | 507 __ CompareObjectType(lhs, r5, r6, FIRST_SPEC_OBJECT_TYPE); |
499 __ b(lt, not_both_strings); | 508 __ blt(not_both_strings); |
500 // If both objects are undetectable, they are equal. Otherwise, they | 509 // If both objects are undetectable, they are equal. Otherwise, they |
501 // are not equal, since they are different objects and an object is not | 510 // are not equal, since they are different objects and an object is not |
502 // equal to undefined. | 511 // equal to undefined. |
503 __ ldr(r3, FieldMemOperand(rhs, HeapObject::kMapOffset)); | 512 __ LoadP(r6, FieldMemOperand(rhs, HeapObject::kMapOffset)); |
504 __ ldrb(r2, FieldMemOperand(r2, Map::kBitFieldOffset)); | 513 __ lbz(r5, FieldMemOperand(r5, Map::kBitFieldOffset)); |
505 __ ldrb(r3, FieldMemOperand(r3, Map::kBitFieldOffset)); | 514 __ lbz(r6, FieldMemOperand(r6, Map::kBitFieldOffset)); |
506 __ and_(r0, r2, Operand(r3)); | 515 __ and_(r3, r5, r6); |
507 __ and_(r0, r0, Operand(1 << Map::kIsUndetectable)); | 516 __ andi(r3, r3, Operand(1 << Map::kIsUndetectable)); |
508 __ eor(r0, r0, Operand(1 << Map::kIsUndetectable)); | 517 __ xori(r3, r3, Operand(1 << Map::kIsUndetectable)); |
509 __ Ret(); | 518 __ Ret(); |
510 } | 519 } |
511 | 520 |
512 | 521 |
513 static void CompareICStub_CheckInputType(MacroAssembler* masm, Register input, | 522 static void CompareICStub_CheckInputType(MacroAssembler* masm, Register input, |
514 Register scratch, | 523 Register scratch, |
515 CompareICState::State expected, | 524 CompareICState::State expected, |
516 Label* fail) { | 525 Label* fail) { |
517 Label ok; | 526 Label ok; |
518 if (expected == CompareICState::SMI) { | 527 if (expected == CompareICState::SMI) { |
519 __ JumpIfNotSmi(input, fail); | 528 __ JumpIfNotSmi(input, fail); |
520 } else if (expected == CompareICState::NUMBER) { | 529 } else if (expected == CompareICState::NUMBER) { |
521 __ JumpIfSmi(input, &ok); | 530 __ JumpIfSmi(input, &ok); |
522 __ CheckMap(input, scratch, Heap::kHeapNumberMapRootIndex, fail, | 531 __ CheckMap(input, scratch, Heap::kHeapNumberMapRootIndex, fail, |
523 DONT_DO_SMI_CHECK); | 532 DONT_DO_SMI_CHECK); |
524 } | 533 } |
525 // We could be strict about internalized/non-internalized here, but as long as | 534 // We could be strict about internalized/non-internalized here, but as long as |
526 // hydrogen doesn't care, the stub doesn't have to care either. | 535 // hydrogen doesn't care, the stub doesn't have to care either. |
527 __ bind(&ok); | 536 __ bind(&ok); |
528 } | 537 } |
529 | 538 |
530 | 539 |
531 // On entry r1 and r2 are the values to be compared. | 540 // On entry r4 and r5 are the values to be compared. |
532 // On exit r0 is 0, positive or negative to indicate the result of | 541 // On exit r3 is 0, positive or negative to indicate the result of |
533 // the comparison. | 542 // the comparison. |
534 void CompareICStub::GenerateGeneric(MacroAssembler* masm) { | 543 void CompareICStub::GenerateGeneric(MacroAssembler* masm) { |
535 Register lhs = r1; | 544 Register lhs = r4; |
536 Register rhs = r0; | 545 Register rhs = r3; |
537 Condition cc = GetCondition(); | 546 Condition cc = GetCondition(); |
538 | 547 |
539 Label miss; | 548 Label miss; |
540 CompareICStub_CheckInputType(masm, lhs, r2, left(), &miss); | 549 CompareICStub_CheckInputType(masm, lhs, r5, left(), &miss); |
541 CompareICStub_CheckInputType(masm, rhs, r3, right(), &miss); | 550 CompareICStub_CheckInputType(masm, rhs, r6, right(), &miss); |
542 | 551 |
543 Label slow; // Call builtin. | 552 Label slow; // Call builtin. |
544 Label not_smis, both_loaded_as_doubles, lhs_not_nan; | 553 Label not_smis, both_loaded_as_doubles, lhs_not_nan; |
545 | 554 |
546 Label not_two_smis, smi_done; | 555 Label not_two_smis, smi_done; |
547 __ orr(r2, r1, r0); | 556 __ orx(r5, r4, r3); |
548 __ JumpIfNotSmi(r2, ¬_two_smis); | 557 __ JumpIfNotSmi(r5, ¬_two_smis); |
549 __ mov(r1, Operand(r1, ASR, 1)); | 558 __ SmiUntag(r4); |
550 __ sub(r0, r1, Operand(r0, ASR, 1)); | 559 __ SmiUntag(r3); |
| 560 __ sub(r3, r4, r3); |
551 __ Ret(); | 561 __ Ret(); |
552 __ bind(¬_two_smis); | 562 __ bind(¬_two_smis); |
553 | 563 |
554 // NOTICE! This code is only reached after a smi-fast-case check, so | 564 // NOTICE! This code is only reached after a smi-fast-case check, so |
555 // it is certain that at least one operand isn't a smi. | 565 // it is certain that at least one operand isn't a smi. |
556 | 566 |
557 // Handle the case where the objects are identical. Either returns the answer | 567 // Handle the case where the objects are identical. Either returns the answer |
558 // or goes to slow. Only falls through if the objects were not identical. | 568 // or goes to slow. Only falls through if the objects were not identical. |
559 EmitIdenticalObjectComparison(masm, &slow, cc); | 569 EmitIdenticalObjectComparison(masm, &slow, cc); |
560 | 570 |
561 // If either is a Smi (we know that not both are), then they can only | 571 // If either is a Smi (we know that not both are), then they can only |
562 // be strictly equal if the other is a HeapNumber. | 572 // be strictly equal if the other is a HeapNumber. |
563 STATIC_ASSERT(kSmiTag == 0); | 573 STATIC_ASSERT(kSmiTag == 0); |
564 DCHECK_EQ(0, Smi::FromInt(0)); | 574 DCHECK_EQ(0, Smi::FromInt(0)); |
565 __ and_(r2, lhs, Operand(rhs)); | 575 __ and_(r5, lhs, rhs); |
566 __ JumpIfNotSmi(r2, ¬_smis); | 576 __ JumpIfNotSmi(r5, ¬_smis); |
567 // One operand is a smi. EmitSmiNonsmiComparison generates code that can: | 577 // One operand is a smi. EmitSmiNonsmiComparison generates code that can: |
568 // 1) Return the answer. | 578 // 1) Return the answer. |
569 // 2) Go to slow. | 579 // 2) Go to slow. |
570 // 3) Fall through to both_loaded_as_doubles. | 580 // 3) Fall through to both_loaded_as_doubles. |
571 // 4) Jump to lhs_not_nan. | 581 // 4) Jump to lhs_not_nan. |
572 // In cases 3 and 4 we have found out we were dealing with a number-number | 582 // In cases 3 and 4 we have found out we were dealing with a number-number |
573 // comparison. If VFP3 is supported the double values of the numbers have | 583 // comparison. The double values of the numbers have been loaded |
574 // been loaded into d7 and d6. Otherwise, the double values have been loaded | 584 // into d7 and d6. |
575 // into r0, r1, r2, and r3. | |
576 EmitSmiNonsmiComparison(masm, lhs, rhs, &lhs_not_nan, &slow, strict()); | 585 EmitSmiNonsmiComparison(masm, lhs, rhs, &lhs_not_nan, &slow, strict()); |
577 | 586 |
578 __ bind(&both_loaded_as_doubles); | 587 __ bind(&both_loaded_as_doubles); |
579 // The arguments have been converted to doubles and stored in d6 and d7, if | 588 // The arguments have been converted to doubles and stored in d6 and d7 |
580 // VFP3 is supported, or in r0, r1, r2, and r3. | |
581 __ bind(&lhs_not_nan); | 589 __ bind(&lhs_not_nan); |
582 Label no_nan; | 590 Label no_nan; |
583 // ARMv7 VFP3 instructions to implement double precision comparison. | 591 __ fcmpu(d7, d6); |
584 __ VFPCompareAndSetFlags(d7, d6); | 592 |
585 Label nan; | 593 Label nan, equal, less_than; |
586 __ b(vs, &nan); | 594 __ bunordered(&nan); |
587 __ mov(r0, Operand(EQUAL), LeaveCC, eq); | 595 __ beq(&equal); |
588 __ mov(r0, Operand(LESS), LeaveCC, lt); | 596 __ blt(&less_than); |
589 __ mov(r0, Operand(GREATER), LeaveCC, gt); | 597 __ li(r3, Operand(GREATER)); |
| 598 __ Ret(); |
| 599 __ bind(&equal); |
| 600 __ li(r3, Operand(EQUAL)); |
| 601 __ Ret(); |
| 602 __ bind(&less_than); |
| 603 __ li(r3, Operand(LESS)); |
590 __ Ret(); | 604 __ Ret(); |
591 | 605 |
592 __ bind(&nan); | 606 __ bind(&nan); |
593 // If one of the sides was a NaN then the v flag is set. Load r0 with | 607 // If one of the sides was a NaN then the v flag is set. Load r3 with |
594 // whatever it takes to make the comparison fail, since comparisons with NaN | 608 // whatever it takes to make the comparison fail, since comparisons with NaN |
595 // always fail. | 609 // always fail. |
596 if (cc == lt || cc == le) { | 610 if (cc == lt || cc == le) { |
597 __ mov(r0, Operand(GREATER)); | 611 __ li(r3, Operand(GREATER)); |
598 } else { | 612 } else { |
599 __ mov(r0, Operand(LESS)); | 613 __ li(r3, Operand(LESS)); |
600 } | 614 } |
601 __ Ret(); | 615 __ Ret(); |
602 | 616 |
603 __ bind(¬_smis); | 617 __ bind(¬_smis); |
604 // At this point we know we are dealing with two different objects, | 618 // At this point we know we are dealing with two different objects, |
605 // and neither of them is a Smi. The objects are in rhs_ and lhs_. | 619 // and neither of them is a Smi. The objects are in rhs_ and lhs_. |
606 if (strict()) { | 620 if (strict()) { |
607 // This returns non-equal for some object types, or falls through if it | 621 // This returns non-equal for some object types, or falls through if it |
608 // was not lucky. | 622 // was not lucky. |
609 EmitStrictTwoHeapObjectCompare(masm, lhs, rhs); | 623 EmitStrictTwoHeapObjectCompare(masm, lhs, rhs); |
610 } | 624 } |
611 | 625 |
612 Label check_for_internalized_strings; | 626 Label check_for_internalized_strings; |
613 Label flat_string_check; | 627 Label flat_string_check; |
614 // Check for heap-number-heap-number comparison. Can jump to slow case, | 628 // Check for heap-number-heap-number comparison. Can jump to slow case, |
615 // or load both doubles into r0, r1, r2, r3 and jump to the code that handles | 629 // or load both doubles into r3, r4, r5, r6 and jump to the code that handles |
616 // that case. If the inputs are not doubles then jumps to | 630 // that case. If the inputs are not doubles then jumps to |
617 // check_for_internalized_strings. | 631 // check_for_internalized_strings. |
618 // In this case r2 will contain the type of rhs_. Never falls through. | 632 // In this case r5 will contain the type of rhs_. Never falls through. |
619 EmitCheckForTwoHeapNumbers(masm, | 633 EmitCheckForTwoHeapNumbers(masm, lhs, rhs, &both_loaded_as_doubles, |
620 lhs, | |
621 rhs, | |
622 &both_loaded_as_doubles, | |
623 &check_for_internalized_strings, | 634 &check_for_internalized_strings, |
624 &flat_string_check); | 635 &flat_string_check); |
625 | 636 |
626 __ bind(&check_for_internalized_strings); | 637 __ bind(&check_for_internalized_strings); |
627 // In the strict case the EmitStrictTwoHeapObjectCompare already took care of | 638 // In the strict case the EmitStrictTwoHeapObjectCompare already took care of |
628 // internalized strings. | 639 // internalized strings. |
629 if (cc == eq && !strict()) { | 640 if (cc == eq && !strict()) { |
630 // Returns an answer for two internalized strings or two detectable objects. | 641 // Returns an answer for two internalized strings or two detectable objects. |
631 // Otherwise jumps to string case or not both strings case. | 642 // Otherwise jumps to string case or not both strings case. |
632 // Assumes that r2 is the type of rhs_ on entry. | 643 // Assumes that r5 is the type of rhs_ on entry. |
633 EmitCheckForInternalizedStringsOrObjects( | 644 EmitCheckForInternalizedStringsOrObjects(masm, lhs, rhs, &flat_string_check, |
634 masm, lhs, rhs, &flat_string_check, &slow); | 645 &slow); |
635 } | 646 } |
636 | 647 |
637 // Check for both being sequential one-byte strings, | 648 // Check for both being sequential one-byte strings, |
638 // and inline if that is the case. | 649 // and inline if that is the case. |
639 __ bind(&flat_string_check); | 650 __ bind(&flat_string_check); |
640 | 651 |
641 __ JumpIfNonSmisNotBothSequentialOneByteStrings(lhs, rhs, r2, r3, &slow); | 652 __ JumpIfNonSmisNotBothSequentialOneByteStrings(lhs, rhs, r5, r6, &slow); |
642 | 653 |
643 __ IncrementCounter(isolate()->counters()->string_compare_native(), 1, r2, | 654 __ IncrementCounter(isolate()->counters()->string_compare_native(), 1, r5, |
644 r3); | 655 r6); |
645 if (cc == eq) { | 656 if (cc == eq) { |
646 StringHelper::GenerateFlatOneByteStringEquals(masm, lhs, rhs, r2, r3, r4); | 657 StringHelper::GenerateFlatOneByteStringEquals(masm, lhs, rhs, r5, r6); |
647 } else { | 658 } else { |
648 StringHelper::GenerateCompareFlatOneByteStrings(masm, lhs, rhs, r2, r3, r4, | 659 StringHelper::GenerateCompareFlatOneByteStrings(masm, lhs, rhs, r5, r6, r7); |
649 r5); | |
650 } | 660 } |
651 // Never falls through to here. | 661 // Never falls through to here. |
652 | 662 |
653 __ bind(&slow); | 663 __ bind(&slow); |
654 | 664 |
655 __ Push(lhs, rhs); | 665 __ Push(lhs, rhs); |
656 // Figure out which native to call and setup the arguments. | 666 // Figure out which native to call and setup the arguments. |
657 Builtins::JavaScript native; | 667 Builtins::JavaScript native; |
658 if (cc == eq) { | 668 if (cc == eq) { |
659 native = strict() ? Builtins::STRICT_EQUALS : Builtins::EQUALS; | 669 native = strict() ? Builtins::STRICT_EQUALS : Builtins::EQUALS; |
660 } else { | 670 } else { |
661 native = Builtins::COMPARE; | 671 native = Builtins::COMPARE; |
662 int ncr; // NaN compare result | 672 int ncr; // NaN compare result |
663 if (cc == lt || cc == le) { | 673 if (cc == lt || cc == le) { |
664 ncr = GREATER; | 674 ncr = GREATER; |
665 } else { | 675 } else { |
666 DCHECK(cc == gt || cc == ge); // remaining cases | 676 DCHECK(cc == gt || cc == ge); // remaining cases |
667 ncr = LESS; | 677 ncr = LESS; |
668 } | 678 } |
669 __ mov(r0, Operand(Smi::FromInt(ncr))); | 679 __ LoadSmiLiteral(r3, Smi::FromInt(ncr)); |
670 __ push(r0); | 680 __ push(r3); |
671 } | 681 } |
672 | 682 |
673 // Call the native; it returns -1 (less), 0 (equal), or 1 (greater) | 683 // Call the native; it returns -1 (less), 0 (equal), or 1 (greater) |
674 // tagged as a small integer. | 684 // tagged as a small integer. |
675 __ InvokeBuiltin(native, JUMP_FUNCTION); | 685 __ InvokeBuiltin(native, JUMP_FUNCTION); |
676 | 686 |
677 __ bind(&miss); | 687 __ bind(&miss); |
678 GenerateMiss(masm); | 688 GenerateMiss(masm); |
679 } | 689 } |
680 | 690 |
681 | 691 |
682 void StoreBufferOverflowStub::Generate(MacroAssembler* masm) { | 692 void StoreBufferOverflowStub::Generate(MacroAssembler* masm) { |
683 // We don't allow a GC during a store buffer overflow so there is no need to | 693 // We don't allow a GC during a store buffer overflow so there is no need to |
684 // store the registers in any particular way, but we do have to store and | 694 // store the registers in any particular way, but we do have to store and |
685 // restore them. | 695 // restore them. |
686 __ stm(db_w, sp, kCallerSaved | lr.bit()); | 696 __ mflr(r0); |
687 | 697 __ MultiPush(kJSCallerSaved | r0.bit()); |
688 const Register scratch = r1; | |
689 | |
690 if (save_doubles()) { | 698 if (save_doubles()) { |
691 __ SaveFPRegs(sp, scratch); | 699 __ SaveFPRegs(sp, 0, DoubleRegister::kNumVolatileRegisters); |
692 } | 700 } |
693 const int argument_count = 1; | 701 const int argument_count = 1; |
694 const int fp_argument_count = 0; | 702 const int fp_argument_count = 0; |
| 703 const Register scratch = r4; |
695 | 704 |
696 AllowExternalCallThatCantCauseGC scope(masm); | 705 AllowExternalCallThatCantCauseGC scope(masm); |
697 __ PrepareCallCFunction(argument_count, fp_argument_count, scratch); | 706 __ PrepareCallCFunction(argument_count, fp_argument_count, scratch); |
698 __ mov(r0, Operand(ExternalReference::isolate_address(isolate()))); | 707 __ mov(r3, Operand(ExternalReference::isolate_address(isolate()))); |
699 __ CallCFunction( | 708 __ CallCFunction(ExternalReference::store_buffer_overflow_function(isolate()), |
700 ExternalReference::store_buffer_overflow_function(isolate()), | 709 argument_count); |
701 argument_count); | |
702 if (save_doubles()) { | 710 if (save_doubles()) { |
703 __ RestoreFPRegs(sp, scratch); | 711 __ RestoreFPRegs(sp, 0, DoubleRegister::kNumVolatileRegisters); |
704 } | 712 } |
705 __ ldm(ia_w, sp, kCallerSaved | pc.bit()); // Also pop pc to get Ret(0). | 713 __ MultiPop(kJSCallerSaved | r0.bit()); |
| 714 __ mtlr(r0); |
| 715 __ Ret(); |
| 716 } |
| 717 |
| 718 |
| 719 void StoreRegistersStateStub::Generate(MacroAssembler* masm) { |
| 720 __ PushSafepointRegisters(); |
| 721 __ blr(); |
| 722 } |
| 723 |
| 724 |
| 725 void RestoreRegistersStateStub::Generate(MacroAssembler* masm) { |
| 726 __ PopSafepointRegisters(); |
| 727 __ blr(); |
706 } | 728 } |
707 | 729 |
708 | 730 |
709 void MathPowStub::Generate(MacroAssembler* masm) { | 731 void MathPowStub::Generate(MacroAssembler* masm) { |
710 const Register base = r1; | 732 const Register base = r4; |
711 const Register exponent = MathPowTaggedDescriptor::exponent(); | 733 const Register exponent = MathPowTaggedDescriptor::exponent(); |
712 DCHECK(exponent.is(r2)); | 734 DCHECK(exponent.is(r5)); |
713 const Register heapnumbermap = r5; | 735 const Register heapnumbermap = r8; |
714 const Register heapnumber = r0; | 736 const Register heapnumber = r3; |
715 const DwVfpRegister double_base = d0; | 737 const DoubleRegister double_base = d1; |
716 const DwVfpRegister double_exponent = d1; | 738 const DoubleRegister double_exponent = d2; |
717 const DwVfpRegister double_result = d2; | 739 const DoubleRegister double_result = d3; |
718 const DwVfpRegister double_scratch = d3; | 740 const DoubleRegister double_scratch = d0; |
719 const SwVfpRegister single_scratch = s6; | 741 const Register scratch = r11; |
720 const Register scratch = r9; | 742 const Register scratch2 = r10; |
721 const Register scratch2 = r4; | |
722 | 743 |
723 Label call_runtime, done, int_exponent; | 744 Label call_runtime, done, int_exponent; |
724 if (exponent_type() == ON_STACK) { | 745 if (exponent_type() == ON_STACK) { |
725 Label base_is_smi, unpack_exponent; | 746 Label base_is_smi, unpack_exponent; |
726 // The exponent and base are supplied as arguments on the stack. | 747 // The exponent and base are supplied as arguments on the stack. |
727 // This can only happen if the stub is called from non-optimized code. | 748 // This can only happen if the stub is called from non-optimized code. |
728 // Load input parameters from stack to double registers. | 749 // Load input parameters from stack to double registers. |
729 __ ldr(base, MemOperand(sp, 1 * kPointerSize)); | 750 __ LoadP(base, MemOperand(sp, 1 * kPointerSize)); |
730 __ ldr(exponent, MemOperand(sp, 0 * kPointerSize)); | 751 __ LoadP(exponent, MemOperand(sp, 0 * kPointerSize)); |
731 | 752 |
732 __ LoadRoot(heapnumbermap, Heap::kHeapNumberMapRootIndex); | 753 __ LoadRoot(heapnumbermap, Heap::kHeapNumberMapRootIndex); |
733 | 754 |
734 __ UntagAndJumpIfSmi(scratch, base, &base_is_smi); | 755 __ UntagAndJumpIfSmi(scratch, base, &base_is_smi); |
735 __ ldr(scratch, FieldMemOperand(base, JSObject::kMapOffset)); | 756 __ LoadP(scratch, FieldMemOperand(base, JSObject::kMapOffset)); |
736 __ cmp(scratch, heapnumbermap); | 757 __ cmp(scratch, heapnumbermap); |
737 __ b(ne, &call_runtime); | 758 __ bne(&call_runtime); |
738 | 759 |
739 __ vldr(double_base, FieldMemOperand(base, HeapNumber::kValueOffset)); | 760 __ lfd(double_base, FieldMemOperand(base, HeapNumber::kValueOffset)); |
740 __ jmp(&unpack_exponent); | 761 __ b(&unpack_exponent); |
741 | 762 |
742 __ bind(&base_is_smi); | 763 __ bind(&base_is_smi); |
743 __ vmov(single_scratch, scratch); | 764 __ ConvertIntToDouble(scratch, double_base); |
744 __ vcvt_f64_s32(double_base, single_scratch); | |
745 __ bind(&unpack_exponent); | 765 __ bind(&unpack_exponent); |
746 | 766 |
747 __ UntagAndJumpIfSmi(scratch, exponent, &int_exponent); | 767 __ UntagAndJumpIfSmi(scratch, exponent, &int_exponent); |
| 768 __ LoadP(scratch, FieldMemOperand(exponent, JSObject::kMapOffset)); |
| 769 __ cmp(scratch, heapnumbermap); |
| 770 __ bne(&call_runtime); |
748 | 771 |
749 __ ldr(scratch, FieldMemOperand(exponent, JSObject::kMapOffset)); | 772 __ lfd(double_exponent, |
750 __ cmp(scratch, heapnumbermap); | 773 FieldMemOperand(exponent, HeapNumber::kValueOffset)); |
751 __ b(ne, &call_runtime); | |
752 __ vldr(double_exponent, | |
753 FieldMemOperand(exponent, HeapNumber::kValueOffset)); | |
754 } else if (exponent_type() == TAGGED) { | 774 } else if (exponent_type() == TAGGED) { |
755 // Base is already in double_base. | 775 // Base is already in double_base. |
756 __ UntagAndJumpIfSmi(scratch, exponent, &int_exponent); | 776 __ UntagAndJumpIfSmi(scratch, exponent, &int_exponent); |
757 | 777 |
758 __ vldr(double_exponent, | 778 __ lfd(double_exponent, |
759 FieldMemOperand(exponent, HeapNumber::kValueOffset)); | 779 FieldMemOperand(exponent, HeapNumber::kValueOffset)); |
760 } | 780 } |
761 | 781 |
762 if (exponent_type() != INTEGER) { | 782 if (exponent_type() != INTEGER) { |
763 Label int_exponent_convert; | |
764 // Detect integer exponents stored as double. | 783 // Detect integer exponents stored as double. |
765 __ vcvt_u32_f64(single_scratch, double_exponent); | 784 __ TryDoubleToInt32Exact(scratch, double_exponent, scratch2, |
766 // We do not check for NaN or Infinity here because comparing numbers on | 785 double_scratch); |
767 // ARM correctly distinguishes NaNs. We end up calling the built-in. | 786 __ beq(&int_exponent); |
768 __ vcvt_f64_u32(double_scratch, single_scratch); | |
769 __ VFPCompareAndSetFlags(double_scratch, double_exponent); | |
770 __ b(eq, &int_exponent_convert); | |
771 | 787 |
772 if (exponent_type() == ON_STACK) { | 788 if (exponent_type() == ON_STACK) { |
773 // Detect square root case. Crankshaft detects constant +/-0.5 at | 789 // Detect square root case. Crankshaft detects constant +/-0.5 at |
774 // compile time and uses DoMathPowHalf instead. We then skip this check | 790 // compile time and uses DoMathPowHalf instead. We then skip this check |
775 // for non-constant cases of +/-0.5 as these hardly occur. | 791 // for non-constant cases of +/-0.5 as these hardly occur. |
776 Label not_plus_half; | 792 Label not_plus_half, not_minus_inf1, not_minus_inf2; |
777 | 793 |
778 // Test for 0.5. | 794 // Test for 0.5. |
779 __ vmov(double_scratch, 0.5, scratch); | 795 __ LoadDoubleLiteral(double_scratch, 0.5, scratch); |
780 __ VFPCompareAndSetFlags(double_exponent, double_scratch); | 796 __ fcmpu(double_exponent, double_scratch); |
781 __ b(ne, ¬_plus_half); | 797 __ bne(¬_plus_half); |
782 | 798 |
783 // Calculates square root of base. Check for the special case of | 799 // Calculates square root of base. Check for the special case of |
784 // Math.pow(-Infinity, 0.5) == Infinity (ECMA spec, 15.8.2.13). | 800 // Math.pow(-Infinity, 0.5) == Infinity (ECMA spec, 15.8.2.13). |
785 __ vmov(double_scratch, -V8_INFINITY, scratch); | 801 __ LoadDoubleLiteral(double_scratch, -V8_INFINITY, scratch); |
786 __ VFPCompareAndSetFlags(double_base, double_scratch); | 802 __ fcmpu(double_base, double_scratch); |
787 __ vneg(double_result, double_scratch, eq); | 803 __ bne(¬_minus_inf1); |
788 __ b(eq, &done); | 804 __ fneg(double_result, double_scratch); |
| 805 __ b(&done); |
| 806 __ bind(¬_minus_inf1); |
789 | 807 |
790 // Add +0 to convert -0 to +0. | 808 // Add +0 to convert -0 to +0. |
791 __ vadd(double_scratch, double_base, kDoubleRegZero); | 809 __ fadd(double_scratch, double_base, kDoubleRegZero); |
792 __ vsqrt(double_result, double_scratch); | 810 __ fsqrt(double_result, double_scratch); |
793 __ jmp(&done); | 811 __ b(&done); |
794 | 812 |
795 __ bind(¬_plus_half); | 813 __ bind(¬_plus_half); |
796 __ vmov(double_scratch, -0.5, scratch); | 814 __ LoadDoubleLiteral(double_scratch, -0.5, scratch); |
797 __ VFPCompareAndSetFlags(double_exponent, double_scratch); | 815 __ fcmpu(double_exponent, double_scratch); |
798 __ b(ne, &call_runtime); | 816 __ bne(&call_runtime); |
799 | 817 |
800 // Calculates square root of base. Check for the special case of | 818 // Calculates square root of base. Check for the special case of |
801 // Math.pow(-Infinity, -0.5) == 0 (ECMA spec, 15.8.2.13). | 819 // Math.pow(-Infinity, -0.5) == 0 (ECMA spec, 15.8.2.13). |
802 __ vmov(double_scratch, -V8_INFINITY, scratch); | 820 __ LoadDoubleLiteral(double_scratch, -V8_INFINITY, scratch); |
803 __ VFPCompareAndSetFlags(double_base, double_scratch); | 821 __ fcmpu(double_base, double_scratch); |
804 __ vmov(double_result, kDoubleRegZero, eq); | 822 __ bne(¬_minus_inf2); |
805 __ b(eq, &done); | 823 __ fmr(double_result, kDoubleRegZero); |
| 824 __ b(&done); |
| 825 __ bind(¬_minus_inf2); |
806 | 826 |
807 // Add +0 to convert -0 to +0. | 827 // Add +0 to convert -0 to +0. |
808 __ vadd(double_scratch, double_base, kDoubleRegZero); | 828 __ fadd(double_scratch, double_base, kDoubleRegZero); |
809 __ vmov(double_result, 1.0, scratch); | 829 __ LoadDoubleLiteral(double_result, 1.0, scratch); |
810 __ vsqrt(double_scratch, double_scratch); | 830 __ fsqrt(double_scratch, double_scratch); |
811 __ vdiv(double_result, double_result, double_scratch); | 831 __ fdiv(double_result, double_result, double_scratch); |
812 __ jmp(&done); | 832 __ b(&done); |
813 } | 833 } |
814 | 834 |
815 __ push(lr); | 835 __ mflr(r0); |
| 836 __ push(r0); |
816 { | 837 { |
817 AllowExternalCallThatCantCauseGC scope(masm); | 838 AllowExternalCallThatCantCauseGC scope(masm); |
818 __ PrepareCallCFunction(0, 2, scratch); | 839 __ PrepareCallCFunction(0, 2, scratch); |
819 __ MovToFloatParameters(double_base, double_exponent); | 840 __ MovToFloatParameters(double_base, double_exponent); |
820 __ CallCFunction( | 841 __ CallCFunction( |
821 ExternalReference::power_double_double_function(isolate()), | 842 ExternalReference::power_double_double_function(isolate()), 0, 2); |
822 0, 2); | |
823 } | 843 } |
824 __ pop(lr); | 844 __ pop(r0); |
| 845 __ mtlr(r0); |
825 __ MovFromFloatResult(double_result); | 846 __ MovFromFloatResult(double_result); |
826 __ jmp(&done); | 847 __ b(&done); |
827 | |
828 __ bind(&int_exponent_convert); | |
829 __ vcvt_u32_f64(single_scratch, double_exponent); | |
830 __ vmov(scratch, single_scratch); | |
831 } | 848 } |
832 | 849 |
833 // Calculate power with integer exponent. | 850 // Calculate power with integer exponent. |
834 __ bind(&int_exponent); | 851 __ bind(&int_exponent); |
835 | 852 |
836 // Get two copies of exponent in the registers scratch and exponent. | 853 // Get two copies of exponent in the registers scratch and exponent. |
837 if (exponent_type() == INTEGER) { | 854 if (exponent_type() == INTEGER) { |
838 __ mov(scratch, exponent); | 855 __ mr(scratch, exponent); |
839 } else { | 856 } else { |
840 // Exponent has previously been stored into scratch as untagged integer. | 857 // Exponent has previously been stored into scratch as untagged integer. |
841 __ mov(exponent, scratch); | 858 __ mr(exponent, scratch); |
842 } | 859 } |
843 __ vmov(double_scratch, double_base); // Back up base. | 860 __ fmr(double_scratch, double_base); // Back up base. |
844 __ vmov(double_result, 1.0, scratch2); | 861 __ li(scratch2, Operand(1)); |
| 862 __ ConvertIntToDouble(scratch2, double_result); |
845 | 863 |
846 // Get absolute value of exponent. | 864 // Get absolute value of exponent. |
847 __ cmp(scratch, Operand::Zero()); | 865 Label positive_exponent; |
848 __ mov(scratch2, Operand::Zero(), LeaveCC, mi); | 866 __ cmpi(scratch, Operand::Zero()); |
849 __ sub(scratch, scratch2, scratch, LeaveCC, mi); | 867 __ bge(&positive_exponent); |
| 868 __ neg(scratch, scratch); |
| 869 __ bind(&positive_exponent); |
850 | 870 |
851 Label while_true; | 871 Label while_true, no_carry, loop_end; |
852 __ bind(&while_true); | 872 __ bind(&while_true); |
853 __ mov(scratch, Operand(scratch, ASR, 1), SetCC); | 873 __ andi(scratch2, scratch, Operand(1)); |
854 __ vmul(double_result, double_result, double_scratch, cs); | 874 __ beq(&no_carry, cr0); |
855 __ vmul(double_scratch, double_scratch, double_scratch, ne); | 875 __ fmul(double_result, double_result, double_scratch); |
856 __ b(ne, &while_true); | 876 __ bind(&no_carry); |
| 877 __ ShiftRightArithImm(scratch, scratch, 1, SetRC); |
| 878 __ beq(&loop_end, cr0); |
| 879 __ fmul(double_scratch, double_scratch, double_scratch); |
| 880 __ b(&while_true); |
| 881 __ bind(&loop_end); |
857 | 882 |
858 __ cmp(exponent, Operand::Zero()); | 883 __ cmpi(exponent, Operand::Zero()); |
859 __ b(ge, &done); | 884 __ bge(&done); |
860 __ vmov(double_scratch, 1.0, scratch); | 885 |
861 __ vdiv(double_result, double_scratch, double_result); | 886 __ li(scratch2, Operand(1)); |
| 887 __ ConvertIntToDouble(scratch2, double_scratch); |
| 888 __ fdiv(double_result, double_scratch, double_result); |
862 // Test whether result is zero. Bail out to check for subnormal result. | 889 // Test whether result is zero. Bail out to check for subnormal result. |
863 // Due to subnormals, x^-y == (1/x)^y does not hold in all cases. | 890 // Due to subnormals, x^-y == (1/x)^y does not hold in all cases. |
864 __ VFPCompareAndSetFlags(double_result, 0.0); | 891 __ fcmpu(double_result, kDoubleRegZero); |
865 __ b(ne, &done); | 892 __ bne(&done); |
866 // double_exponent may not containe the exponent value if the input was a | 893 // double_exponent may not containe the exponent value if the input was a |
867 // smi. We set it with exponent value before bailing out. | 894 // smi. We set it with exponent value before bailing out. |
868 __ vmov(single_scratch, exponent); | 895 __ ConvertIntToDouble(exponent, double_exponent); |
869 __ vcvt_f64_s32(double_exponent, single_scratch); | |
870 | 896 |
871 // Returning or bailing out. | 897 // Returning or bailing out. |
872 Counters* counters = isolate()->counters(); | 898 Counters* counters = isolate()->counters(); |
873 if (exponent_type() == ON_STACK) { | 899 if (exponent_type() == ON_STACK) { |
874 // The arguments are still on the stack. | 900 // The arguments are still on the stack. |
875 __ bind(&call_runtime); | 901 __ bind(&call_runtime); |
876 __ TailCallRuntime(Runtime::kMathPowRT, 2, 1); | 902 __ TailCallRuntime(Runtime::kMathPowRT, 2, 1); |
877 | 903 |
878 // The stub is called from non-optimized code, which expects the result | 904 // The stub is called from non-optimized code, which expects the result |
879 // as heap number in exponent. | 905 // as heap number in exponent. |
880 __ bind(&done); | 906 __ bind(&done); |
881 __ AllocateHeapNumber( | 907 __ AllocateHeapNumber(heapnumber, scratch, scratch2, heapnumbermap, |
882 heapnumber, scratch, scratch2, heapnumbermap, &call_runtime); | 908 &call_runtime); |
883 __ vstr(double_result, | 909 __ stfd(double_result, |
884 FieldMemOperand(heapnumber, HeapNumber::kValueOffset)); | 910 FieldMemOperand(heapnumber, HeapNumber::kValueOffset)); |
885 DCHECK(heapnumber.is(r0)); | 911 DCHECK(heapnumber.is(r3)); |
886 __ IncrementCounter(counters->math_pow(), 1, scratch, scratch2); | 912 __ IncrementCounter(counters->math_pow(), 1, scratch, scratch2); |
887 __ Ret(2); | 913 __ Ret(2); |
888 } else { | 914 } else { |
889 __ push(lr); | 915 __ mflr(r0); |
| 916 __ push(r0); |
890 { | 917 { |
891 AllowExternalCallThatCantCauseGC scope(masm); | 918 AllowExternalCallThatCantCauseGC scope(masm); |
892 __ PrepareCallCFunction(0, 2, scratch); | 919 __ PrepareCallCFunction(0, 2, scratch); |
893 __ MovToFloatParameters(double_base, double_exponent); | 920 __ MovToFloatParameters(double_base, double_exponent); |
894 __ CallCFunction( | 921 __ CallCFunction( |
895 ExternalReference::power_double_double_function(isolate()), | 922 ExternalReference::power_double_double_function(isolate()), 0, 2); |
896 0, 2); | |
897 } | 923 } |
898 __ pop(lr); | 924 __ pop(r0); |
| 925 __ mtlr(r0); |
899 __ MovFromFloatResult(double_result); | 926 __ MovFromFloatResult(double_result); |
900 | 927 |
901 __ bind(&done); | 928 __ bind(&done); |
902 __ IncrementCounter(counters->math_pow(), 1, scratch, scratch2); | 929 __ IncrementCounter(counters->math_pow(), 1, scratch, scratch2); |
903 __ Ret(); | 930 __ Ret(); |
904 } | 931 } |
905 } | 932 } |
906 | 933 |
907 | 934 |
908 bool CEntryStub::NeedsImmovableCode() { | 935 bool CEntryStub::NeedsImmovableCode() { return true; } |
909 return true; | |
910 } | |
911 | 936 |
912 | 937 |
913 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { | 938 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { |
914 CEntryStub::GenerateAheadOfTime(isolate); | 939 CEntryStub::GenerateAheadOfTime(isolate); |
| 940 // WriteInt32ToHeapNumberStub::GenerateFixedRegStubsAheadOfTime(isolate); |
915 StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime(isolate); | 941 StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime(isolate); |
916 StubFailureTrampolineStub::GenerateAheadOfTime(isolate); | 942 StubFailureTrampolineStub::GenerateAheadOfTime(isolate); |
917 ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); | 943 ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); |
918 CreateAllocationSiteStub::GenerateAheadOfTime(isolate); | 944 CreateAllocationSiteStub::GenerateAheadOfTime(isolate); |
919 BinaryOpICStub::GenerateAheadOfTime(isolate); | 945 BinaryOpICStub::GenerateAheadOfTime(isolate); |
| 946 StoreRegistersStateStub::GenerateAheadOfTime(isolate); |
| 947 RestoreRegistersStateStub::GenerateAheadOfTime(isolate); |
920 BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(isolate); | 948 BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(isolate); |
921 } | 949 } |
922 | 950 |
923 | 951 |
| 952 void StoreRegistersStateStub::GenerateAheadOfTime(Isolate* isolate) { |
| 953 StoreRegistersStateStub stub(isolate); |
| 954 stub.GetCode(); |
| 955 } |
| 956 |
| 957 |
| 958 void RestoreRegistersStateStub::GenerateAheadOfTime(Isolate* isolate) { |
| 959 RestoreRegistersStateStub stub(isolate); |
| 960 stub.GetCode(); |
| 961 } |
| 962 |
| 963 |
924 void CodeStub::GenerateFPStubs(Isolate* isolate) { | 964 void CodeStub::GenerateFPStubs(Isolate* isolate) { |
925 // Generate if not already in cache. | 965 // Generate if not already in cache. |
926 SaveFPRegsMode mode = kSaveFPRegs; | 966 SaveFPRegsMode mode = kSaveFPRegs; |
927 CEntryStub(isolate, 1, mode).GetCode(); | 967 CEntryStub(isolate, 1, mode).GetCode(); |
928 StoreBufferOverflowStub(isolate, mode).GetCode(); | 968 StoreBufferOverflowStub(isolate, mode).GetCode(); |
929 isolate->set_fp_stubs_generated(true); | 969 isolate->set_fp_stubs_generated(true); |
930 } | 970 } |
931 | 971 |
932 | 972 |
933 void CEntryStub::GenerateAheadOfTime(Isolate* isolate) { | 973 void CEntryStub::GenerateAheadOfTime(Isolate* isolate) { |
934 CEntryStub stub(isolate, 1, kDontSaveFPRegs); | 974 CEntryStub stub(isolate, 1, kDontSaveFPRegs); |
935 stub.GetCode(); | 975 stub.GetCode(); |
936 } | 976 } |
937 | 977 |
938 | 978 |
939 void CEntryStub::Generate(MacroAssembler* masm) { | 979 void CEntryStub::Generate(MacroAssembler* masm) { |
940 // Called from JavaScript; parameters are on stack as if calling JS function. | 980 // Called from JavaScript; parameters are on stack as if calling JS function. |
941 // r0: number of arguments including receiver | 981 // r3: number of arguments including receiver |
942 // r1: pointer to builtin function | 982 // r4: pointer to builtin function |
943 // fp: frame pointer (restored after C call) | 983 // fp: frame pointer (restored after C call) |
944 // sp: stack pointer (restored as callee's sp after C call) | 984 // sp: stack pointer (restored as callee's sp after C call) |
945 // cp: current context (C callee-saved) | 985 // cp: current context (C callee-saved) |
946 | 986 |
947 ProfileEntryHookStub::MaybeCallEntryHook(masm); | 987 ProfileEntryHookStub::MaybeCallEntryHook(masm); |
948 | 988 |
949 __ mov(r5, Operand(r1)); | 989 __ mr(r15, r4); |
950 | 990 |
951 // Compute the argv pointer in a callee-saved register. | 991 // Compute the argv pointer. |
952 __ add(r1, sp, Operand(r0, LSL, kPointerSizeLog2)); | 992 __ ShiftLeftImm(r4, r3, Operand(kPointerSizeLog2)); |
953 __ sub(r1, r1, Operand(kPointerSize)); | 993 __ add(r4, r4, sp); |
| 994 __ subi(r4, r4, Operand(kPointerSize)); |
954 | 995 |
955 // Enter the exit frame that transitions from JavaScript to C++. | 996 // Enter the exit frame that transitions from JavaScript to C++. |
956 FrameScope scope(masm, StackFrame::MANUAL); | 997 FrameScope scope(masm, StackFrame::MANUAL); |
957 __ EnterExitFrame(save_doubles()); | 998 |
| 999 // Need at least one extra slot for return address location. |
| 1000 int arg_stack_space = 1; |
| 1001 |
| 1002 // PPC LINUX ABI: |
| 1003 #if V8_TARGET_ARCH_PPC64 && !ABI_RETURNS_OBJECT_PAIRS_IN_REGS |
| 1004 // Pass buffer for return value on stack if necessary |
| 1005 if (result_size() > 1) { |
| 1006 DCHECK_EQ(2, result_size()); |
| 1007 arg_stack_space += 2; |
| 1008 } |
| 1009 #endif |
| 1010 |
| 1011 __ EnterExitFrame(save_doubles(), arg_stack_space); |
958 | 1012 |
959 // Store a copy of argc in callee-saved registers for later. | 1013 // Store a copy of argc in callee-saved registers for later. |
960 __ mov(r4, Operand(r0)); | 1014 __ mr(r14, r3); |
961 | 1015 |
962 // r0, r4: number of arguments including receiver (C callee-saved) | 1016 // r3, r14: number of arguments including receiver (C callee-saved) |
963 // r1: pointer to the first argument (C callee-saved) | 1017 // r4: pointer to the first argument |
964 // r5: pointer to builtin function (C callee-saved) | 1018 // r15: pointer to builtin function (C callee-saved) |
965 | 1019 |
966 // Result returned in r0 or r0+r1 by default. | 1020 // Result returned in registers or stack, depending on result size and ABI. |
967 | 1021 |
968 #if V8_HOST_ARCH_ARM | 1022 Register isolate_reg = r5; |
969 int frame_alignment = MacroAssembler::ActivationFrameAlignment(); | 1023 #if V8_TARGET_ARCH_PPC64 && !ABI_RETURNS_OBJECT_PAIRS_IN_REGS |
970 int frame_alignment_mask = frame_alignment - 1; | 1024 if (result_size() > 1) { |
971 if (FLAG_debug_code) { | 1025 // The return value is 16-byte non-scalar value. |
972 if (frame_alignment > kPointerSize) { | 1026 // Use frame storage reserved by calling function to pass return |
973 Label alignment_as_expected; | 1027 // buffer as implicit first argument. |
974 DCHECK(base::bits::IsPowerOfTwo32(frame_alignment)); | 1028 __ mr(r5, r4); |
975 __ tst(sp, Operand(frame_alignment_mask)); | 1029 __ mr(r4, r3); |
976 __ b(eq, &alignment_as_expected); | 1030 __ addi(r3, sp, Operand((kStackFrameExtraParamSlot + 1) * kPointerSize)); |
977 // Don't use Check here, as it will call Runtime_Abort re-entering here. | 1031 isolate_reg = r6; |
978 __ stop("Unexpected alignment"); | |
979 __ bind(&alignment_as_expected); | |
980 } | |
981 } | 1032 } |
982 #endif | 1033 #endif |
983 | 1034 |
984 // Call C built-in. | 1035 // Call C built-in. |
985 // r0 = argc, r1 = argv | 1036 __ mov(isolate_reg, Operand(ExternalReference::isolate_address(isolate()))); |
986 __ mov(r2, Operand(ExternalReference::isolate_address(isolate()))); | 1037 |
| 1038 #if ABI_USES_FUNCTION_DESCRIPTORS && !defined(USE_SIMULATOR) |
| 1039 // Native AIX/PPC64 Linux use a function descriptor. |
| 1040 __ LoadP(ToRegister(ABI_TOC_REGISTER), MemOperand(r15, kPointerSize)); |
| 1041 __ LoadP(ip, MemOperand(r15, 0)); // Instruction address |
| 1042 Register target = ip; |
| 1043 #elif ABI_TOC_ADDRESSABILITY_VIA_IP |
| 1044 __ Move(ip, r15); |
| 1045 Register target = ip; |
| 1046 #else |
| 1047 Register target = r15; |
| 1048 #endif |
987 | 1049 |
988 // To let the GC traverse the return address of the exit frames, we need to | 1050 // To let the GC traverse the return address of the exit frames, we need to |
989 // know where the return address is. The CEntryStub is unmovable, so | 1051 // know where the return address is. The CEntryStub is unmovable, so |
990 // we can store the address on the stack to be able to find it again and | 1052 // we can store the address on the stack to be able to find it again and |
991 // we never have to restore it, because it will not change. | 1053 // we never have to restore it, because it will not change. |
992 // Compute the return address in lr to return to after the jump below. Pc is | 1054 // Compute the return address in lr to return to after the jump below. Pc is |
993 // already at '+ 8' from the current instruction but return is after three | 1055 // already at '+ 8' from the current instruction but return is after three |
994 // instructions so add another 4 to pc to get the return address. | 1056 // instructions so add another 4 to pc to get the return address. |
995 { | 1057 { |
996 // Prevent literal pool emission before return address. | 1058 Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm); |
997 Assembler::BlockConstPoolScope block_const_pool(masm); | 1059 Label here; |
998 __ add(lr, pc, Operand(4)); | 1060 __ b(&here, SetLK); |
999 __ str(lr, MemOperand(sp, 0)); | 1061 __ bind(&here); |
1000 __ Call(r5); | 1062 __ mflr(r8); |
1001 } | 1063 |
1002 | 1064 // Constant used below is dependent on size of Call() macro instructions |
1003 __ VFPEnsureFPSCRState(r2); | 1065 __ addi(r0, r8, Operand(20)); |
| 1066 |
| 1067 __ StoreP(r0, MemOperand(sp, kStackFrameExtraParamSlot * kPointerSize)); |
| 1068 __ Call(target); |
| 1069 } |
| 1070 |
| 1071 #if V8_TARGET_ARCH_PPC64 && !ABI_RETURNS_OBJECT_PAIRS_IN_REGS |
| 1072 // If return value is on the stack, pop it to registers. |
| 1073 if (result_size() > 1) { |
| 1074 __ LoadP(r4, MemOperand(r3, kPointerSize)); |
| 1075 __ LoadP(r3, MemOperand(r3)); |
| 1076 } |
| 1077 #endif |
1004 | 1078 |
1005 // Runtime functions should not return 'the hole'. Allowing it to escape may | 1079 // Runtime functions should not return 'the hole'. Allowing it to escape may |
1006 // lead to crashes in the IC code later. | 1080 // lead to crashes in the IC code later. |
1007 if (FLAG_debug_code) { | 1081 if (FLAG_debug_code) { |
1008 Label okay; | 1082 Label okay; |
1009 __ CompareRoot(r0, Heap::kTheHoleValueRootIndex); | 1083 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex); |
1010 __ b(ne, &okay); | 1084 __ bne(&okay); |
1011 __ stop("The hole escaped"); | 1085 __ stop("The hole escaped"); |
1012 __ bind(&okay); | 1086 __ bind(&okay); |
1013 } | 1087 } |
1014 | 1088 |
1015 // Check result for exception sentinel. | 1089 // Check result for exception sentinel. |
1016 Label exception_returned; | 1090 Label exception_returned; |
1017 __ CompareRoot(r0, Heap::kExceptionRootIndex); | 1091 __ CompareRoot(r3, Heap::kExceptionRootIndex); |
1018 __ b(eq, &exception_returned); | 1092 __ beq(&exception_returned); |
1019 | 1093 |
1020 ExternalReference pending_exception_address( | 1094 ExternalReference pending_exception_address(Isolate::kPendingExceptionAddress, |
1021 Isolate::kPendingExceptionAddress, isolate()); | 1095 isolate()); |
1022 | 1096 |
1023 // Check that there is no pending exception, otherwise we | 1097 // Check that there is no pending exception, otherwise we |
1024 // should have returned the exception sentinel. | 1098 // should have returned the exception sentinel. |
1025 if (FLAG_debug_code) { | 1099 if (FLAG_debug_code) { |
1026 Label okay; | 1100 Label okay; |
1027 __ mov(r2, Operand(pending_exception_address)); | 1101 __ mov(r5, Operand(pending_exception_address)); |
1028 __ ldr(r2, MemOperand(r2)); | 1102 __ LoadP(r5, MemOperand(r5)); |
1029 __ CompareRoot(r2, Heap::kTheHoleValueRootIndex); | 1103 __ CompareRoot(r5, Heap::kTheHoleValueRootIndex); |
1030 // Cannot use check here as it attempts to generate call into runtime. | 1104 // Cannot use check here as it attempts to generate call into runtime. |
1031 __ b(eq, &okay); | 1105 __ beq(&okay); |
1032 __ stop("Unexpected pending exception"); | 1106 __ stop("Unexpected pending exception"); |
1033 __ bind(&okay); | 1107 __ bind(&okay); |
1034 } | 1108 } |
1035 | 1109 |
1036 // Exit C frame and return. | 1110 // Exit C frame and return. |
1037 // r0:r1: result | 1111 // r3:r4: result |
1038 // sp: stack pointer | 1112 // sp: stack pointer |
1039 // fp: frame pointer | 1113 // fp: frame pointer |
1040 // Callee-saved register r4 still holds argc. | 1114 // r14: still holds argc (callee-saved). |
1041 __ LeaveExitFrame(save_doubles(), r4, true); | 1115 __ LeaveExitFrame(save_doubles(), r14, true); |
1042 __ mov(pc, lr); | 1116 __ blr(); |
1043 | 1117 |
1044 // Handling of exception. | 1118 // Handling of exception. |
1045 __ bind(&exception_returned); | 1119 __ bind(&exception_returned); |
1046 | 1120 |
1047 // Retrieve the pending exception. | 1121 // Retrieve the pending exception. |
1048 __ mov(r2, Operand(pending_exception_address)); | 1122 __ mov(r5, Operand(pending_exception_address)); |
1049 __ ldr(r0, MemOperand(r2)); | 1123 __ LoadP(r3, MemOperand(r5)); |
1050 | 1124 |
1051 // Clear the pending exception. | 1125 // Clear the pending exception. |
1052 __ LoadRoot(r3, Heap::kTheHoleValueRootIndex); | 1126 __ LoadRoot(r6, Heap::kTheHoleValueRootIndex); |
1053 __ str(r3, MemOperand(r2)); | 1127 __ StoreP(r6, MemOperand(r5)); |
1054 | 1128 |
1055 // Special handling of termination exceptions which are uncatchable | 1129 // Special handling of termination exceptions which are uncatchable |
1056 // by javascript code. | 1130 // by javascript code. |
1057 Label throw_termination_exception; | 1131 Label throw_termination_exception; |
1058 __ CompareRoot(r0, Heap::kTerminationExceptionRootIndex); | 1132 __ CompareRoot(r3, Heap::kTerminationExceptionRootIndex); |
1059 __ b(eq, &throw_termination_exception); | 1133 __ beq(&throw_termination_exception); |
1060 | 1134 |
1061 // Handle normal exception. | 1135 // Handle normal exception. |
1062 __ Throw(r0); | 1136 __ Throw(r3); |
1063 | 1137 |
1064 __ bind(&throw_termination_exception); | 1138 __ bind(&throw_termination_exception); |
1065 __ ThrowUncatchable(r0); | 1139 __ ThrowUncatchable(r3); |
1066 } | 1140 } |
1067 | 1141 |
1068 | 1142 |
1069 void JSEntryStub::Generate(MacroAssembler* masm) { | 1143 void JSEntryStub::Generate(MacroAssembler* masm) { |
1070 // r0: code entry | 1144 // r3: code entry |
1071 // r1: function | 1145 // r4: function |
1072 // r2: receiver | 1146 // r5: receiver |
1073 // r3: argc | 1147 // r6: argc |
1074 // [sp+0]: argv | 1148 // [sp+0]: argv |
1075 | 1149 |
1076 Label invoke, handler_entry, exit; | 1150 Label invoke, handler_entry, exit; |
1077 | 1151 |
| 1152 // Called from C |
| 1153 #if ABI_USES_FUNCTION_DESCRIPTORS |
| 1154 __ function_descriptor(); |
| 1155 #endif |
| 1156 |
1078 ProfileEntryHookStub::MaybeCallEntryHook(masm); | 1157 ProfileEntryHookStub::MaybeCallEntryHook(masm); |
1079 | 1158 |
1080 // Called from C, so do not pop argc and args on exit (preserve sp) | 1159 // PPC LINUX ABI: |
1081 // No need to save register-passed args | 1160 // preserve LR in pre-reserved slot in caller's frame |
1082 // Save callee-saved registers (incl. cp and fp), sp, and lr | 1161 __ mflr(r0); |
1083 __ stm(db_w, sp, kCalleeSaved | lr.bit()); | 1162 __ StoreP(r0, MemOperand(sp, kStackFrameLRSlot * kPointerSize)); |
1084 | 1163 |
1085 // Save callee-saved vfp registers. | 1164 // Save callee saved registers on the stack. |
1086 __ vstm(db_w, sp, kFirstCalleeSavedDoubleReg, kLastCalleeSavedDoubleReg); | 1165 __ MultiPush(kCalleeSaved); |
1087 // Set up the reserved register for 0.0. | 1166 |
1088 __ vmov(kDoubleRegZero, 0.0); | 1167 // Floating point regs FPR0 - FRP13 are volatile |
1089 __ VFPEnsureFPSCRState(r4); | 1168 // FPR14-FPR31 are non-volatile, but sub-calls will save them for us |
1090 | 1169 |
1091 // Get address of argv, see stm above. | 1170 // int offset_to_argv = kPointerSize * 22; // matches (22*4) above |
1092 // r0: code entry | 1171 // __ lwz(r7, MemOperand(sp, offset_to_argv)); |
1093 // r1: function | |
1094 // r2: receiver | |
1095 // r3: argc | |
1096 | |
1097 // Set up argv in r4. | |
1098 int offset_to_argv = (kNumCalleeSaved + 1) * kPointerSize; | |
1099 offset_to_argv += kNumDoubleCalleeSaved * kDoubleSize; | |
1100 __ ldr(r4, MemOperand(sp, offset_to_argv)); | |
1101 | 1172 |
1102 // Push a frame with special values setup to mark it as an entry frame. | 1173 // Push a frame with special values setup to mark it as an entry frame. |
1103 // r0: code entry | 1174 // r3: code entry |
1104 // r1: function | 1175 // r4: function |
1105 // r2: receiver | 1176 // r5: receiver |
1106 // r3: argc | 1177 // r6: argc |
1107 // r4: argv | 1178 // r7: argv |
| 1179 __ li(r0, Operand(-1)); // Push a bad frame pointer to fail if it is used. |
| 1180 __ push(r0); |
| 1181 #if V8_OOL_CONSTANT_POOL |
| 1182 __ mov(kConstantPoolRegister, |
| 1183 Operand(isolate()->factory()->empty_constant_pool_array())); |
| 1184 __ push(kConstantPoolRegister); |
| 1185 #endif |
1108 int marker = type(); | 1186 int marker = type(); |
1109 if (FLAG_enable_ool_constant_pool) { | 1187 __ LoadSmiLiteral(r0, Smi::FromInt(marker)); |
1110 __ mov(r8, Operand(isolate()->factory()->empty_constant_pool_array())); | 1188 __ push(r0); |
1111 } | 1189 __ push(r0); |
1112 __ mov(r7, Operand(Smi::FromInt(marker))); | 1190 // Save copies of the top frame descriptor on the stack. |
1113 __ mov(r6, Operand(Smi::FromInt(marker))); | 1191 __ mov(r8, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); |
1114 __ mov(r5, | 1192 __ LoadP(r0, MemOperand(r8)); |
1115 Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); | 1193 __ push(r0); |
1116 __ ldr(r5, MemOperand(r5)); | |
1117 __ mov(ip, Operand(-1)); // Push a bad frame pointer to fail if it is used. | |
1118 __ stm(db_w, sp, r5.bit() | r6.bit() | r7.bit() | | |
1119 (FLAG_enable_ool_constant_pool ? r8.bit() : 0) | | |
1120 ip.bit()); | |
1121 | 1194 |
1122 // Set up frame pointer for the frame to be pushed. | 1195 // Set up frame pointer for the frame to be pushed. |
1123 __ add(fp, sp, Operand(-EntryFrameConstants::kCallerFPOffset)); | 1196 __ addi(fp, sp, Operand(-EntryFrameConstants::kCallerFPOffset)); |
1124 | 1197 |
1125 // If this is the outermost JS call, set js_entry_sp value. | 1198 // If this is the outermost JS call, set js_entry_sp value. |
1126 Label non_outermost_js; | 1199 Label non_outermost_js; |
1127 ExternalReference js_entry_sp(Isolate::kJSEntrySPAddress, isolate()); | 1200 ExternalReference js_entry_sp(Isolate::kJSEntrySPAddress, isolate()); |
1128 __ mov(r5, Operand(ExternalReference(js_entry_sp))); | 1201 __ mov(r8, Operand(ExternalReference(js_entry_sp))); |
1129 __ ldr(r6, MemOperand(r5)); | 1202 __ LoadP(r9, MemOperand(r8)); |
1130 __ cmp(r6, Operand::Zero()); | 1203 __ cmpi(r9, Operand::Zero()); |
1131 __ b(ne, &non_outermost_js); | 1204 __ bne(&non_outermost_js); |
1132 __ str(fp, MemOperand(r5)); | 1205 __ StoreP(fp, MemOperand(r8)); |
1133 __ mov(ip, Operand(Smi::FromInt(StackFrame::OUTERMOST_JSENTRY_FRAME))); | 1206 __ LoadSmiLiteral(ip, Smi::FromInt(StackFrame::OUTERMOST_JSENTRY_FRAME)); |
1134 Label cont; | 1207 Label cont; |
1135 __ b(&cont); | 1208 __ b(&cont); |
1136 __ bind(&non_outermost_js); | 1209 __ bind(&non_outermost_js); |
1137 __ mov(ip, Operand(Smi::FromInt(StackFrame::INNER_JSENTRY_FRAME))); | 1210 __ LoadSmiLiteral(ip, Smi::FromInt(StackFrame::INNER_JSENTRY_FRAME)); |
1138 __ bind(&cont); | 1211 __ bind(&cont); |
1139 __ push(ip); | 1212 __ push(ip); // frame-type |
1140 | 1213 |
1141 // Jump to a faked try block that does the invoke, with a faked catch | 1214 // Jump to a faked try block that does the invoke, with a faked catch |
1142 // block that sets the pending exception. | 1215 // block that sets the pending exception. |
1143 __ jmp(&invoke); | 1216 __ b(&invoke); |
1144 | 1217 |
1145 // Block literal pool emission whilst taking the position of the handler | 1218 __ bind(&handler_entry); |
1146 // entry. This avoids making the assumption that literal pools are always | 1219 handler_offset_ = handler_entry.pos(); |
1147 // emitted after an instruction is emitted, rather than before. | 1220 // Caught exception: Store result (exception) in the pending exception |
1148 { | 1221 // field in the JSEnv and return a failure sentinel. Coming in here the |
1149 Assembler::BlockConstPoolScope block_const_pool(masm); | 1222 // fp will be invalid because the PushTryHandler below sets it to 0 to |
1150 __ bind(&handler_entry); | 1223 // signal the existence of the JSEntry frame. |
1151 handler_offset_ = handler_entry.pos(); | 1224 __ mov(ip, Operand(ExternalReference(Isolate::kPendingExceptionAddress, |
1152 // Caught exception: Store result (exception) in the pending exception | 1225 isolate()))); |
1153 // field in the JSEnv and return a failure sentinel. Coming in here the | 1226 |
1154 // fp will be invalid because the PushTryHandler below sets it to 0 to | 1227 __ StoreP(r3, MemOperand(ip)); |
1155 // signal the existence of the JSEntry frame. | 1228 __ LoadRoot(r3, Heap::kExceptionRootIndex); |
1156 __ mov(ip, Operand(ExternalReference(Isolate::kPendingExceptionAddress, | |
1157 isolate()))); | |
1158 } | |
1159 __ str(r0, MemOperand(ip)); | |
1160 __ LoadRoot(r0, Heap::kExceptionRootIndex); | |
1161 __ b(&exit); | 1229 __ b(&exit); |
1162 | 1230 |
1163 // Invoke: Link this frame into the handler chain. There's only one | 1231 // Invoke: Link this frame into the handler chain. There's only one |
1164 // handler block in this code object, so its index is 0. | 1232 // handler block in this code object, so its index is 0. |
1165 __ bind(&invoke); | 1233 __ bind(&invoke); |
1166 // Must preserve r0-r4, r5-r6 are available. | 1234 // Must preserve r0-r4, r5-r7 are available. (needs update for PPC) |
1167 __ PushTryHandler(StackHandler::JS_ENTRY, 0); | 1235 __ PushTryHandler(StackHandler::JS_ENTRY, 0); |
1168 // If an exception not caught by another handler occurs, this handler | 1236 // If an exception not caught by another handler occurs, this handler |
1169 // returns control to the code after the bl(&invoke) above, which | 1237 // returns control to the code after the b(&invoke) above, which |
1170 // restores all kCalleeSaved registers (including cp and fp) to their | 1238 // restores all kCalleeSaved registers (including cp and fp) to their |
1171 // saved values before returning a failure to C. | 1239 // saved values before returning a failure to C. |
1172 | 1240 |
1173 // Clear any pending exceptions. | 1241 // Clear any pending exceptions. |
1174 __ mov(r5, Operand(isolate()->factory()->the_hole_value())); | 1242 __ mov(r8, Operand(isolate()->factory()->the_hole_value())); |
1175 __ mov(ip, Operand(ExternalReference(Isolate::kPendingExceptionAddress, | 1243 __ mov(ip, Operand(ExternalReference(Isolate::kPendingExceptionAddress, |
1176 isolate()))); | 1244 isolate()))); |
1177 __ str(r5, MemOperand(ip)); | 1245 __ StoreP(r8, MemOperand(ip)); |
1178 | 1246 |
1179 // Invoke the function by calling through JS entry trampoline builtin. | 1247 // Invoke the function by calling through JS entry trampoline builtin. |
1180 // Notice that we cannot store a reference to the trampoline code directly in | 1248 // Notice that we cannot store a reference to the trampoline code directly in |
1181 // this stub, because runtime stubs are not traversed when doing GC. | 1249 // this stub, because runtime stubs are not traversed when doing GC. |
1182 | 1250 |
1183 // Expected registers by Builtins::JSEntryTrampoline | 1251 // Expected registers by Builtins::JSEntryTrampoline |
1184 // r0: code entry | 1252 // r3: code entry |
1185 // r1: function | 1253 // r4: function |
1186 // r2: receiver | 1254 // r5: receiver |
1187 // r3: argc | 1255 // r6: argc |
1188 // r4: argv | 1256 // r7: argv |
1189 if (type() == StackFrame::ENTRY_CONSTRUCT) { | 1257 if (type() == StackFrame::ENTRY_CONSTRUCT) { |
1190 ExternalReference construct_entry(Builtins::kJSConstructEntryTrampoline, | 1258 ExternalReference construct_entry(Builtins::kJSConstructEntryTrampoline, |
1191 isolate()); | 1259 isolate()); |
1192 __ mov(ip, Operand(construct_entry)); | 1260 __ mov(ip, Operand(construct_entry)); |
1193 } else { | 1261 } else { |
1194 ExternalReference entry(Builtins::kJSEntryTrampoline, isolate()); | 1262 ExternalReference entry(Builtins::kJSEntryTrampoline, isolate()); |
1195 __ mov(ip, Operand(entry)); | 1263 __ mov(ip, Operand(entry)); |
1196 } | 1264 } |
1197 __ ldr(ip, MemOperand(ip)); // deref address | 1265 __ LoadP(ip, MemOperand(ip)); // deref address |
1198 __ add(ip, ip, Operand(Code::kHeaderSize - kHeapObjectTag)); | |
1199 | 1266 |
1200 // Branch and link to JSEntryTrampoline. | 1267 // Branch and link to JSEntryTrampoline. |
1201 __ Call(ip); | 1268 // the address points to the start of the code object, skip the header |
| 1269 __ addi(ip, ip, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 1270 __ mtctr(ip); |
| 1271 __ bctrl(); // make the call |
1202 | 1272 |
1203 // Unlink this frame from the handler chain. | 1273 // Unlink this frame from the handler chain. |
1204 __ PopTryHandler(); | 1274 __ PopTryHandler(); |
1205 | 1275 |
1206 __ bind(&exit); // r0 holds result | 1276 __ bind(&exit); // r3 holds result |
1207 // Check if the current stack frame is marked as the outermost JS frame. | 1277 // Check if the current stack frame is marked as the outermost JS frame. |
1208 Label non_outermost_js_2; | 1278 Label non_outermost_js_2; |
1209 __ pop(r5); | 1279 __ pop(r8); |
1210 __ cmp(r5, Operand(Smi::FromInt(StackFrame::OUTERMOST_JSENTRY_FRAME))); | 1280 __ CmpSmiLiteral(r8, Smi::FromInt(StackFrame::OUTERMOST_JSENTRY_FRAME), r0); |
1211 __ b(ne, &non_outermost_js_2); | 1281 __ bne(&non_outermost_js_2); |
1212 __ mov(r6, Operand::Zero()); | 1282 __ mov(r9, Operand::Zero()); |
1213 __ mov(r5, Operand(ExternalReference(js_entry_sp))); | 1283 __ mov(r8, Operand(ExternalReference(js_entry_sp))); |
1214 __ str(r6, MemOperand(r5)); | 1284 __ StoreP(r9, MemOperand(r8)); |
1215 __ bind(&non_outermost_js_2); | 1285 __ bind(&non_outermost_js_2); |
1216 | 1286 |
1217 // Restore the top frame descriptors from the stack. | 1287 // Restore the top frame descriptors from the stack. |
1218 __ pop(r3); | 1288 __ pop(r6); |
1219 __ mov(ip, | 1289 __ mov(ip, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); |
1220 Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); | 1290 __ StoreP(r6, MemOperand(ip)); |
1221 __ str(r3, MemOperand(ip)); | |
1222 | 1291 |
1223 // Reset the stack to the callee saved registers. | 1292 // Reset the stack to the callee saved registers. |
1224 __ add(sp, sp, Operand(-EntryFrameConstants::kCallerFPOffset)); | 1293 __ addi(sp, sp, Operand(-EntryFrameConstants::kCallerFPOffset)); |
1225 | 1294 |
1226 // Restore callee-saved registers and return. | 1295 // Restore callee-saved registers and return. |
1227 #ifdef DEBUG | 1296 #ifdef DEBUG |
1228 if (FLAG_debug_code) { | 1297 if (FLAG_debug_code) { |
1229 __ mov(lr, Operand(pc)); | 1298 Label here; |
| 1299 __ b(&here, SetLK); |
| 1300 __ bind(&here); |
1230 } | 1301 } |
1231 #endif | 1302 #endif |
1232 | 1303 |
1233 // Restore callee-saved vfp registers. | 1304 __ MultiPop(kCalleeSaved); |
1234 __ vldm(ia_w, sp, kFirstCalleeSavedDoubleReg, kLastCalleeSavedDoubleReg); | |
1235 | 1305 |
1236 __ ldm(ia_w, sp, kCalleeSaved | pc.bit()); | 1306 __ LoadP(r0, MemOperand(sp, kStackFrameLRSlot * kPointerSize)); |
| 1307 __ mtctr(r0); |
| 1308 __ bctr(); |
1237 } | 1309 } |
1238 | 1310 |
1239 | 1311 |
1240 // Uses registers r0 to r4. | 1312 // Uses registers r3 to r7. |
1241 // Expected input (depending on whether args are in registers or on the stack): | 1313 // Expected input (depending on whether args are in registers or on the stack): |
1242 // * object: r0 or at sp + 1 * kPointerSize. | 1314 // * object: r3 or at sp + 1 * kPointerSize. |
1243 // * function: r1 or at sp. | 1315 // * function: r4 or at sp. |
1244 // | 1316 // |
1245 // An inlined call site may have been generated before calling this stub. | 1317 // An inlined call site may have been generated before calling this stub. |
1246 // In this case the offset to the inline sites to patch are passed in r5 and r6. | 1318 // In this case the offset to the inline site to patch is passed in r8. |
1247 // (See LCodeGen::DoInstanceOfKnownGlobal) | 1319 // (See LCodeGen::DoInstanceOfKnownGlobal) |
1248 void InstanceofStub::Generate(MacroAssembler* masm) { | 1320 void InstanceofStub::Generate(MacroAssembler* masm) { |
1249 // Call site inlining and patching implies arguments in registers. | 1321 // Call site inlining and patching implies arguments in registers. |
1250 DCHECK(HasArgsInRegisters() || !HasCallSiteInlineCheck()); | 1322 DCHECK(HasArgsInRegisters() || !HasCallSiteInlineCheck()); |
1251 | 1323 |
1252 // Fixed register usage throughout the stub: | 1324 // Fixed register usage throughout the stub: |
1253 const Register object = r0; // Object (lhs). | 1325 const Register object = r3; // Object (lhs). |
1254 Register map = r3; // Map of the object. | 1326 Register map = r6; // Map of the object. |
1255 const Register function = r1; // Function (rhs). | 1327 const Register function = r4; // Function (rhs). |
1256 const Register prototype = r4; // Prototype of the function. | 1328 const Register prototype = r7; // Prototype of the function. |
1257 const Register scratch = r2; | 1329 const Register inline_site = r9; |
| 1330 const Register scratch = r5; |
| 1331 Register scratch3 = no_reg; |
| 1332 |
| 1333 // delta = mov + unaligned LoadP + cmp + bne |
| 1334 #if V8_TARGET_ARCH_PPC64 |
| 1335 const int32_t kDeltaToLoadBoolResult = |
| 1336 (Assembler::kMovInstructions + 4) * Assembler::kInstrSize; |
| 1337 #else |
| 1338 const int32_t kDeltaToLoadBoolResult = |
| 1339 (Assembler::kMovInstructions + 3) * Assembler::kInstrSize; |
| 1340 #endif |
1258 | 1341 |
1259 Label slow, loop, is_instance, is_not_instance, not_js_object; | 1342 Label slow, loop, is_instance, is_not_instance, not_js_object; |
1260 | 1343 |
1261 if (!HasArgsInRegisters()) { | 1344 if (!HasArgsInRegisters()) { |
1262 __ ldr(object, MemOperand(sp, 1 * kPointerSize)); | 1345 __ LoadP(object, MemOperand(sp, 1 * kPointerSize)); |
1263 __ ldr(function, MemOperand(sp, 0)); | 1346 __ LoadP(function, MemOperand(sp, 0)); |
1264 } | 1347 } |
1265 | 1348 |
1266 // Check that the left hand is a JS object and load map. | 1349 // Check that the left hand is a JS object and load map. |
1267 __ JumpIfSmi(object, ¬_js_object); | 1350 __ JumpIfSmi(object, ¬_js_object); |
1268 __ IsObjectJSObjectType(object, map, scratch, ¬_js_object); | 1351 __ IsObjectJSObjectType(object, map, scratch, ¬_js_object); |
1269 | 1352 |
1270 // If there is a call site cache don't look in the global cache, but do the | 1353 // If there is a call site cache don't look in the global cache, but do the |
1271 // real lookup and update the call site cache. | 1354 // real lookup and update the call site cache. |
1272 if (!HasCallSiteInlineCheck() && !ReturnTrueFalseObject()) { | 1355 if (!HasCallSiteInlineCheck() && !ReturnTrueFalseObject()) { |
1273 Label miss; | 1356 Label miss; |
1274 __ CompareRoot(function, Heap::kInstanceofCacheFunctionRootIndex); | 1357 __ CompareRoot(function, Heap::kInstanceofCacheFunctionRootIndex); |
1275 __ b(ne, &miss); | 1358 __ bne(&miss); |
1276 __ CompareRoot(map, Heap::kInstanceofCacheMapRootIndex); | 1359 __ CompareRoot(map, Heap::kInstanceofCacheMapRootIndex); |
1277 __ b(ne, &miss); | 1360 __ bne(&miss); |
1278 __ LoadRoot(r0, Heap::kInstanceofCacheAnswerRootIndex); | 1361 __ LoadRoot(r3, Heap::kInstanceofCacheAnswerRootIndex); |
1279 __ Ret(HasArgsInRegisters() ? 0 : 2); | 1362 __ Ret(HasArgsInRegisters() ? 0 : 2); |
1280 | 1363 |
1281 __ bind(&miss); | 1364 __ bind(&miss); |
1282 } | 1365 } |
1283 | 1366 |
1284 // Get the prototype of the function. | 1367 // Get the prototype of the function. |
1285 __ TryGetFunctionPrototype(function, prototype, scratch, &slow, true); | 1368 __ TryGetFunctionPrototype(function, prototype, scratch, &slow, true); |
1286 | 1369 |
1287 // Check that the function prototype is a JS object. | 1370 // Check that the function prototype is a JS object. |
1288 __ JumpIfSmi(prototype, &slow); | 1371 __ JumpIfSmi(prototype, &slow); |
1289 __ IsObjectJSObjectType(prototype, scratch, scratch, &slow); | 1372 __ IsObjectJSObjectType(prototype, scratch, scratch, &slow); |
1290 | 1373 |
1291 // Update the global instanceof or call site inlined cache with the current | 1374 // Update the global instanceof or call site inlined cache with the current |
1292 // map and function. The cached answer will be set when it is known below. | 1375 // map and function. The cached answer will be set when it is known below. |
1293 if (!HasCallSiteInlineCheck()) { | 1376 if (!HasCallSiteInlineCheck()) { |
1294 __ StoreRoot(function, Heap::kInstanceofCacheFunctionRootIndex); | 1377 __ StoreRoot(function, Heap::kInstanceofCacheFunctionRootIndex); |
1295 __ StoreRoot(map, Heap::kInstanceofCacheMapRootIndex); | 1378 __ StoreRoot(map, Heap::kInstanceofCacheMapRootIndex); |
1296 } else { | 1379 } else { |
1297 DCHECK(HasArgsInRegisters()); | 1380 DCHECK(HasArgsInRegisters()); |
1298 // Patch the (relocated) inlined map check. | 1381 // Patch the (relocated) inlined map check. |
1299 | 1382 |
1300 // The map_load_offset was stored in r5 | 1383 // The offset was stored in r8 |
1301 // (See LCodeGen::DoDeferredLInstanceOfKnownGlobal). | 1384 // (See LCodeGen::DoDeferredLInstanceOfKnownGlobal). |
1302 const Register map_load_offset = r5; | 1385 const Register offset = r8; |
1303 __ sub(r9, lr, map_load_offset); | 1386 __ mflr(inline_site); |
1304 // Get the map location in r5 and patch it. | 1387 __ sub(inline_site, inline_site, offset); |
1305 __ GetRelocatedValueLocation(r9, map_load_offset, scratch); | 1388 // Get the map location in r8 and patch it. |
1306 __ ldr(map_load_offset, MemOperand(map_load_offset)); | 1389 __ GetRelocatedValue(inline_site, offset, scratch); |
1307 __ str(map, FieldMemOperand(map_load_offset, Cell::kValueOffset)); | 1390 __ StoreP(map, FieldMemOperand(offset, Cell::kValueOffset), r0); |
1308 } | 1391 } |
1309 | 1392 |
1310 // Register mapping: r3 is object map and r4 is function prototype. | 1393 // Register mapping: r6 is object map and r7 is function prototype. |
1311 // Get prototype of object into r2. | 1394 // Get prototype of object into r5. |
1312 __ ldr(scratch, FieldMemOperand(map, Map::kPrototypeOffset)); | 1395 __ LoadP(scratch, FieldMemOperand(map, Map::kPrototypeOffset)); |
1313 | 1396 |
1314 // We don't need map any more. Use it as a scratch register. | 1397 // We don't need map any more. Use it as a scratch register. |
1315 Register scratch2 = map; | 1398 scratch3 = map; |
1316 map = no_reg; | 1399 map = no_reg; |
1317 | 1400 |
1318 // Loop through the prototype chain looking for the function prototype. | 1401 // Loop through the prototype chain looking for the function prototype. |
1319 __ LoadRoot(scratch2, Heap::kNullValueRootIndex); | 1402 __ LoadRoot(scratch3, Heap::kNullValueRootIndex); |
1320 __ bind(&loop); | 1403 __ bind(&loop); |
1321 __ cmp(scratch, Operand(prototype)); | 1404 __ cmp(scratch, prototype); |
1322 __ b(eq, &is_instance); | 1405 __ beq(&is_instance); |
1323 __ cmp(scratch, scratch2); | 1406 __ cmp(scratch, scratch3); |
1324 __ b(eq, &is_not_instance); | 1407 __ beq(&is_not_instance); |
1325 __ ldr(scratch, FieldMemOperand(scratch, HeapObject::kMapOffset)); | 1408 __ LoadP(scratch, FieldMemOperand(scratch, HeapObject::kMapOffset)); |
1326 __ ldr(scratch, FieldMemOperand(scratch, Map::kPrototypeOffset)); | 1409 __ LoadP(scratch, FieldMemOperand(scratch, Map::kPrototypeOffset)); |
1327 __ jmp(&loop); | 1410 __ b(&loop); |
1328 Factory* factory = isolate()->factory(); | 1411 Factory* factory = isolate()->factory(); |
1329 | 1412 |
1330 __ bind(&is_instance); | 1413 __ bind(&is_instance); |
1331 if (!HasCallSiteInlineCheck()) { | 1414 if (!HasCallSiteInlineCheck()) { |
1332 __ mov(r0, Operand(Smi::FromInt(0))); | 1415 __ LoadSmiLiteral(r3, Smi::FromInt(0)); |
1333 __ StoreRoot(r0, Heap::kInstanceofCacheAnswerRootIndex); | 1416 __ StoreRoot(r3, Heap::kInstanceofCacheAnswerRootIndex); |
1334 if (ReturnTrueFalseObject()) { | 1417 if (ReturnTrueFalseObject()) { |
1335 __ Move(r0, factory->true_value()); | 1418 __ Move(r3, factory->true_value()); |
1336 } | 1419 } |
1337 } else { | 1420 } else { |
1338 // Patch the call site to return true. | 1421 // Patch the call site to return true. |
1339 __ LoadRoot(r0, Heap::kTrueValueRootIndex); | 1422 __ LoadRoot(r3, Heap::kTrueValueRootIndex); |
1340 // The bool_load_offset was stored in r6 | 1423 __ addi(inline_site, inline_site, Operand(kDeltaToLoadBoolResult)); |
1341 // (See LCodeGen::DoDeferredLInstanceOfKnownGlobal). | |
1342 const Register bool_load_offset = r6; | |
1343 __ sub(r9, lr, bool_load_offset); | |
1344 // Get the boolean result location in scratch and patch it. | 1424 // Get the boolean result location in scratch and patch it. |
1345 __ GetRelocatedValueLocation(r9, scratch, scratch2); | 1425 __ SetRelocatedValue(inline_site, scratch, r3); |
1346 __ str(r0, MemOperand(scratch)); | |
1347 | 1426 |
1348 if (!ReturnTrueFalseObject()) { | 1427 if (!ReturnTrueFalseObject()) { |
1349 __ mov(r0, Operand(Smi::FromInt(0))); | 1428 __ LoadSmiLiteral(r3, Smi::FromInt(0)); |
1350 } | 1429 } |
1351 } | 1430 } |
1352 __ Ret(HasArgsInRegisters() ? 0 : 2); | 1431 __ Ret(HasArgsInRegisters() ? 0 : 2); |
1353 | 1432 |
1354 __ bind(&is_not_instance); | 1433 __ bind(&is_not_instance); |
1355 if (!HasCallSiteInlineCheck()) { | 1434 if (!HasCallSiteInlineCheck()) { |
1356 __ mov(r0, Operand(Smi::FromInt(1))); | 1435 __ LoadSmiLiteral(r3, Smi::FromInt(1)); |
1357 __ StoreRoot(r0, Heap::kInstanceofCacheAnswerRootIndex); | 1436 __ StoreRoot(r3, Heap::kInstanceofCacheAnswerRootIndex); |
1358 if (ReturnTrueFalseObject()) { | 1437 if (ReturnTrueFalseObject()) { |
1359 __ Move(r0, factory->false_value()); | 1438 __ Move(r3, factory->false_value()); |
1360 } | 1439 } |
1361 } else { | 1440 } else { |
1362 // Patch the call site to return false. | 1441 // Patch the call site to return false. |
1363 __ LoadRoot(r0, Heap::kFalseValueRootIndex); | 1442 __ LoadRoot(r3, Heap::kFalseValueRootIndex); |
1364 // The bool_load_offset was stored in r6 | 1443 __ addi(inline_site, inline_site, Operand(kDeltaToLoadBoolResult)); |
1365 // (See LCodeGen::DoDeferredLInstanceOfKnownGlobal). | |
1366 const Register bool_load_offset = r6; | |
1367 __ sub(r9, lr, bool_load_offset); | |
1368 ; | |
1369 // Get the boolean result location in scratch and patch it. | 1444 // Get the boolean result location in scratch and patch it. |
1370 __ GetRelocatedValueLocation(r9, scratch, scratch2); | 1445 __ SetRelocatedValue(inline_site, scratch, r3); |
1371 __ str(r0, MemOperand(scratch)); | |
1372 | 1446 |
1373 if (!ReturnTrueFalseObject()) { | 1447 if (!ReturnTrueFalseObject()) { |
1374 __ mov(r0, Operand(Smi::FromInt(1))); | 1448 __ LoadSmiLiteral(r3, Smi::FromInt(1)); |
1375 } | 1449 } |
1376 } | 1450 } |
1377 __ Ret(HasArgsInRegisters() ? 0 : 2); | 1451 __ Ret(HasArgsInRegisters() ? 0 : 2); |
1378 | 1452 |
1379 Label object_not_null, object_not_null_or_smi; | 1453 Label object_not_null, object_not_null_or_smi; |
1380 __ bind(¬_js_object); | 1454 __ bind(¬_js_object); |
1381 // Before null, smi and string value checks, check that the rhs is a function | 1455 // Before null, smi and string value checks, check that the rhs is a function |
1382 // as for a non-function rhs an exception needs to be thrown. | 1456 // as for a non-function rhs an exception needs to be thrown. |
1383 __ JumpIfSmi(function, &slow); | 1457 __ JumpIfSmi(function, &slow); |
1384 __ CompareObjectType(function, scratch2, scratch, JS_FUNCTION_TYPE); | 1458 __ CompareObjectType(function, scratch3, scratch, JS_FUNCTION_TYPE); |
1385 __ b(ne, &slow); | 1459 __ bne(&slow); |
1386 | 1460 |
1387 // Null is not instance of anything. | 1461 // Null is not instance of anything. |
1388 __ cmp(object, Operand(isolate()->factory()->null_value())); | 1462 __ Cmpi(object, Operand(isolate()->factory()->null_value()), r0); |
1389 __ b(ne, &object_not_null); | 1463 __ bne(&object_not_null); |
1390 if (ReturnTrueFalseObject()) { | 1464 if (ReturnTrueFalseObject()) { |
1391 __ Move(r0, factory->false_value()); | 1465 __ Move(r3, factory->false_value()); |
1392 } else { | 1466 } else { |
1393 __ mov(r0, Operand(Smi::FromInt(1))); | 1467 __ LoadSmiLiteral(r3, Smi::FromInt(1)); |
1394 } | 1468 } |
1395 __ Ret(HasArgsInRegisters() ? 0 : 2); | 1469 __ Ret(HasArgsInRegisters() ? 0 : 2); |
1396 | 1470 |
1397 __ bind(&object_not_null); | 1471 __ bind(&object_not_null); |
1398 // Smi values are not instances of anything. | 1472 // Smi values are not instances of anything. |
1399 __ JumpIfNotSmi(object, &object_not_null_or_smi); | 1473 __ JumpIfNotSmi(object, &object_not_null_or_smi); |
1400 if (ReturnTrueFalseObject()) { | 1474 if (ReturnTrueFalseObject()) { |
1401 __ Move(r0, factory->false_value()); | 1475 __ Move(r3, factory->false_value()); |
1402 } else { | 1476 } else { |
1403 __ mov(r0, Operand(Smi::FromInt(1))); | 1477 __ LoadSmiLiteral(r3, Smi::FromInt(1)); |
1404 } | 1478 } |
1405 __ Ret(HasArgsInRegisters() ? 0 : 2); | 1479 __ Ret(HasArgsInRegisters() ? 0 : 2); |
1406 | 1480 |
1407 __ bind(&object_not_null_or_smi); | 1481 __ bind(&object_not_null_or_smi); |
1408 // String values are not instances of anything. | 1482 // String values are not instances of anything. |
1409 __ IsObjectJSStringType(object, scratch, &slow); | 1483 __ IsObjectJSStringType(object, scratch, &slow); |
1410 if (ReturnTrueFalseObject()) { | 1484 if (ReturnTrueFalseObject()) { |
1411 __ Move(r0, factory->false_value()); | 1485 __ Move(r3, factory->false_value()); |
1412 } else { | 1486 } else { |
1413 __ mov(r0, Operand(Smi::FromInt(1))); | 1487 __ LoadSmiLiteral(r3, Smi::FromInt(1)); |
1414 } | 1488 } |
1415 __ Ret(HasArgsInRegisters() ? 0 : 2); | 1489 __ Ret(HasArgsInRegisters() ? 0 : 2); |
1416 | 1490 |
1417 // Slow-case. Tail call builtin. | 1491 // Slow-case. Tail call builtin. |
1418 __ bind(&slow); | 1492 __ bind(&slow); |
1419 if (!ReturnTrueFalseObject()) { | 1493 if (!ReturnTrueFalseObject()) { |
1420 if (HasArgsInRegisters()) { | 1494 if (HasArgsInRegisters()) { |
1421 __ Push(r0, r1); | 1495 __ Push(r3, r4); |
1422 } | 1496 } |
1423 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); | 1497 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); |
1424 } else { | 1498 } else { |
1425 { | 1499 { |
1426 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 1500 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
1427 __ Push(r0, r1); | 1501 __ Push(r3, r4); |
1428 __ InvokeBuiltin(Builtins::INSTANCE_OF, CALL_FUNCTION); | 1502 __ InvokeBuiltin(Builtins::INSTANCE_OF, CALL_FUNCTION); |
1429 } | 1503 } |
1430 __ cmp(r0, Operand::Zero()); | 1504 Label true_value, done; |
1431 __ LoadRoot(r0, Heap::kTrueValueRootIndex, eq); | 1505 __ cmpi(r3, Operand::Zero()); |
1432 __ LoadRoot(r0, Heap::kFalseValueRootIndex, ne); | 1506 __ beq(&true_value); |
| 1507 |
| 1508 __ LoadRoot(r3, Heap::kFalseValueRootIndex); |
| 1509 __ b(&done); |
| 1510 |
| 1511 __ bind(&true_value); |
| 1512 __ LoadRoot(r3, Heap::kTrueValueRootIndex); |
| 1513 |
| 1514 __ bind(&done); |
1433 __ Ret(HasArgsInRegisters() ? 0 : 2); | 1515 __ Ret(HasArgsInRegisters() ? 0 : 2); |
1434 } | 1516 } |
1435 } | 1517 } |
1436 | 1518 |
1437 | 1519 |
1438 void FunctionPrototypeStub::Generate(MacroAssembler* masm) { | 1520 void FunctionPrototypeStub::Generate(MacroAssembler* masm) { |
1439 Label miss; | 1521 Label miss; |
1440 Register receiver = LoadDescriptor::ReceiverRegister(); | 1522 Register receiver = LoadDescriptor::ReceiverRegister(); |
1441 | 1523 |
1442 NamedLoadHandlerCompiler::GenerateLoadFunctionPrototype(masm, receiver, r3, | 1524 NamedLoadHandlerCompiler::GenerateLoadFunctionPrototype(masm, receiver, r6, |
1443 r4, &miss); | 1525 r7, &miss); |
1444 __ bind(&miss); | 1526 __ bind(&miss); |
1445 PropertyAccessCompiler::TailCallBuiltin( | 1527 PropertyAccessCompiler::TailCallBuiltin( |
1446 masm, PropertyAccessCompiler::MissBuiltin(Code::LOAD_IC)); | 1528 masm, PropertyAccessCompiler::MissBuiltin(Code::LOAD_IC)); |
1447 } | 1529 } |
1448 | 1530 |
1449 | 1531 |
1450 void LoadIndexedStringStub::Generate(MacroAssembler* masm) { | 1532 void LoadIndexedStringStub::Generate(MacroAssembler* masm) { |
1451 // Return address is in lr. | 1533 // Return address is in lr. |
1452 Label miss; | 1534 Label miss; |
1453 | 1535 |
1454 Register receiver = LoadDescriptor::ReceiverRegister(); | 1536 Register receiver = LoadDescriptor::ReceiverRegister(); |
1455 Register index = LoadDescriptor::NameRegister(); | 1537 Register index = LoadDescriptor::NameRegister(); |
1456 Register scratch = r3; | 1538 Register scratch = r6; |
1457 Register result = r0; | 1539 Register result = r3; |
1458 DCHECK(!scratch.is(receiver) && !scratch.is(index)); | 1540 DCHECK(!scratch.is(receiver) && !scratch.is(index)); |
1459 | 1541 |
1460 StringCharAtGenerator char_at_generator(receiver, index, scratch, result, | 1542 StringCharAtGenerator char_at_generator(receiver, index, scratch, result, |
1461 &miss, // When not a string. | 1543 &miss, // When not a string. |
1462 &miss, // When not a number. | 1544 &miss, // When not a number. |
1463 &miss, // When index out of range. | 1545 &miss, // When index out of range. |
1464 STRING_INDEX_IS_ARRAY_INDEX, | 1546 STRING_INDEX_IS_ARRAY_INDEX, |
1465 RECEIVER_IS_STRING); | 1547 RECEIVER_IS_STRING); |
1466 char_at_generator.GenerateFast(masm); | 1548 char_at_generator.GenerateFast(masm); |
1467 __ Ret(); | 1549 __ Ret(); |
1468 | 1550 |
1469 StubRuntimeCallHelper call_helper; | 1551 StubRuntimeCallHelper call_helper; |
1470 char_at_generator.GenerateSlow(masm, call_helper); | 1552 char_at_generator.GenerateSlow(masm, call_helper); |
1471 | 1553 |
1472 __ bind(&miss); | 1554 __ bind(&miss); |
1473 PropertyAccessCompiler::TailCallBuiltin( | 1555 PropertyAccessCompiler::TailCallBuiltin( |
1474 masm, PropertyAccessCompiler::MissBuiltin(Code::KEYED_LOAD_IC)); | 1556 masm, PropertyAccessCompiler::MissBuiltin(Code::KEYED_LOAD_IC)); |
1475 } | 1557 } |
1476 | 1558 |
1477 | 1559 |
1478 void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { | 1560 void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { |
1479 // The displacement is the offset of the last parameter (if any) | 1561 // The displacement is the offset of the last parameter (if any) |
1480 // relative to the frame pointer. | 1562 // relative to the frame pointer. |
1481 const int kDisplacement = | 1563 const int kDisplacement = |
1482 StandardFrameConstants::kCallerSPOffset - kPointerSize; | 1564 StandardFrameConstants::kCallerSPOffset - kPointerSize; |
1483 DCHECK(r1.is(ArgumentsAccessReadDescriptor::index())); | 1565 DCHECK(r4.is(ArgumentsAccessReadDescriptor::index())); |
1484 DCHECK(r0.is(ArgumentsAccessReadDescriptor::parameter_count())); | 1566 DCHECK(r3.is(ArgumentsAccessReadDescriptor::parameter_count())); |
1485 | 1567 |
1486 // Check that the key is a smi. | 1568 // Check that the key is a smi. |
1487 Label slow; | 1569 Label slow; |
1488 __ JumpIfNotSmi(r1, &slow); | 1570 __ JumpIfNotSmi(r4, &slow); |
1489 | 1571 |
1490 // Check if the calling frame is an arguments adaptor frame. | 1572 // Check if the calling frame is an arguments adaptor frame. |
1491 Label adaptor; | 1573 Label adaptor; |
1492 __ ldr(r2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | 1574 __ LoadP(r5, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
1493 __ ldr(r3, MemOperand(r2, StandardFrameConstants::kContextOffset)); | 1575 __ LoadP(r6, MemOperand(r5, StandardFrameConstants::kContextOffset)); |
1494 __ cmp(r3, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 1576 STATIC_ASSERT(StackFrame::ARGUMENTS_ADAPTOR < 0x3fffu); |
1495 __ b(eq, &adaptor); | 1577 __ CmpSmiLiteral(r6, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0); |
| 1578 __ beq(&adaptor); |
1496 | 1579 |
1497 // Check index against formal parameters count limit passed in | 1580 // Check index against formal parameters count limit passed in |
1498 // through register r0. Use unsigned comparison to get negative | 1581 // through register r3. Use unsigned comparison to get negative |
1499 // check for free. | 1582 // check for free. |
1500 __ cmp(r1, r0); | 1583 __ cmpl(r4, r3); |
1501 __ b(hs, &slow); | 1584 __ bge(&slow); |
1502 | 1585 |
1503 // Read the argument from the stack and return it. | 1586 // Read the argument from the stack and return it. |
1504 __ sub(r3, r0, r1); | 1587 __ sub(r6, r3, r4); |
1505 __ add(r3, fp, Operand::PointerOffsetFromSmiKey(r3)); | 1588 __ SmiToPtrArrayOffset(r6, r6); |
1506 __ ldr(r0, MemOperand(r3, kDisplacement)); | 1589 __ add(r6, fp, r6); |
1507 __ Jump(lr); | 1590 __ LoadP(r3, MemOperand(r6, kDisplacement)); |
| 1591 __ blr(); |
1508 | 1592 |
1509 // Arguments adaptor case: Check index against actual arguments | 1593 // Arguments adaptor case: Check index against actual arguments |
1510 // limit found in the arguments adaptor frame. Use unsigned | 1594 // limit found in the arguments adaptor frame. Use unsigned |
1511 // comparison to get negative check for free. | 1595 // comparison to get negative check for free. |
1512 __ bind(&adaptor); | 1596 __ bind(&adaptor); |
1513 __ ldr(r0, MemOperand(r2, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 1597 __ LoadP(r3, MemOperand(r5, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
1514 __ cmp(r1, r0); | 1598 __ cmpl(r4, r3); |
1515 __ b(cs, &slow); | 1599 __ bge(&slow); |
1516 | 1600 |
1517 // Read the argument from the adaptor frame and return it. | 1601 // Read the argument from the adaptor frame and return it. |
1518 __ sub(r3, r0, r1); | 1602 __ sub(r6, r3, r4); |
1519 __ add(r3, r2, Operand::PointerOffsetFromSmiKey(r3)); | 1603 __ SmiToPtrArrayOffset(r6, r6); |
1520 __ ldr(r0, MemOperand(r3, kDisplacement)); | 1604 __ add(r6, r5, r6); |
1521 __ Jump(lr); | 1605 __ LoadP(r3, MemOperand(r6, kDisplacement)); |
| 1606 __ blr(); |
1522 | 1607 |
1523 // Slow-case: Handle non-smi or out-of-bounds access to arguments | 1608 // Slow-case: Handle non-smi or out-of-bounds access to arguments |
1524 // by calling the runtime system. | 1609 // by calling the runtime system. |
1525 __ bind(&slow); | 1610 __ bind(&slow); |
1526 __ push(r1); | 1611 __ push(r4); |
1527 __ TailCallRuntime(Runtime::kGetArgumentsProperty, 1, 1); | 1612 __ TailCallRuntime(Runtime::kGetArgumentsProperty, 1, 1); |
1528 } | 1613 } |
1529 | 1614 |
1530 | 1615 |
1531 void ArgumentsAccessStub::GenerateNewSloppySlow(MacroAssembler* masm) { | 1616 void ArgumentsAccessStub::GenerateNewSloppySlow(MacroAssembler* masm) { |
1532 // sp[0] : number of parameters | 1617 // sp[0] : number of parameters |
1533 // sp[4] : receiver displacement | 1618 // sp[1] : receiver displacement |
1534 // sp[8] : function | 1619 // sp[2] : function |
1535 | 1620 |
1536 // Check if the calling frame is an arguments adaptor frame. | 1621 // Check if the calling frame is an arguments adaptor frame. |
1537 Label runtime; | 1622 Label runtime; |
1538 __ ldr(r3, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | 1623 __ LoadP(r6, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
1539 __ ldr(r2, MemOperand(r3, StandardFrameConstants::kContextOffset)); | 1624 __ LoadP(r5, MemOperand(r6, StandardFrameConstants::kContextOffset)); |
1540 __ cmp(r2, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 1625 STATIC_ASSERT(StackFrame::ARGUMENTS_ADAPTOR < 0x3fffu); |
1541 __ b(ne, &runtime); | 1626 __ CmpSmiLiteral(r5, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0); |
| 1627 __ bne(&runtime); |
1542 | 1628 |
1543 // Patch the arguments.length and the parameters pointer in the current frame. | 1629 // Patch the arguments.length and the parameters pointer in the current frame. |
1544 __ ldr(r2, MemOperand(r3, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 1630 __ LoadP(r5, MemOperand(r6, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
1545 __ str(r2, MemOperand(sp, 0 * kPointerSize)); | 1631 __ StoreP(r5, MemOperand(sp, 0 * kPointerSize)); |
1546 __ add(r3, r3, Operand(r2, LSL, 1)); | 1632 __ SmiToPtrArrayOffset(r5, r5); |
1547 __ add(r3, r3, Operand(StandardFrameConstants::kCallerSPOffset)); | 1633 __ add(r6, r6, r5); |
1548 __ str(r3, MemOperand(sp, 1 * kPointerSize)); | 1634 __ addi(r6, r6, Operand(StandardFrameConstants::kCallerSPOffset)); |
| 1635 __ StoreP(r6, MemOperand(sp, 1 * kPointerSize)); |
1549 | 1636 |
1550 __ bind(&runtime); | 1637 __ bind(&runtime); |
1551 __ TailCallRuntime(Runtime::kNewSloppyArguments, 3, 1); | 1638 __ TailCallRuntime(Runtime::kNewSloppyArguments, 3, 1); |
1552 } | 1639 } |
1553 | 1640 |
1554 | 1641 |
1555 void ArgumentsAccessStub::GenerateNewSloppyFast(MacroAssembler* masm) { | 1642 void ArgumentsAccessStub::GenerateNewSloppyFast(MacroAssembler* masm) { |
1556 // Stack layout: | 1643 // Stack layout: |
1557 // sp[0] : number of parameters (tagged) | 1644 // sp[0] : number of parameters (tagged) |
1558 // sp[4] : address of receiver argument | 1645 // sp[1] : address of receiver argument |
1559 // sp[8] : function | 1646 // sp[2] : function |
1560 // Registers used over whole function: | 1647 // Registers used over whole function: |
1561 // r6 : allocated object (tagged) | 1648 // r9 : allocated object (tagged) |
1562 // r9 : mapped parameter count (tagged) | 1649 // r11 : mapped parameter count (tagged) |
1563 | 1650 |
1564 __ ldr(r1, MemOperand(sp, 0 * kPointerSize)); | 1651 __ LoadP(r4, MemOperand(sp, 0 * kPointerSize)); |
1565 // r1 = parameter count (tagged) | 1652 // r4 = parameter count (tagged) |
1566 | 1653 |
1567 // Check if the calling frame is an arguments adaptor frame. | 1654 // Check if the calling frame is an arguments adaptor frame. |
1568 Label runtime; | 1655 Label runtime; |
1569 Label adaptor_frame, try_allocate; | 1656 Label adaptor_frame, try_allocate; |
1570 __ ldr(r3, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | 1657 __ LoadP(r6, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
1571 __ ldr(r2, MemOperand(r3, StandardFrameConstants::kContextOffset)); | 1658 __ LoadP(r5, MemOperand(r6, StandardFrameConstants::kContextOffset)); |
1572 __ cmp(r2, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 1659 STATIC_ASSERT(StackFrame::ARGUMENTS_ADAPTOR < 0x3fffu); |
1573 __ b(eq, &adaptor_frame); | 1660 __ CmpSmiLiteral(r5, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0); |
| 1661 __ beq(&adaptor_frame); |
1574 | 1662 |
1575 // No adaptor, parameter count = argument count. | 1663 // No adaptor, parameter count = argument count. |
1576 __ mov(r2, r1); | 1664 __ mr(r5, r4); |
1577 __ b(&try_allocate); | 1665 __ b(&try_allocate); |
1578 | 1666 |
1579 // We have an adaptor frame. Patch the parameters pointer. | 1667 // We have an adaptor frame. Patch the parameters pointer. |
1580 __ bind(&adaptor_frame); | 1668 __ bind(&adaptor_frame); |
1581 __ ldr(r2, MemOperand(r3, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 1669 __ LoadP(r5, MemOperand(r6, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
1582 __ add(r3, r3, Operand(r2, LSL, 1)); | 1670 __ SmiToPtrArrayOffset(r7, r5); |
1583 __ add(r3, r3, Operand(StandardFrameConstants::kCallerSPOffset)); | 1671 __ add(r6, r6, r7); |
1584 __ str(r3, MemOperand(sp, 1 * kPointerSize)); | 1672 __ addi(r6, r6, Operand(StandardFrameConstants::kCallerSPOffset)); |
| 1673 __ StoreP(r6, MemOperand(sp, 1 * kPointerSize)); |
1585 | 1674 |
1586 // r1 = parameter count (tagged) | 1675 // r4 = parameter count (tagged) |
1587 // r2 = argument count (tagged) | 1676 // r5 = argument count (tagged) |
1588 // Compute the mapped parameter count = min(r1, r2) in r1. | 1677 // Compute the mapped parameter count = min(r4, r5) in r4. |
1589 __ cmp(r1, Operand(r2)); | 1678 Label skip; |
1590 __ mov(r1, Operand(r2), LeaveCC, gt); | 1679 __ cmp(r4, r5); |
| 1680 __ blt(&skip); |
| 1681 __ mr(r4, r5); |
| 1682 __ bind(&skip); |
1591 | 1683 |
1592 __ bind(&try_allocate); | 1684 __ bind(&try_allocate); |
1593 | 1685 |
1594 // Compute the sizes of backing store, parameter map, and arguments object. | 1686 // Compute the sizes of backing store, parameter map, and arguments object. |
1595 // 1. Parameter map, has 2 extra words containing context and backing store. | 1687 // 1. Parameter map, has 2 extra words containing context and backing store. |
1596 const int kParameterMapHeaderSize = | 1688 const int kParameterMapHeaderSize = |
1597 FixedArray::kHeaderSize + 2 * kPointerSize; | 1689 FixedArray::kHeaderSize + 2 * kPointerSize; |
1598 // If there are no mapped parameters, we do not need the parameter_map. | 1690 // If there are no mapped parameters, we do not need the parameter_map. |
1599 __ cmp(r1, Operand(Smi::FromInt(0))); | 1691 Label skip2, skip3; |
1600 __ mov(r9, Operand::Zero(), LeaveCC, eq); | 1692 __ CmpSmiLiteral(r4, Smi::FromInt(0), r0); |
1601 __ mov(r9, Operand(r1, LSL, 1), LeaveCC, ne); | 1693 __ bne(&skip2); |
1602 __ add(r9, r9, Operand(kParameterMapHeaderSize), LeaveCC, ne); | 1694 __ li(r11, Operand::Zero()); |
| 1695 __ b(&skip3); |
| 1696 __ bind(&skip2); |
| 1697 __ SmiToPtrArrayOffset(r11, r4); |
| 1698 __ addi(r11, r11, Operand(kParameterMapHeaderSize)); |
| 1699 __ bind(&skip3); |
1603 | 1700 |
1604 // 2. Backing store. | 1701 // 2. Backing store. |
1605 __ add(r9, r9, Operand(r2, LSL, 1)); | 1702 __ SmiToPtrArrayOffset(r7, r5); |
1606 __ add(r9, r9, Operand(FixedArray::kHeaderSize)); | 1703 __ add(r11, r11, r7); |
| 1704 __ addi(r11, r11, Operand(FixedArray::kHeaderSize)); |
1607 | 1705 |
1608 // 3. Arguments object. | 1706 // 3. Arguments object. |
1609 __ add(r9, r9, Operand(Heap::kSloppyArgumentsObjectSize)); | 1707 __ addi(r11, r11, Operand(Heap::kSloppyArgumentsObjectSize)); |
1610 | 1708 |
1611 // Do the allocation of all three objects in one go. | 1709 // Do the allocation of all three objects in one go. |
1612 __ Allocate(r9, r0, r3, r4, &runtime, TAG_OBJECT); | 1710 __ Allocate(r11, r3, r6, r7, &runtime, TAG_OBJECT); |
1613 | 1711 |
1614 // r0 = address of new object(s) (tagged) | 1712 // r3 = address of new object(s) (tagged) |
1615 // r2 = argument count (smi-tagged) | 1713 // r5 = argument count (smi-tagged) |
1616 // Get the arguments boilerplate from the current native context into r4. | 1714 // Get the arguments boilerplate from the current native context into r4. |
1617 const int kNormalOffset = | 1715 const int kNormalOffset = |
1618 Context::SlotOffset(Context::SLOPPY_ARGUMENTS_MAP_INDEX); | 1716 Context::SlotOffset(Context::SLOPPY_ARGUMENTS_MAP_INDEX); |
1619 const int kAliasedOffset = | 1717 const int kAliasedOffset = |
1620 Context::SlotOffset(Context::ALIASED_ARGUMENTS_MAP_INDEX); | 1718 Context::SlotOffset(Context::ALIASED_ARGUMENTS_MAP_INDEX); |
1621 | 1719 |
1622 __ ldr(r4, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 1720 __ LoadP(r7, |
1623 __ ldr(r4, FieldMemOperand(r4, GlobalObject::kNativeContextOffset)); | 1721 MemOperand(cp, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
1624 __ cmp(r1, Operand::Zero()); | 1722 __ LoadP(r7, FieldMemOperand(r7, GlobalObject::kNativeContextOffset)); |
1625 __ ldr(r4, MemOperand(r4, kNormalOffset), eq); | 1723 Label skip4, skip5; |
1626 __ ldr(r4, MemOperand(r4, kAliasedOffset), ne); | 1724 __ cmpi(r4, Operand::Zero()); |
| 1725 __ bne(&skip4); |
| 1726 __ LoadP(r7, MemOperand(r7, kNormalOffset)); |
| 1727 __ b(&skip5); |
| 1728 __ bind(&skip4); |
| 1729 __ LoadP(r7, MemOperand(r7, kAliasedOffset)); |
| 1730 __ bind(&skip5); |
1627 | 1731 |
1628 // r0 = address of new object (tagged) | 1732 // r3 = address of new object (tagged) |
1629 // r1 = mapped parameter count (tagged) | 1733 // r4 = mapped parameter count (tagged) |
1630 // r2 = argument count (smi-tagged) | 1734 // r5 = argument count (smi-tagged) |
1631 // r4 = address of arguments map (tagged) | 1735 // r7 = address of arguments map (tagged) |
1632 __ str(r4, FieldMemOperand(r0, JSObject::kMapOffset)); | 1736 __ StoreP(r7, FieldMemOperand(r3, JSObject::kMapOffset), r0); |
1633 __ LoadRoot(r3, Heap::kEmptyFixedArrayRootIndex); | 1737 __ LoadRoot(r6, Heap::kEmptyFixedArrayRootIndex); |
1634 __ str(r3, FieldMemOperand(r0, JSObject::kPropertiesOffset)); | 1738 __ StoreP(r6, FieldMemOperand(r3, JSObject::kPropertiesOffset), r0); |
1635 __ str(r3, FieldMemOperand(r0, JSObject::kElementsOffset)); | 1739 __ StoreP(r6, FieldMemOperand(r3, JSObject::kElementsOffset), r0); |
1636 | 1740 |
1637 // Set up the callee in-object property. | 1741 // Set up the callee in-object property. |
1638 STATIC_ASSERT(Heap::kArgumentsCalleeIndex == 1); | 1742 STATIC_ASSERT(Heap::kArgumentsCalleeIndex == 1); |
1639 __ ldr(r3, MemOperand(sp, 2 * kPointerSize)); | 1743 __ LoadP(r6, MemOperand(sp, 2 * kPointerSize)); |
1640 __ AssertNotSmi(r3); | 1744 __ AssertNotSmi(r6); |
1641 const int kCalleeOffset = JSObject::kHeaderSize + | 1745 const int kCalleeOffset = |
1642 Heap::kArgumentsCalleeIndex * kPointerSize; | 1746 JSObject::kHeaderSize + Heap::kArgumentsCalleeIndex * kPointerSize; |
1643 __ str(r3, FieldMemOperand(r0, kCalleeOffset)); | 1747 __ StoreP(r6, FieldMemOperand(r3, kCalleeOffset), r0); |
1644 | 1748 |
1645 // Use the length (smi tagged) and set that as an in-object property too. | 1749 // Use the length (smi tagged) and set that as an in-object property too. |
1646 __ AssertSmi(r2); | 1750 __ AssertSmi(r5); |
1647 STATIC_ASSERT(Heap::kArgumentsLengthIndex == 0); | 1751 STATIC_ASSERT(Heap::kArgumentsLengthIndex == 0); |
1648 const int kLengthOffset = JSObject::kHeaderSize + | 1752 const int kLengthOffset = |
1649 Heap::kArgumentsLengthIndex * kPointerSize; | 1753 JSObject::kHeaderSize + Heap::kArgumentsLengthIndex * kPointerSize; |
1650 __ str(r2, FieldMemOperand(r0, kLengthOffset)); | 1754 __ StoreP(r5, FieldMemOperand(r3, kLengthOffset), r0); |
1651 | 1755 |
1652 // Set up the elements pointer in the allocated arguments object. | 1756 // Set up the elements pointer in the allocated arguments object. |
1653 // If we allocated a parameter map, r4 will point there, otherwise | 1757 // If we allocated a parameter map, r7 will point there, otherwise |
1654 // it will point to the backing store. | 1758 // it will point to the backing store. |
1655 __ add(r4, r0, Operand(Heap::kSloppyArgumentsObjectSize)); | 1759 __ addi(r7, r3, Operand(Heap::kSloppyArgumentsObjectSize)); |
1656 __ str(r4, FieldMemOperand(r0, JSObject::kElementsOffset)); | 1760 __ StoreP(r7, FieldMemOperand(r3, JSObject::kElementsOffset), r0); |
1657 | 1761 |
1658 // r0 = address of new object (tagged) | 1762 // r3 = address of new object (tagged) |
1659 // r1 = mapped parameter count (tagged) | 1763 // r4 = mapped parameter count (tagged) |
1660 // r2 = argument count (tagged) | 1764 // r5 = argument count (tagged) |
1661 // r4 = address of parameter map or backing store (tagged) | 1765 // r7 = address of parameter map or backing store (tagged) |
1662 // Initialize parameter map. If there are no mapped arguments, we're done. | 1766 // Initialize parameter map. If there are no mapped arguments, we're done. |
1663 Label skip_parameter_map; | 1767 Label skip_parameter_map, skip6; |
1664 __ cmp(r1, Operand(Smi::FromInt(0))); | 1768 __ CmpSmiLiteral(r4, Smi::FromInt(0), r0); |
1665 // Move backing store address to r3, because it is | 1769 __ bne(&skip6); |
| 1770 // Move backing store address to r6, because it is |
1666 // expected there when filling in the unmapped arguments. | 1771 // expected there when filling in the unmapped arguments. |
1667 __ mov(r3, r4, LeaveCC, eq); | 1772 __ mr(r6, r7); |
1668 __ b(eq, &skip_parameter_map); | 1773 __ b(&skip_parameter_map); |
| 1774 __ bind(&skip6); |
1669 | 1775 |
1670 __ LoadRoot(r6, Heap::kSloppyArgumentsElementsMapRootIndex); | 1776 __ LoadRoot(r9, Heap::kSloppyArgumentsElementsMapRootIndex); |
1671 __ str(r6, FieldMemOperand(r4, FixedArray::kMapOffset)); | 1777 __ StoreP(r9, FieldMemOperand(r7, FixedArray::kMapOffset), r0); |
1672 __ add(r6, r1, Operand(Smi::FromInt(2))); | 1778 __ AddSmiLiteral(r9, r4, Smi::FromInt(2), r0); |
1673 __ str(r6, FieldMemOperand(r4, FixedArray::kLengthOffset)); | 1779 __ StoreP(r9, FieldMemOperand(r7, FixedArray::kLengthOffset), r0); |
1674 __ str(cp, FieldMemOperand(r4, FixedArray::kHeaderSize + 0 * kPointerSize)); | 1780 __ StoreP(cp, FieldMemOperand(r7, FixedArray::kHeaderSize + 0 * kPointerSize), |
1675 __ add(r6, r4, Operand(r1, LSL, 1)); | 1781 r0); |
1676 __ add(r6, r6, Operand(kParameterMapHeaderSize)); | 1782 __ SmiToPtrArrayOffset(r9, r4); |
1677 __ str(r6, FieldMemOperand(r4, FixedArray::kHeaderSize + 1 * kPointerSize)); | 1783 __ add(r9, r7, r9); |
| 1784 __ addi(r9, r9, Operand(kParameterMapHeaderSize)); |
| 1785 __ StoreP(r9, FieldMemOperand(r7, FixedArray::kHeaderSize + 1 * kPointerSize), |
| 1786 r0); |
1678 | 1787 |
1679 // Copy the parameter slots and the holes in the arguments. | 1788 // Copy the parameter slots and the holes in the arguments. |
1680 // We need to fill in mapped_parameter_count slots. They index the context, | 1789 // We need to fill in mapped_parameter_count slots. They index the context, |
1681 // where parameters are stored in reverse order, at | 1790 // where parameters are stored in reverse order, at |
1682 // MIN_CONTEXT_SLOTS .. MIN_CONTEXT_SLOTS+parameter_count-1 | 1791 // MIN_CONTEXT_SLOTS .. MIN_CONTEXT_SLOTS+parameter_count-1 |
1683 // The mapped parameter thus need to get indices | 1792 // The mapped parameter thus need to get indices |
1684 // MIN_CONTEXT_SLOTS+parameter_count-1 .. | 1793 // MIN_CONTEXT_SLOTS+parameter_count-1 .. |
1685 // MIN_CONTEXT_SLOTS+parameter_count-mapped_parameter_count | 1794 // MIN_CONTEXT_SLOTS+parameter_count-mapped_parameter_count |
1686 // We loop from right to left. | 1795 // We loop from right to left. |
1687 Label parameters_loop, parameters_test; | 1796 Label parameters_loop, parameters_test; |
1688 __ mov(r6, r1); | 1797 __ mr(r9, r4); |
1689 __ ldr(r9, MemOperand(sp, 0 * kPointerSize)); | 1798 __ LoadP(r11, MemOperand(sp, 0 * kPointerSize)); |
1690 __ add(r9, r9, Operand(Smi::FromInt(Context::MIN_CONTEXT_SLOTS))); | 1799 __ AddSmiLiteral(r11, r11, Smi::FromInt(Context::MIN_CONTEXT_SLOTS), r0); |
1691 __ sub(r9, r9, Operand(r1)); | 1800 __ sub(r11, r11, r4); |
1692 __ LoadRoot(r5, Heap::kTheHoleValueRootIndex); | 1801 __ LoadRoot(r10, Heap::kTheHoleValueRootIndex); |
1693 __ add(r3, r4, Operand(r6, LSL, 1)); | 1802 __ SmiToPtrArrayOffset(r6, r9); |
1694 __ add(r3, r3, Operand(kParameterMapHeaderSize)); | 1803 __ add(r6, r7, r6); |
| 1804 __ addi(r6, r6, Operand(kParameterMapHeaderSize)); |
1695 | 1805 |
1696 // r6 = loop variable (tagged) | 1806 // r9 = loop variable (tagged) |
1697 // r1 = mapping index (tagged) | 1807 // r4 = mapping index (tagged) |
1698 // r3 = address of backing store (tagged) | 1808 // r6 = address of backing store (tagged) |
1699 // r4 = address of parameter map (tagged), which is also the address of new | 1809 // r7 = address of parameter map (tagged) |
1700 // object + Heap::kSloppyArgumentsObjectSize (tagged) | 1810 // r8 = temporary scratch (a.o., for address calculation) |
1701 // r0 = temporary scratch (a.o., for address calculation) | 1811 // r10 = the hole value |
1702 // r5 = the hole value | 1812 __ b(¶meters_test); |
1703 __ jmp(¶meters_test); | |
1704 | 1813 |
1705 __ bind(¶meters_loop); | 1814 __ bind(¶meters_loop); |
1706 __ sub(r6, r6, Operand(Smi::FromInt(1))); | 1815 __ SubSmiLiteral(r9, r9, Smi::FromInt(1), r0); |
1707 __ mov(r0, Operand(r6, LSL, 1)); | 1816 __ SmiToPtrArrayOffset(r8, r9); |
1708 __ add(r0, r0, Operand(kParameterMapHeaderSize - kHeapObjectTag)); | 1817 __ addi(r8, r8, Operand(kParameterMapHeaderSize - kHeapObjectTag)); |
1709 __ str(r9, MemOperand(r4, r0)); | 1818 __ StorePX(r11, MemOperand(r8, r7)); |
1710 __ sub(r0, r0, Operand(kParameterMapHeaderSize - FixedArray::kHeaderSize)); | 1819 __ subi(r8, r8, Operand(kParameterMapHeaderSize - FixedArray::kHeaderSize)); |
1711 __ str(r5, MemOperand(r3, r0)); | 1820 __ StorePX(r10, MemOperand(r8, r6)); |
1712 __ add(r9, r9, Operand(Smi::FromInt(1))); | 1821 __ AddSmiLiteral(r11, r11, Smi::FromInt(1), r0); |
1713 __ bind(¶meters_test); | 1822 __ bind(¶meters_test); |
1714 __ cmp(r6, Operand(Smi::FromInt(0))); | 1823 __ CmpSmiLiteral(r9, Smi::FromInt(0), r0); |
1715 __ b(ne, ¶meters_loop); | 1824 __ bne(¶meters_loop); |
1716 | |
1717 // Restore r0 = new object (tagged) | |
1718 __ sub(r0, r4, Operand(Heap::kSloppyArgumentsObjectSize)); | |
1719 | 1825 |
1720 __ bind(&skip_parameter_map); | 1826 __ bind(&skip_parameter_map); |
1721 // r0 = address of new object (tagged) | 1827 // r5 = argument count (tagged) |
1722 // r2 = argument count (tagged) | 1828 // r6 = address of backing store (tagged) |
1723 // r3 = address of backing store (tagged) | 1829 // r8 = scratch |
1724 // r5 = scratch | |
1725 // Copy arguments header and remaining slots (if there are any). | 1830 // Copy arguments header and remaining slots (if there are any). |
1726 __ LoadRoot(r5, Heap::kFixedArrayMapRootIndex); | 1831 __ LoadRoot(r8, Heap::kFixedArrayMapRootIndex); |
1727 __ str(r5, FieldMemOperand(r3, FixedArray::kMapOffset)); | 1832 __ StoreP(r8, FieldMemOperand(r6, FixedArray::kMapOffset), r0); |
1728 __ str(r2, FieldMemOperand(r3, FixedArray::kLengthOffset)); | 1833 __ StoreP(r5, FieldMemOperand(r6, FixedArray::kLengthOffset), r0); |
1729 | 1834 |
1730 Label arguments_loop, arguments_test; | 1835 Label arguments_loop, arguments_test; |
1731 __ mov(r9, r1); | 1836 __ mr(r11, r4); |
1732 __ ldr(r4, MemOperand(sp, 1 * kPointerSize)); | 1837 __ LoadP(r7, MemOperand(sp, 1 * kPointerSize)); |
1733 __ sub(r4, r4, Operand(r9, LSL, 1)); | 1838 __ SmiToPtrArrayOffset(r8, r11); |
1734 __ jmp(&arguments_test); | 1839 __ sub(r7, r7, r8); |
| 1840 __ b(&arguments_test); |
1735 | 1841 |
1736 __ bind(&arguments_loop); | 1842 __ bind(&arguments_loop); |
1737 __ sub(r4, r4, Operand(kPointerSize)); | 1843 __ subi(r7, r7, Operand(kPointerSize)); |
1738 __ ldr(r6, MemOperand(r4, 0)); | 1844 __ LoadP(r9, MemOperand(r7, 0)); |
1739 __ add(r5, r3, Operand(r9, LSL, 1)); | 1845 __ SmiToPtrArrayOffset(r8, r11); |
1740 __ str(r6, FieldMemOperand(r5, FixedArray::kHeaderSize)); | 1846 __ add(r8, r6, r8); |
1741 __ add(r9, r9, Operand(Smi::FromInt(1))); | 1847 __ StoreP(r9, FieldMemOperand(r8, FixedArray::kHeaderSize), r0); |
| 1848 __ AddSmiLiteral(r11, r11, Smi::FromInt(1), r0); |
1742 | 1849 |
1743 __ bind(&arguments_test); | 1850 __ bind(&arguments_test); |
1744 __ cmp(r9, Operand(r2)); | 1851 __ cmp(r11, r5); |
1745 __ b(lt, &arguments_loop); | 1852 __ blt(&arguments_loop); |
1746 | 1853 |
1747 // Return and remove the on-stack parameters. | 1854 // Return and remove the on-stack parameters. |
1748 __ add(sp, sp, Operand(3 * kPointerSize)); | 1855 __ addi(sp, sp, Operand(3 * kPointerSize)); |
1749 __ Ret(); | 1856 __ Ret(); |
1750 | 1857 |
1751 // Do the runtime call to allocate the arguments object. | 1858 // Do the runtime call to allocate the arguments object. |
1752 // r0 = address of new object (tagged) | 1859 // r5 = argument count (tagged) |
1753 // r2 = argument count (tagged) | |
1754 __ bind(&runtime); | 1860 __ bind(&runtime); |
1755 __ str(r2, MemOperand(sp, 0 * kPointerSize)); // Patch argument count. | 1861 __ StoreP(r5, MemOperand(sp, 0 * kPointerSize)); // Patch argument count. |
1756 __ TailCallRuntime(Runtime::kNewSloppyArguments, 3, 1); | 1862 __ TailCallRuntime(Runtime::kNewSloppyArguments, 3, 1); |
1757 } | 1863 } |
1758 | 1864 |
1759 | 1865 |
1760 void LoadIndexedInterceptorStub::Generate(MacroAssembler* masm) { | 1866 void LoadIndexedInterceptorStub::Generate(MacroAssembler* masm) { |
1761 // Return address is in lr. | 1867 // Return address is in lr. |
1762 Label slow; | 1868 Label slow; |
1763 | 1869 |
1764 Register receiver = LoadDescriptor::ReceiverRegister(); | 1870 Register receiver = LoadDescriptor::ReceiverRegister(); |
1765 Register key = LoadDescriptor::NameRegister(); | 1871 Register key = LoadDescriptor::NameRegister(); |
1766 | 1872 |
1767 // Check that the key is an array index, that is Uint32. | 1873 // Check that the key is an array index, that is Uint32. |
1768 __ NonNegativeSmiTst(key); | 1874 __ TestIfPositiveSmi(key, r0); |
1769 __ b(ne, &slow); | 1875 __ bne(&slow, cr0); |
1770 | 1876 |
1771 // Everything is fine, call runtime. | 1877 // Everything is fine, call runtime. |
1772 __ Push(receiver, key); // Receiver, key. | 1878 __ Push(receiver, key); // Receiver, key. |
1773 | 1879 |
1774 // Perform tail call to the entry. | 1880 // Perform tail call to the entry. |
1775 __ TailCallExternalReference( | 1881 __ TailCallExternalReference( |
1776 ExternalReference(IC_Utility(IC::kLoadElementWithInterceptor), | 1882 ExternalReference(IC_Utility(IC::kLoadElementWithInterceptor), |
1777 masm->isolate()), | 1883 masm->isolate()), |
1778 2, 1); | 1884 2, 1); |
1779 | 1885 |
1780 __ bind(&slow); | 1886 __ bind(&slow); |
1781 PropertyAccessCompiler::TailCallBuiltin( | 1887 PropertyAccessCompiler::TailCallBuiltin( |
1782 masm, PropertyAccessCompiler::MissBuiltin(Code::KEYED_LOAD_IC)); | 1888 masm, PropertyAccessCompiler::MissBuiltin(Code::KEYED_LOAD_IC)); |
1783 } | 1889 } |
1784 | 1890 |
1785 | 1891 |
1786 void ArgumentsAccessStub::GenerateNewStrict(MacroAssembler* masm) { | 1892 void ArgumentsAccessStub::GenerateNewStrict(MacroAssembler* masm) { |
1787 // sp[0] : number of parameters | 1893 // sp[0] : number of parameters |
1788 // sp[4] : receiver displacement | 1894 // sp[4] : receiver displacement |
1789 // sp[8] : function | 1895 // sp[8] : function |
1790 // Check if the calling frame is an arguments adaptor frame. | 1896 // Check if the calling frame is an arguments adaptor frame. |
1791 Label adaptor_frame, try_allocate, runtime; | 1897 Label adaptor_frame, try_allocate, runtime; |
1792 __ ldr(r2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | 1898 __ LoadP(r5, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
1793 __ ldr(r3, MemOperand(r2, StandardFrameConstants::kContextOffset)); | 1899 __ LoadP(r6, MemOperand(r5, StandardFrameConstants::kContextOffset)); |
1794 __ cmp(r3, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 1900 STATIC_ASSERT(StackFrame::ARGUMENTS_ADAPTOR < 0x3fffu); |
1795 __ b(eq, &adaptor_frame); | 1901 __ CmpSmiLiteral(r6, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0); |
| 1902 __ beq(&adaptor_frame); |
1796 | 1903 |
1797 // Get the length from the frame. | 1904 // Get the length from the frame. |
1798 __ ldr(r1, MemOperand(sp, 0)); | 1905 __ LoadP(r4, MemOperand(sp, 0)); |
1799 __ b(&try_allocate); | 1906 __ b(&try_allocate); |
1800 | 1907 |
1801 // Patch the arguments.length and the parameters pointer. | 1908 // Patch the arguments.length and the parameters pointer. |
1802 __ bind(&adaptor_frame); | 1909 __ bind(&adaptor_frame); |
1803 __ ldr(r1, MemOperand(r2, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 1910 __ LoadP(r4, MemOperand(r5, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
1804 __ str(r1, MemOperand(sp, 0)); | 1911 __ StoreP(r4, MemOperand(sp, 0)); |
1805 __ add(r3, r2, Operand::PointerOffsetFromSmiKey(r1)); | 1912 __ SmiToPtrArrayOffset(r6, r4); |
1806 __ add(r3, r3, Operand(StandardFrameConstants::kCallerSPOffset)); | 1913 __ add(r6, r5, r6); |
1807 __ str(r3, MemOperand(sp, 1 * kPointerSize)); | 1914 __ addi(r6, r6, Operand(StandardFrameConstants::kCallerSPOffset)); |
| 1915 __ StoreP(r6, MemOperand(sp, 1 * kPointerSize)); |
1808 | 1916 |
1809 // Try the new space allocation. Start out with computing the size | 1917 // Try the new space allocation. Start out with computing the size |
1810 // of the arguments object and the elements array in words. | 1918 // of the arguments object and the elements array in words. |
1811 Label add_arguments_object; | 1919 Label add_arguments_object; |
1812 __ bind(&try_allocate); | 1920 __ bind(&try_allocate); |
1813 __ SmiUntag(r1, SetCC); | 1921 __ cmpi(r4, Operand::Zero()); |
1814 __ b(eq, &add_arguments_object); | 1922 __ beq(&add_arguments_object); |
1815 __ add(r1, r1, Operand(FixedArray::kHeaderSize / kPointerSize)); | 1923 __ SmiUntag(r4); |
| 1924 __ addi(r4, r4, Operand(FixedArray::kHeaderSize / kPointerSize)); |
1816 __ bind(&add_arguments_object); | 1925 __ bind(&add_arguments_object); |
1817 __ add(r1, r1, Operand(Heap::kStrictArgumentsObjectSize / kPointerSize)); | 1926 __ addi(r4, r4, Operand(Heap::kStrictArgumentsObjectSize / kPointerSize)); |
1818 | 1927 |
1819 // Do the allocation of both objects in one go. | 1928 // Do the allocation of both objects in one go. |
1820 __ Allocate(r1, r0, r2, r3, &runtime, | 1929 __ Allocate(r4, r3, r5, r6, &runtime, |
1821 static_cast<AllocationFlags>(TAG_OBJECT | SIZE_IN_WORDS)); | 1930 static_cast<AllocationFlags>(TAG_OBJECT | SIZE_IN_WORDS)); |
1822 | 1931 |
1823 // Get the arguments boilerplate from the current native context. | 1932 // Get the arguments boilerplate from the current native context. |
1824 __ ldr(r4, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 1933 __ LoadP(r7, |
1825 __ ldr(r4, FieldMemOperand(r4, GlobalObject::kNativeContextOffset)); | 1934 MemOperand(cp, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
1826 __ ldr(r4, MemOperand( | 1935 __ LoadP(r7, FieldMemOperand(r7, GlobalObject::kNativeContextOffset)); |
1827 r4, Context::SlotOffset(Context::STRICT_ARGUMENTS_MAP_INDEX))); | 1936 __ LoadP( |
| 1937 r7, |
| 1938 MemOperand(r7, Context::SlotOffset(Context::STRICT_ARGUMENTS_MAP_INDEX))); |
1828 | 1939 |
1829 __ str(r4, FieldMemOperand(r0, JSObject::kMapOffset)); | 1940 __ StoreP(r7, FieldMemOperand(r3, JSObject::kMapOffset), r0); |
1830 __ LoadRoot(r3, Heap::kEmptyFixedArrayRootIndex); | 1941 __ LoadRoot(r6, Heap::kEmptyFixedArrayRootIndex); |
1831 __ str(r3, FieldMemOperand(r0, JSObject::kPropertiesOffset)); | 1942 __ StoreP(r6, FieldMemOperand(r3, JSObject::kPropertiesOffset), r0); |
1832 __ str(r3, FieldMemOperand(r0, JSObject::kElementsOffset)); | 1943 __ StoreP(r6, FieldMemOperand(r3, JSObject::kElementsOffset), r0); |
1833 | 1944 |
1834 // Get the length (smi tagged) and set that as an in-object property too. | 1945 // Get the length (smi tagged) and set that as an in-object property too. |
1835 STATIC_ASSERT(Heap::kArgumentsLengthIndex == 0); | 1946 STATIC_ASSERT(Heap::kArgumentsLengthIndex == 0); |
1836 __ ldr(r1, MemOperand(sp, 0 * kPointerSize)); | 1947 __ LoadP(r4, MemOperand(sp, 0 * kPointerSize)); |
1837 __ AssertSmi(r1); | 1948 __ AssertSmi(r4); |
1838 __ str(r1, FieldMemOperand(r0, JSObject::kHeaderSize + | 1949 __ StoreP(r4, |
1839 Heap::kArgumentsLengthIndex * kPointerSize)); | 1950 FieldMemOperand(r3, JSObject::kHeaderSize + |
| 1951 Heap::kArgumentsLengthIndex * kPointerSize), |
| 1952 r0); |
1840 | 1953 |
1841 // If there are no actual arguments, we're done. | 1954 // If there are no actual arguments, we're done. |
1842 Label done; | 1955 Label done; |
1843 __ cmp(r1, Operand::Zero()); | 1956 __ cmpi(r4, Operand::Zero()); |
1844 __ b(eq, &done); | 1957 __ beq(&done); |
1845 | 1958 |
1846 // Get the parameters pointer from the stack. | 1959 // Get the parameters pointer from the stack. |
1847 __ ldr(r2, MemOperand(sp, 1 * kPointerSize)); | 1960 __ LoadP(r5, MemOperand(sp, 1 * kPointerSize)); |
1848 | 1961 |
1849 // Set up the elements pointer in the allocated arguments object and | 1962 // Set up the elements pointer in the allocated arguments object and |
1850 // initialize the header in the elements fixed array. | 1963 // initialize the header in the elements fixed array. |
1851 __ add(r4, r0, Operand(Heap::kStrictArgumentsObjectSize)); | 1964 __ addi(r7, r3, Operand(Heap::kStrictArgumentsObjectSize)); |
1852 __ str(r4, FieldMemOperand(r0, JSObject::kElementsOffset)); | 1965 __ StoreP(r7, FieldMemOperand(r3, JSObject::kElementsOffset), r0); |
1853 __ LoadRoot(r3, Heap::kFixedArrayMapRootIndex); | 1966 __ LoadRoot(r6, Heap::kFixedArrayMapRootIndex); |
1854 __ str(r3, FieldMemOperand(r4, FixedArray::kMapOffset)); | 1967 __ StoreP(r6, FieldMemOperand(r7, FixedArray::kMapOffset), r0); |
1855 __ str(r1, FieldMemOperand(r4, FixedArray::kLengthOffset)); | 1968 __ StoreP(r4, FieldMemOperand(r7, FixedArray::kLengthOffset), r0); |
1856 __ SmiUntag(r1); | 1969 // Untag the length for the loop. |
| 1970 __ SmiUntag(r4); |
1857 | 1971 |
1858 // Copy the fixed array slots. | 1972 // Copy the fixed array slots. |
1859 Label loop; | 1973 Label loop; |
1860 // Set up r4 to point to the first array slot. | 1974 // Set up r7 to point just prior to the first array slot. |
1861 __ add(r4, r4, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | 1975 __ addi(r7, r7, |
| 1976 Operand(FixedArray::kHeaderSize - kHeapObjectTag - kPointerSize)); |
| 1977 __ mtctr(r4); |
1862 __ bind(&loop); | 1978 __ bind(&loop); |
1863 // Pre-decrement r2 with kPointerSize on each iteration. | 1979 // Pre-decrement r5 with kPointerSize on each iteration. |
1864 // Pre-decrement in order to skip receiver. | 1980 // Pre-decrement in order to skip receiver. |
1865 __ ldr(r3, MemOperand(r2, kPointerSize, NegPreIndex)); | 1981 __ LoadPU(r6, MemOperand(r5, -kPointerSize)); |
1866 // Post-increment r4 with kPointerSize on each iteration. | 1982 // Pre-increment r7 with kPointerSize on each iteration. |
1867 __ str(r3, MemOperand(r4, kPointerSize, PostIndex)); | 1983 __ StorePU(r6, MemOperand(r7, kPointerSize)); |
1868 __ sub(r1, r1, Operand(1)); | 1984 __ bdnz(&loop); |
1869 __ cmp(r1, Operand::Zero()); | |
1870 __ b(ne, &loop); | |
1871 | 1985 |
1872 // Return and remove the on-stack parameters. | 1986 // Return and remove the on-stack parameters. |
1873 __ bind(&done); | 1987 __ bind(&done); |
1874 __ add(sp, sp, Operand(3 * kPointerSize)); | 1988 __ addi(sp, sp, Operand(3 * kPointerSize)); |
1875 __ Ret(); | 1989 __ Ret(); |
1876 | 1990 |
1877 // Do the runtime call to allocate the arguments object. | 1991 // Do the runtime call to allocate the arguments object. |
1878 __ bind(&runtime); | 1992 __ bind(&runtime); |
1879 __ TailCallRuntime(Runtime::kNewStrictArguments, 3, 1); | 1993 __ TailCallRuntime(Runtime::kNewStrictArguments, 3, 1); |
1880 } | 1994 } |
1881 | 1995 |
1882 | 1996 |
1883 void RegExpExecStub::Generate(MacroAssembler* masm) { | 1997 void RegExpExecStub::Generate(MacroAssembler* masm) { |
1884 // Just jump directly to runtime if native RegExp is not selected at compile | 1998 // Just jump directly to runtime if native RegExp is not selected at compile |
1885 // time or if regexp entry in generated code is turned off runtime switch or | 1999 // time or if regexp entry in generated code is turned off runtime switch or |
1886 // at compilation. | 2000 // at compilation. |
1887 #ifdef V8_INTERPRETED_REGEXP | 2001 #ifdef V8_INTERPRETED_REGEXP |
1888 __ TailCallRuntime(Runtime::kRegExpExecRT, 4, 1); | 2002 __ TailCallRuntime(Runtime::kRegExpExecRT, 4, 1); |
1889 #else // V8_INTERPRETED_REGEXP | 2003 #else // V8_INTERPRETED_REGEXP |
1890 | 2004 |
1891 // Stack frame on entry. | 2005 // Stack frame on entry. |
1892 // sp[0]: last_match_info (expected JSArray) | 2006 // sp[0]: last_match_info (expected JSArray) |
1893 // sp[4]: previous index | 2007 // sp[4]: previous index |
1894 // sp[8]: subject string | 2008 // sp[8]: subject string |
1895 // sp[12]: JSRegExp object | 2009 // sp[12]: JSRegExp object |
1896 | 2010 |
1897 const int kLastMatchInfoOffset = 0 * kPointerSize; | 2011 const int kLastMatchInfoOffset = 0 * kPointerSize; |
1898 const int kPreviousIndexOffset = 1 * kPointerSize; | 2012 const int kPreviousIndexOffset = 1 * kPointerSize; |
1899 const int kSubjectOffset = 2 * kPointerSize; | 2013 const int kSubjectOffset = 2 * kPointerSize; |
1900 const int kJSRegExpOffset = 3 * kPointerSize; | 2014 const int kJSRegExpOffset = 3 * kPointerSize; |
1901 | 2015 |
1902 Label runtime; | 2016 Label runtime, br_over, encoding_type_UC16; |
| 2017 |
1903 // Allocation of registers for this function. These are in callee save | 2018 // Allocation of registers for this function. These are in callee save |
1904 // registers and will be preserved by the call to the native RegExp code, as | 2019 // registers and will be preserved by the call to the native RegExp code, as |
1905 // this code is called using the normal C calling convention. When calling | 2020 // this code is called using the normal C calling convention. When calling |
1906 // directly from generated code the native RegExp code will not do a GC and | 2021 // directly from generated code the native RegExp code will not do a GC and |
1907 // therefore the content of these registers are safe to use after the call. | 2022 // therefore the content of these registers are safe to use after the call. |
1908 Register subject = r4; | 2023 Register subject = r14; |
1909 Register regexp_data = r5; | 2024 Register regexp_data = r15; |
1910 Register last_match_info_elements = no_reg; // will be r6; | 2025 Register last_match_info_elements = r16; |
| 2026 Register code = r17; |
| 2027 |
| 2028 // Ensure register assigments are consistent with callee save masks |
| 2029 DCHECK(subject.bit() & kCalleeSaved); |
| 2030 DCHECK(regexp_data.bit() & kCalleeSaved); |
| 2031 DCHECK(last_match_info_elements.bit() & kCalleeSaved); |
| 2032 DCHECK(code.bit() & kCalleeSaved); |
1911 | 2033 |
1912 // Ensure that a RegExp stack is allocated. | 2034 // Ensure that a RegExp stack is allocated. |
1913 ExternalReference address_of_regexp_stack_memory_address = | 2035 ExternalReference address_of_regexp_stack_memory_address = |
1914 ExternalReference::address_of_regexp_stack_memory_address(isolate()); | 2036 ExternalReference::address_of_regexp_stack_memory_address(isolate()); |
1915 ExternalReference address_of_regexp_stack_memory_size = | 2037 ExternalReference address_of_regexp_stack_memory_size = |
1916 ExternalReference::address_of_regexp_stack_memory_size(isolate()); | 2038 ExternalReference::address_of_regexp_stack_memory_size(isolate()); |
1917 __ mov(r0, Operand(address_of_regexp_stack_memory_size)); | 2039 __ mov(r3, Operand(address_of_regexp_stack_memory_size)); |
1918 __ ldr(r0, MemOperand(r0, 0)); | 2040 __ LoadP(r3, MemOperand(r3, 0)); |
1919 __ cmp(r0, Operand::Zero()); | 2041 __ cmpi(r3, Operand::Zero()); |
1920 __ b(eq, &runtime); | 2042 __ beq(&runtime); |
1921 | 2043 |
1922 // Check that the first argument is a JSRegExp object. | 2044 // Check that the first argument is a JSRegExp object. |
1923 __ ldr(r0, MemOperand(sp, kJSRegExpOffset)); | 2045 __ LoadP(r3, MemOperand(sp, kJSRegExpOffset)); |
1924 __ JumpIfSmi(r0, &runtime); | 2046 __ JumpIfSmi(r3, &runtime); |
1925 __ CompareObjectType(r0, r1, r1, JS_REGEXP_TYPE); | 2047 __ CompareObjectType(r3, r4, r4, JS_REGEXP_TYPE); |
1926 __ b(ne, &runtime); | 2048 __ bne(&runtime); |
1927 | 2049 |
1928 // Check that the RegExp has been compiled (data contains a fixed array). | 2050 // Check that the RegExp has been compiled (data contains a fixed array). |
1929 __ ldr(regexp_data, FieldMemOperand(r0, JSRegExp::kDataOffset)); | 2051 __ LoadP(regexp_data, FieldMemOperand(r3, JSRegExp::kDataOffset)); |
1930 if (FLAG_debug_code) { | 2052 if (FLAG_debug_code) { |
1931 __ SmiTst(regexp_data); | 2053 __ TestIfSmi(regexp_data, r0); |
1932 __ Check(ne, kUnexpectedTypeForRegExpDataFixedArrayExpected); | 2054 __ Check(ne, kUnexpectedTypeForRegExpDataFixedArrayExpected, cr0); |
1933 __ CompareObjectType(regexp_data, r0, r0, FIXED_ARRAY_TYPE); | 2055 __ CompareObjectType(regexp_data, r3, r3, FIXED_ARRAY_TYPE); |
1934 __ Check(eq, kUnexpectedTypeForRegExpDataFixedArrayExpected); | 2056 __ Check(eq, kUnexpectedTypeForRegExpDataFixedArrayExpected); |
1935 } | 2057 } |
1936 | 2058 |
1937 // regexp_data: RegExp data (FixedArray) | 2059 // regexp_data: RegExp data (FixedArray) |
1938 // Check the type of the RegExp. Only continue if type is JSRegExp::IRREGEXP. | 2060 // Check the type of the RegExp. Only continue if type is JSRegExp::IRREGEXP. |
1939 __ ldr(r0, FieldMemOperand(regexp_data, JSRegExp::kDataTagOffset)); | 2061 __ LoadP(r3, FieldMemOperand(regexp_data, JSRegExp::kDataTagOffset)); |
1940 __ cmp(r0, Operand(Smi::FromInt(JSRegExp::IRREGEXP))); | 2062 // DCHECK(Smi::FromInt(JSRegExp::IRREGEXP) < (char *)0xffffu); |
1941 __ b(ne, &runtime); | 2063 __ CmpSmiLiteral(r3, Smi::FromInt(JSRegExp::IRREGEXP), r0); |
| 2064 __ bne(&runtime); |
1942 | 2065 |
1943 // regexp_data: RegExp data (FixedArray) | 2066 // regexp_data: RegExp data (FixedArray) |
1944 // Check that the number of captures fit in the static offsets vector buffer. | 2067 // Check that the number of captures fit in the static offsets vector buffer. |
1945 __ ldr(r2, | 2068 __ LoadP(r5, |
1946 FieldMemOperand(regexp_data, JSRegExp::kIrregexpCaptureCountOffset)); | 2069 FieldMemOperand(regexp_data, JSRegExp::kIrregexpCaptureCountOffset)); |
1947 // Check (number_of_captures + 1) * 2 <= offsets vector size | 2070 // Check (number_of_captures + 1) * 2 <= offsets vector size |
1948 // Or number_of_captures * 2 <= offsets vector size - 2 | 2071 // Or number_of_captures * 2 <= offsets vector size - 2 |
1949 // Multiplying by 2 comes for free since r2 is smi-tagged. | 2072 // SmiToShortArrayOffset accomplishes the multiplication by 2 and |
1950 STATIC_ASSERT(kSmiTag == 0); | 2073 // SmiUntag (which is a nop for 32-bit). |
1951 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); | 2074 __ SmiToShortArrayOffset(r5, r5); |
1952 STATIC_ASSERT(Isolate::kJSRegexpStaticOffsetsVectorSize >= 2); | 2075 STATIC_ASSERT(Isolate::kJSRegexpStaticOffsetsVectorSize >= 2); |
1953 __ cmp(r2, Operand(Isolate::kJSRegexpStaticOffsetsVectorSize - 2)); | 2076 __ cmpli(r5, Operand(Isolate::kJSRegexpStaticOffsetsVectorSize - 2)); |
1954 __ b(hi, &runtime); | 2077 __ bgt(&runtime); |
1955 | 2078 |
1956 // Reset offset for possibly sliced string. | 2079 // Reset offset for possibly sliced string. |
1957 __ mov(r9, Operand::Zero()); | 2080 __ li(r11, Operand::Zero()); |
1958 __ ldr(subject, MemOperand(sp, kSubjectOffset)); | 2081 __ LoadP(subject, MemOperand(sp, kSubjectOffset)); |
1959 __ JumpIfSmi(subject, &runtime); | 2082 __ JumpIfSmi(subject, &runtime); |
1960 __ mov(r3, subject); // Make a copy of the original subject string. | 2083 __ mr(r6, subject); // Make a copy of the original subject string. |
1961 __ ldr(r0, FieldMemOperand(subject, HeapObject::kMapOffset)); | 2084 __ LoadP(r3, FieldMemOperand(subject, HeapObject::kMapOffset)); |
1962 __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset)); | 2085 __ lbz(r3, FieldMemOperand(r3, Map::kInstanceTypeOffset)); |
1963 // subject: subject string | 2086 // subject: subject string |
1964 // r3: subject string | 2087 // r6: subject string |
1965 // r0: subject string instance type | 2088 // r3: subject string instance type |
1966 // regexp_data: RegExp data (FixedArray) | 2089 // regexp_data: RegExp data (FixedArray) |
1967 // Handle subject string according to its encoding and representation: | 2090 // Handle subject string according to its encoding and representation: |
1968 // (1) Sequential string? If yes, go to (5). | 2091 // (1) Sequential string? If yes, go to (5). |
1969 // (2) Anything but sequential or cons? If yes, go to (6). | 2092 // (2) Anything but sequential or cons? If yes, go to (6). |
1970 // (3) Cons string. If the string is flat, replace subject with first string. | 2093 // (3) Cons string. If the string is flat, replace subject with first string. |
1971 // Otherwise bailout. | 2094 // Otherwise bailout. |
1972 // (4) Is subject external? If yes, go to (7). | 2095 // (4) Is subject external? If yes, go to (7). |
1973 // (5) Sequential string. Load regexp code according to encoding. | 2096 // (5) Sequential string. Load regexp code according to encoding. |
1974 // (E) Carry on. | 2097 // (E) Carry on. |
1975 /// [...] | 2098 /// [...] |
1976 | 2099 |
1977 // Deferred code at the end of the stub: | 2100 // Deferred code at the end of the stub: |
1978 // (6) Not a long external string? If yes, go to (8). | 2101 // (6) Not a long external string? If yes, go to (8). |
1979 // (7) External string. Make it, offset-wise, look like a sequential string. | 2102 // (7) External string. Make it, offset-wise, look like a sequential string. |
1980 // Go to (5). | 2103 // Go to (5). |
1981 // (8) Short external string or not a string? If yes, bail out to runtime. | 2104 // (8) Short external string or not a string? If yes, bail out to runtime. |
1982 // (9) Sliced string. Replace subject with parent. Go to (4). | 2105 // (9) Sliced string. Replace subject with parent. Go to (4). |
1983 | 2106 |
1984 Label seq_string /* 5 */, external_string /* 7 */, | 2107 Label seq_string /* 5 */, external_string /* 7 */, check_underlying /* 4 */, |
1985 check_underlying /* 4 */, not_seq_nor_cons /* 6 */, | 2108 not_seq_nor_cons /* 6 */, not_long_external /* 8 */; |
1986 not_long_external /* 8 */; | |
1987 | 2109 |
1988 // (1) Sequential string? If yes, go to (5). | 2110 // (1) Sequential string? If yes, go to (5). |
1989 __ and_(r1, | 2111 STATIC_ASSERT((kIsNotStringMask | kStringRepresentationMask | |
1990 r0, | 2112 kShortExternalStringMask) == 0x93); |
1991 Operand(kIsNotStringMask | | 2113 __ andi(r4, r3, Operand(kIsNotStringMask | kStringRepresentationMask | |
1992 kStringRepresentationMask | | 2114 kShortExternalStringMask)); |
1993 kShortExternalStringMask), | |
1994 SetCC); | |
1995 STATIC_ASSERT((kStringTag | kSeqStringTag) == 0); | 2115 STATIC_ASSERT((kStringTag | kSeqStringTag) == 0); |
1996 __ b(eq, &seq_string); // Go to (5). | 2116 __ beq(&seq_string, cr0); // Go to (5). |
1997 | 2117 |
1998 // (2) Anything but sequential or cons? If yes, go to (6). | 2118 // (2) Anything but sequential or cons? If yes, go to (6). |
1999 STATIC_ASSERT(kConsStringTag < kExternalStringTag); | 2119 STATIC_ASSERT(kConsStringTag < kExternalStringTag); |
2000 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag); | 2120 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag); |
2001 STATIC_ASSERT(kIsNotStringMask > kExternalStringTag); | 2121 STATIC_ASSERT(kIsNotStringMask > kExternalStringTag); |
2002 STATIC_ASSERT(kShortExternalStringTag > kExternalStringTag); | 2122 STATIC_ASSERT(kShortExternalStringTag > kExternalStringTag); |
2003 __ cmp(r1, Operand(kExternalStringTag)); | 2123 STATIC_ASSERT(kExternalStringTag < 0xffffu); |
2004 __ b(ge, ¬_seq_nor_cons); // Go to (6). | 2124 __ cmpi(r4, Operand(kExternalStringTag)); |
| 2125 __ bge(¬_seq_nor_cons); // Go to (6). |
2005 | 2126 |
2006 // (3) Cons string. Check that it's flat. | 2127 // (3) Cons string. Check that it's flat. |
2007 // Replace subject with first string and reload instance type. | 2128 // Replace subject with first string and reload instance type. |
2008 __ ldr(r0, FieldMemOperand(subject, ConsString::kSecondOffset)); | 2129 __ LoadP(r3, FieldMemOperand(subject, ConsString::kSecondOffset)); |
2009 __ CompareRoot(r0, Heap::kempty_stringRootIndex); | 2130 __ CompareRoot(r3, Heap::kempty_stringRootIndex); |
2010 __ b(ne, &runtime); | 2131 __ bne(&runtime); |
2011 __ ldr(subject, FieldMemOperand(subject, ConsString::kFirstOffset)); | 2132 __ LoadP(subject, FieldMemOperand(subject, ConsString::kFirstOffset)); |
2012 | 2133 |
2013 // (4) Is subject external? If yes, go to (7). | 2134 // (4) Is subject external? If yes, go to (7). |
2014 __ bind(&check_underlying); | 2135 __ bind(&check_underlying); |
2015 __ ldr(r0, FieldMemOperand(subject, HeapObject::kMapOffset)); | 2136 __ LoadP(r3, FieldMemOperand(subject, HeapObject::kMapOffset)); |
2016 __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset)); | 2137 __ lbz(r3, FieldMemOperand(r3, Map::kInstanceTypeOffset)); |
2017 STATIC_ASSERT(kSeqStringTag == 0); | 2138 STATIC_ASSERT(kSeqStringTag == 0); |
2018 __ tst(r0, Operand(kStringRepresentationMask)); | 2139 STATIC_ASSERT(kStringRepresentationMask == 3); |
| 2140 __ andi(r0, r3, Operand(kStringRepresentationMask)); |
2019 // The underlying external string is never a short external string. | 2141 // The underlying external string is never a short external string. |
2020 STATIC_ASSERT(ExternalString::kMaxShortLength < ConsString::kMinLength); | 2142 STATIC_ASSERT(ExternalString::kMaxShortLength < ConsString::kMinLength); |
2021 STATIC_ASSERT(ExternalString::kMaxShortLength < SlicedString::kMinLength); | 2143 STATIC_ASSERT(ExternalString::kMaxShortLength < SlicedString::kMinLength); |
2022 __ b(ne, &external_string); // Go to (7). | 2144 __ bne(&external_string, cr0); // Go to (7). |
2023 | 2145 |
2024 // (5) Sequential string. Load regexp code according to encoding. | 2146 // (5) Sequential string. Load regexp code according to encoding. |
2025 __ bind(&seq_string); | 2147 __ bind(&seq_string); |
2026 // subject: sequential subject string (or look-alike, external string) | 2148 // subject: sequential subject string (or look-alike, external string) |
2027 // r3: original subject string | 2149 // r6: original subject string |
2028 // Load previous index and check range before r3 is overwritten. We have to | 2150 // Load previous index and check range before r6 is overwritten. We have to |
2029 // use r3 instead of subject here because subject might have been only made | 2151 // use r6 instead of subject here because subject might have been only made |
2030 // to look like a sequential string when it actually is an external string. | 2152 // to look like a sequential string when it actually is an external string. |
2031 __ ldr(r1, MemOperand(sp, kPreviousIndexOffset)); | 2153 __ LoadP(r4, MemOperand(sp, kPreviousIndexOffset)); |
2032 __ JumpIfNotSmi(r1, &runtime); | 2154 __ JumpIfNotSmi(r4, &runtime); |
2033 __ ldr(r3, FieldMemOperand(r3, String::kLengthOffset)); | 2155 __ LoadP(r6, FieldMemOperand(r6, String::kLengthOffset)); |
2034 __ cmp(r3, Operand(r1)); | 2156 __ cmpl(r6, r4); |
2035 __ b(ls, &runtime); | 2157 __ ble(&runtime); |
2036 __ SmiUntag(r1); | 2158 __ SmiUntag(r4); |
2037 | 2159 |
2038 STATIC_ASSERT(4 == kOneByteStringTag); | 2160 STATIC_ASSERT(4 == kOneByteStringTag); |
2039 STATIC_ASSERT(kTwoByteStringTag == 0); | 2161 STATIC_ASSERT(kTwoByteStringTag == 0); |
2040 __ and_(r0, r0, Operand(kStringEncodingMask)); | 2162 STATIC_ASSERT(kStringEncodingMask == 4); |
2041 __ mov(r3, Operand(r0, ASR, 2), SetCC); | 2163 __ ExtractBitMask(r6, r3, kStringEncodingMask, SetRC); |
2042 __ ldr(r6, FieldMemOperand(regexp_data, JSRegExp::kDataOneByteCodeOffset), | 2164 __ beq(&encoding_type_UC16, cr0); |
2043 ne); | 2165 __ LoadP(code, |
2044 __ ldr(r6, FieldMemOperand(regexp_data, JSRegExp::kDataUC16CodeOffset), eq); | 2166 FieldMemOperand(regexp_data, JSRegExp::kDataOneByteCodeOffset)); |
| 2167 __ b(&br_over); |
| 2168 __ bind(&encoding_type_UC16); |
| 2169 __ LoadP(code, FieldMemOperand(regexp_data, JSRegExp::kDataUC16CodeOffset)); |
| 2170 __ bind(&br_over); |
2045 | 2171 |
2046 // (E) Carry on. String handling is done. | 2172 // (E) Carry on. String handling is done. |
2047 // r6: irregexp code | 2173 // code: irregexp code |
2048 // Check that the irregexp code has been generated for the actual string | 2174 // Check that the irregexp code has been generated for the actual string |
2049 // encoding. If it has, the field contains a code object otherwise it contains | 2175 // encoding. If it has, the field contains a code object otherwise it contains |
2050 // a smi (code flushing support). | 2176 // a smi (code flushing support). |
2051 __ JumpIfSmi(r6, &runtime); | 2177 __ JumpIfSmi(code, &runtime); |
2052 | 2178 |
2053 // r1: previous index | 2179 // r4: previous index |
2054 // r3: encoding of subject string (1 if one_byte, 0 if two_byte); | 2180 // r6: encoding of subject string (1 if one_byte, 0 if two_byte); |
2055 // r6: code | 2181 // code: Address of generated regexp code |
2056 // subject: Subject string | 2182 // subject: Subject string |
2057 // regexp_data: RegExp data (FixedArray) | 2183 // regexp_data: RegExp data (FixedArray) |
2058 // All checks done. Now push arguments for native regexp code. | 2184 // All checks done. Now push arguments for native regexp code. |
2059 __ IncrementCounter(isolate()->counters()->regexp_entry_native(), 1, r0, r2); | 2185 __ IncrementCounter(isolate()->counters()->regexp_entry_native(), 1, r3, r5); |
2060 | 2186 |
2061 // Isolates: note we add an additional parameter here (isolate pointer). | 2187 // Isolates: note we add an additional parameter here (isolate pointer). |
2062 const int kRegExpExecuteArguments = 9; | 2188 const int kRegExpExecuteArguments = 10; |
2063 const int kParameterRegisters = 4; | 2189 const int kParameterRegisters = 8; |
2064 __ EnterExitFrame(false, kRegExpExecuteArguments - kParameterRegisters); | 2190 __ EnterExitFrame(false, kRegExpExecuteArguments - kParameterRegisters); |
2065 | 2191 |
2066 // Stack pointer now points to cell where return address is to be written. | 2192 // Stack pointer now points to cell where return address is to be written. |
2067 // Arguments are before that on the stack or in registers. | 2193 // Arguments are before that on the stack or in registers. |
2068 | 2194 |
2069 // Argument 9 (sp[20]): Pass current isolate address. | 2195 // Argument 10 (in stack parameter area): Pass current isolate address. |
2070 __ mov(r0, Operand(ExternalReference::isolate_address(isolate()))); | 2196 __ mov(r3, Operand(ExternalReference::isolate_address(isolate()))); |
2071 __ str(r0, MemOperand(sp, 5 * kPointerSize)); | 2197 __ StoreP(r3, MemOperand(sp, (kStackFrameExtraParamSlot + 1) * kPointerSize)); |
2072 | 2198 |
2073 // Argument 8 (sp[16]): Indicate that this is a direct call from JavaScript. | 2199 // Argument 9 is a dummy that reserves the space used for |
2074 __ mov(r0, Operand(1)); | 2200 // the return address added by the ExitFrame in native calls. |
2075 __ str(r0, MemOperand(sp, 4 * kPointerSize)); | 2201 |
2076 | 2202 // Argument 8 (r10): Indicate that this is a direct call from JavaScript. |
2077 // Argument 7 (sp[12]): Start (high end) of backtracking stack memory area. | 2203 __ li(r10, Operand(1)); |
2078 __ mov(r0, Operand(address_of_regexp_stack_memory_address)); | 2204 |
2079 __ ldr(r0, MemOperand(r0, 0)); | 2205 // Argument 7 (r9): Start (high end) of backtracking stack memory area. |
2080 __ mov(r2, Operand(address_of_regexp_stack_memory_size)); | 2206 __ mov(r3, Operand(address_of_regexp_stack_memory_address)); |
2081 __ ldr(r2, MemOperand(r2, 0)); | 2207 __ LoadP(r3, MemOperand(r3, 0)); |
2082 __ add(r0, r0, Operand(r2)); | 2208 __ mov(r5, Operand(address_of_regexp_stack_memory_size)); |
2083 __ str(r0, MemOperand(sp, 3 * kPointerSize)); | 2209 __ LoadP(r5, MemOperand(r5, 0)); |
2084 | 2210 __ add(r9, r3, r5); |
2085 // Argument 6: Set the number of capture registers to zero to force global | 2211 |
2086 // regexps to behave as non-global. This does not affect non-global regexps. | 2212 // Argument 6 (r8): Set the number of capture registers to zero to force |
2087 __ mov(r0, Operand::Zero()); | 2213 // global egexps to behave as non-global. This does not affect non-global |
2088 __ str(r0, MemOperand(sp, 2 * kPointerSize)); | 2214 // regexps. |
2089 | 2215 __ li(r8, Operand::Zero()); |
2090 // Argument 5 (sp[4]): static offsets vector buffer. | 2216 |
2091 __ mov(r0, | 2217 // Argument 5 (r7): static offsets vector buffer. |
2092 Operand(ExternalReference::address_of_static_offsets_vector( | 2218 __ mov( |
2093 isolate()))); | 2219 r7, |
2094 __ str(r0, MemOperand(sp, 1 * kPointerSize)); | 2220 Operand(ExternalReference::address_of_static_offsets_vector(isolate()))); |
2095 | 2221 |
2096 // For arguments 4 and 3 get string length, calculate start of string data and | 2222 // For arguments 4 (r6) and 3 (r5) get string length, calculate start of data |
2097 // calculate the shift of the index (0 for one-byte and 1 for two-byte). | 2223 // and calculate the shift of the index (0 for one-byte and 1 for two-byte). |
2098 __ add(r7, subject, Operand(SeqString::kHeaderSize - kHeapObjectTag)); | 2224 __ addi(r18, subject, Operand(SeqString::kHeaderSize - kHeapObjectTag)); |
2099 __ eor(r3, r3, Operand(1)); | 2225 __ xori(r6, r6, Operand(1)); |
2100 // Load the length from the original subject string from the previous stack | 2226 // Load the length from the original subject string from the previous stack |
2101 // frame. Therefore we have to use fp, which points exactly to two pointer | 2227 // frame. Therefore we have to use fp, which points exactly to two pointer |
2102 // sizes below the previous sp. (Because creating a new stack frame pushes | 2228 // sizes below the previous sp. (Because creating a new stack frame pushes |
2103 // the previous fp onto the stack and moves up sp by 2 * kPointerSize.) | 2229 // the previous fp onto the stack and moves up sp by 2 * kPointerSize.) |
2104 __ ldr(subject, MemOperand(fp, kSubjectOffset + 2 * kPointerSize)); | 2230 __ LoadP(subject, MemOperand(fp, kSubjectOffset + 2 * kPointerSize)); |
2105 // If slice offset is not 0, load the length from the original sliced string. | 2231 // If slice offset is not 0, load the length from the original sliced string. |
2106 // Argument 4, r3: End of string data | 2232 // Argument 4, r6: End of string data |
2107 // Argument 3, r2: Start of string data | 2233 // Argument 3, r5: Start of string data |
2108 // Prepare start and end index of the input. | 2234 // Prepare start and end index of the input. |
2109 __ add(r9, r7, Operand(r9, LSL, r3)); | 2235 __ ShiftLeft_(r11, r11, r6); |
2110 __ add(r2, r9, Operand(r1, LSL, r3)); | 2236 __ add(r11, r18, r11); |
2111 | 2237 __ ShiftLeft_(r5, r4, r6); |
2112 __ ldr(r7, FieldMemOperand(subject, String::kLengthOffset)); | 2238 __ add(r5, r11, r5); |
2113 __ SmiUntag(r7); | 2239 |
2114 __ add(r3, r9, Operand(r7, LSL, r3)); | 2240 __ LoadP(r18, FieldMemOperand(subject, String::kLengthOffset)); |
2115 | 2241 __ SmiUntag(r18); |
2116 // Argument 2 (r1): Previous index. | 2242 __ ShiftLeft_(r6, r18, r6); |
| 2243 __ add(r6, r11, r6); |
| 2244 |
| 2245 // Argument 2 (r4): Previous index. |
2117 // Already there | 2246 // Already there |
2118 | 2247 |
2119 // Argument 1 (r0): Subject string. | 2248 // Argument 1 (r3): Subject string. |
2120 __ mov(r0, subject); | 2249 __ mr(r3, subject); |
2121 | 2250 |
2122 // Locate the code entry and call it. | 2251 // Locate the code entry and call it. |
2123 __ add(r6, r6, Operand(Code::kHeaderSize - kHeapObjectTag)); | 2252 __ addi(code, code, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 2253 |
| 2254 |
| 2255 #if ABI_USES_FUNCTION_DESCRIPTORS && defined(USE_SIMULATOR) |
| 2256 // Even Simulated AIX/PPC64 Linux uses a function descriptor for the |
| 2257 // RegExp routine. Extract the instruction address here since |
| 2258 // DirectCEntryStub::GenerateCall will not do it for calls out to |
| 2259 // what it thinks is C code compiled for the simulator/host |
| 2260 // platform. |
| 2261 __ LoadP(code, MemOperand(code, 0)); // Instruction address |
| 2262 #endif |
| 2263 |
2124 DirectCEntryStub stub(isolate()); | 2264 DirectCEntryStub stub(isolate()); |
2125 stub.GenerateCall(masm, r6); | 2265 stub.GenerateCall(masm, code); |
2126 | 2266 |
2127 __ LeaveExitFrame(false, no_reg, true); | 2267 __ LeaveExitFrame(false, no_reg, true); |
2128 | 2268 |
2129 last_match_info_elements = r6; | 2269 // r3: result |
2130 | |
2131 // r0: result | |
2132 // subject: subject string (callee saved) | 2270 // subject: subject string (callee saved) |
2133 // regexp_data: RegExp data (callee saved) | 2271 // regexp_data: RegExp data (callee saved) |
2134 // last_match_info_elements: Last match info elements (callee saved) | 2272 // last_match_info_elements: Last match info elements (callee saved) |
2135 // Check the result. | 2273 // Check the result. |
2136 Label success; | 2274 Label success; |
2137 __ cmp(r0, Operand(1)); | 2275 __ cmpi(r3, Operand(1)); |
2138 // We expect exactly one result since we force the called regexp to behave | 2276 // We expect exactly one result since we force the called regexp to behave |
2139 // as non-global. | 2277 // as non-global. |
2140 __ b(eq, &success); | 2278 __ beq(&success); |
2141 Label failure; | 2279 Label failure; |
2142 __ cmp(r0, Operand(NativeRegExpMacroAssembler::FAILURE)); | 2280 __ cmpi(r3, Operand(NativeRegExpMacroAssembler::FAILURE)); |
2143 __ b(eq, &failure); | 2281 __ beq(&failure); |
2144 __ cmp(r0, Operand(NativeRegExpMacroAssembler::EXCEPTION)); | 2282 __ cmpi(r3, Operand(NativeRegExpMacroAssembler::EXCEPTION)); |
2145 // If not exception it can only be retry. Handle that in the runtime system. | 2283 // If not exception it can only be retry. Handle that in the runtime system. |
2146 __ b(ne, &runtime); | 2284 __ bne(&runtime); |
2147 // Result must now be exception. If there is no pending exception already a | 2285 // Result must now be exception. If there is no pending exception already a |
2148 // stack overflow (on the backtrack stack) was detected in RegExp code but | 2286 // stack overflow (on the backtrack stack) was detected in RegExp code but |
2149 // haven't created the exception yet. Handle that in the runtime system. | 2287 // haven't created the exception yet. Handle that in the runtime system. |
2150 // TODO(592): Rerunning the RegExp to get the stack overflow exception. | 2288 // TODO(592): Rerunning the RegExp to get the stack overflow exception. |
2151 __ mov(r1, Operand(isolate()->factory()->the_hole_value())); | 2289 __ mov(r4, Operand(isolate()->factory()->the_hole_value())); |
2152 __ mov(r2, Operand(ExternalReference(Isolate::kPendingExceptionAddress, | 2290 __ mov(r5, Operand(ExternalReference(Isolate::kPendingExceptionAddress, |
2153 isolate()))); | 2291 isolate()))); |
2154 __ ldr(r0, MemOperand(r2, 0)); | 2292 __ LoadP(r3, MemOperand(r5, 0)); |
2155 __ cmp(r0, r1); | 2293 __ cmp(r3, r4); |
2156 __ b(eq, &runtime); | 2294 __ beq(&runtime); |
2157 | 2295 |
2158 __ str(r1, MemOperand(r2, 0)); // Clear pending exception. | 2296 __ StoreP(r4, MemOperand(r5, 0)); // Clear pending exception. |
2159 | 2297 |
2160 // Check if the exception is a termination. If so, throw as uncatchable. | 2298 // Check if the exception is a termination. If so, throw as uncatchable. |
2161 __ CompareRoot(r0, Heap::kTerminationExceptionRootIndex); | 2299 __ CompareRoot(r3, Heap::kTerminationExceptionRootIndex); |
2162 | 2300 |
2163 Label termination_exception; | 2301 Label termination_exception; |
2164 __ b(eq, &termination_exception); | 2302 __ beq(&termination_exception); |
2165 | 2303 |
2166 __ Throw(r0); | 2304 __ Throw(r3); |
2167 | 2305 |
2168 __ bind(&termination_exception); | 2306 __ bind(&termination_exception); |
2169 __ ThrowUncatchable(r0); | 2307 __ ThrowUncatchable(r3); |
2170 | 2308 |
2171 __ bind(&failure); | 2309 __ bind(&failure); |
2172 // For failure and exception return null. | 2310 // For failure and exception return null. |
2173 __ mov(r0, Operand(isolate()->factory()->null_value())); | 2311 __ mov(r3, Operand(isolate()->factory()->null_value())); |
2174 __ add(sp, sp, Operand(4 * kPointerSize)); | 2312 __ addi(sp, sp, Operand(4 * kPointerSize)); |
2175 __ Ret(); | 2313 __ Ret(); |
2176 | 2314 |
2177 // Process the result from the native regexp code. | 2315 // Process the result from the native regexp code. |
2178 __ bind(&success); | 2316 __ bind(&success); |
2179 __ ldr(r1, | 2317 __ LoadP(r4, |
2180 FieldMemOperand(regexp_data, JSRegExp::kIrregexpCaptureCountOffset)); | 2318 FieldMemOperand(regexp_data, JSRegExp::kIrregexpCaptureCountOffset)); |
2181 // Calculate number of capture registers (number_of_captures + 1) * 2. | 2319 // Calculate number of capture registers (number_of_captures + 1) * 2. |
2182 // Multiplying by 2 comes for free since r1 is smi-tagged. | 2320 // SmiToShortArrayOffset accomplishes the multiplication by 2 and |
2183 STATIC_ASSERT(kSmiTag == 0); | 2321 // SmiUntag (which is a nop for 32-bit). |
2184 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); | 2322 __ SmiToShortArrayOffset(r4, r4); |
2185 __ add(r1, r1, Operand(2)); // r1 was a smi. | 2323 __ addi(r4, r4, Operand(2)); |
2186 | 2324 |
2187 __ ldr(r0, MemOperand(sp, kLastMatchInfoOffset)); | 2325 __ LoadP(r3, MemOperand(sp, kLastMatchInfoOffset)); |
2188 __ JumpIfSmi(r0, &runtime); | 2326 __ JumpIfSmi(r3, &runtime); |
2189 __ CompareObjectType(r0, r2, r2, JS_ARRAY_TYPE); | 2327 __ CompareObjectType(r3, r5, r5, JS_ARRAY_TYPE); |
2190 __ b(ne, &runtime); | 2328 __ bne(&runtime); |
2191 // Check that the JSArray is in fast case. | 2329 // Check that the JSArray is in fast case. |
2192 __ ldr(last_match_info_elements, | 2330 __ LoadP(last_match_info_elements, |
2193 FieldMemOperand(r0, JSArray::kElementsOffset)); | 2331 FieldMemOperand(r3, JSArray::kElementsOffset)); |
2194 __ ldr(r0, FieldMemOperand(last_match_info_elements, HeapObject::kMapOffset)); | 2332 __ LoadP(r3, |
2195 __ CompareRoot(r0, Heap::kFixedArrayMapRootIndex); | 2333 FieldMemOperand(last_match_info_elements, HeapObject::kMapOffset)); |
2196 __ b(ne, &runtime); | 2334 __ CompareRoot(r3, Heap::kFixedArrayMapRootIndex); |
| 2335 __ bne(&runtime); |
2197 // Check that the last match info has space for the capture registers and the | 2336 // Check that the last match info has space for the capture registers and the |
2198 // additional information. | 2337 // additional information. |
2199 __ ldr(r0, | 2338 __ LoadP( |
2200 FieldMemOperand(last_match_info_elements, FixedArray::kLengthOffset)); | 2339 r3, FieldMemOperand(last_match_info_elements, FixedArray::kLengthOffset)); |
2201 __ add(r2, r1, Operand(RegExpImpl::kLastMatchOverhead)); | 2340 __ addi(r5, r4, Operand(RegExpImpl::kLastMatchOverhead)); |
2202 __ cmp(r2, Operand::SmiUntag(r0)); | 2341 __ SmiUntag(r0, r3); |
2203 __ b(gt, &runtime); | 2342 __ cmp(r5, r0); |
2204 | 2343 __ bgt(&runtime); |
2205 // r1: number of capture registers | 2344 |
2206 // r4: subject string | 2345 // r4: number of capture registers |
| 2346 // subject: subject string |
2207 // Store the capture count. | 2347 // Store the capture count. |
2208 __ SmiTag(r2, r1); | 2348 __ SmiTag(r5, r4); |
2209 __ str(r2, FieldMemOperand(last_match_info_elements, | 2349 __ StoreP(r5, FieldMemOperand(last_match_info_elements, |
2210 RegExpImpl::kLastCaptureCountOffset)); | 2350 RegExpImpl::kLastCaptureCountOffset), |
| 2351 r0); |
2211 // Store last subject and last input. | 2352 // Store last subject and last input. |
2212 __ str(subject, | 2353 __ StoreP(subject, FieldMemOperand(last_match_info_elements, |
2213 FieldMemOperand(last_match_info_elements, | 2354 RegExpImpl::kLastSubjectOffset), |
2214 RegExpImpl::kLastSubjectOffset)); | 2355 r0); |
2215 __ mov(r2, subject); | 2356 __ mr(r5, subject); |
2216 __ RecordWriteField(last_match_info_elements, | 2357 __ RecordWriteField(last_match_info_elements, RegExpImpl::kLastSubjectOffset, |
2217 RegExpImpl::kLastSubjectOffset, | 2358 subject, r10, kLRHasNotBeenSaved, kDontSaveFPRegs); |
2218 subject, | 2359 __ mr(subject, r5); |
2219 r3, | 2360 __ StoreP(subject, FieldMemOperand(last_match_info_elements, |
2220 kLRHasNotBeenSaved, | 2361 RegExpImpl::kLastInputOffset), |
2221 kDontSaveFPRegs); | 2362 r0); |
2222 __ mov(subject, r2); | 2363 __ RecordWriteField(last_match_info_elements, RegExpImpl::kLastInputOffset, |
2223 __ str(subject, | 2364 subject, r10, kLRHasNotBeenSaved, kDontSaveFPRegs); |
2224 FieldMemOperand(last_match_info_elements, | |
2225 RegExpImpl::kLastInputOffset)); | |
2226 __ RecordWriteField(last_match_info_elements, | |
2227 RegExpImpl::kLastInputOffset, | |
2228 subject, | |
2229 r3, | |
2230 kLRHasNotBeenSaved, | |
2231 kDontSaveFPRegs); | |
2232 | 2365 |
2233 // Get the static offsets vector filled by the native regexp code. | 2366 // Get the static offsets vector filled by the native regexp code. |
2234 ExternalReference address_of_static_offsets_vector = | 2367 ExternalReference address_of_static_offsets_vector = |
2235 ExternalReference::address_of_static_offsets_vector(isolate()); | 2368 ExternalReference::address_of_static_offsets_vector(isolate()); |
2236 __ mov(r2, Operand(address_of_static_offsets_vector)); | 2369 __ mov(r5, Operand(address_of_static_offsets_vector)); |
2237 | 2370 |
2238 // r1: number of capture registers | 2371 // r4: number of capture registers |
2239 // r2: offsets vector | 2372 // r5: offsets vector |
2240 Label next_capture, done; | 2373 Label next_capture; |
2241 // Capture register counter starts from number of capture registers and | 2374 // Capture register counter starts from number of capture registers and |
2242 // counts down until wraping after zero. | 2375 // counts down until wraping after zero. |
2243 __ add(r0, | 2376 __ addi( |
2244 last_match_info_elements, | 2377 r3, last_match_info_elements, |
2245 Operand(RegExpImpl::kFirstCaptureOffset - kHeapObjectTag)); | 2378 Operand(RegExpImpl::kFirstCaptureOffset - kHeapObjectTag - kPointerSize)); |
| 2379 __ addi(r5, r5, Operand(-kIntSize)); // bias down for lwzu |
| 2380 __ mtctr(r4); |
2246 __ bind(&next_capture); | 2381 __ bind(&next_capture); |
2247 __ sub(r1, r1, Operand(1), SetCC); | |
2248 __ b(mi, &done); | |
2249 // Read the value from the static offsets vector buffer. | 2382 // Read the value from the static offsets vector buffer. |
2250 __ ldr(r3, MemOperand(r2, kPointerSize, PostIndex)); | 2383 __ lwzu(r6, MemOperand(r5, kIntSize)); |
2251 // Store the smi value in the last match info. | 2384 // Store the smi value in the last match info. |
2252 __ SmiTag(r3); | 2385 __ SmiTag(r6); |
2253 __ str(r3, MemOperand(r0, kPointerSize, PostIndex)); | 2386 __ StorePU(r6, MemOperand(r3, kPointerSize)); |
2254 __ jmp(&next_capture); | 2387 __ bdnz(&next_capture); |
2255 __ bind(&done); | |
2256 | 2388 |
2257 // Return last match info. | 2389 // Return last match info. |
2258 __ ldr(r0, MemOperand(sp, kLastMatchInfoOffset)); | 2390 __ LoadP(r3, MemOperand(sp, kLastMatchInfoOffset)); |
2259 __ add(sp, sp, Operand(4 * kPointerSize)); | 2391 __ addi(sp, sp, Operand(4 * kPointerSize)); |
2260 __ Ret(); | 2392 __ Ret(); |
2261 | 2393 |
2262 // Do the runtime call to execute the regexp. | 2394 // Do the runtime call to execute the regexp. |
2263 __ bind(&runtime); | 2395 __ bind(&runtime); |
2264 __ TailCallRuntime(Runtime::kRegExpExecRT, 4, 1); | 2396 __ TailCallRuntime(Runtime::kRegExpExecRT, 4, 1); |
2265 | 2397 |
2266 // Deferred code for string handling. | 2398 // Deferred code for string handling. |
2267 // (6) Not a long external string? If yes, go to (8). | 2399 // (6) Not a long external string? If yes, go to (8). |
2268 __ bind(¬_seq_nor_cons); | 2400 __ bind(¬_seq_nor_cons); |
2269 // Compare flags are still set. | 2401 // Compare flags are still set. |
2270 __ b(gt, ¬_long_external); // Go to (8). | 2402 __ bgt(¬_long_external); // Go to (8). |
2271 | 2403 |
2272 // (7) External string. Make it, offset-wise, look like a sequential string. | 2404 // (7) External string. Make it, offset-wise, look like a sequential string. |
2273 __ bind(&external_string); | 2405 __ bind(&external_string); |
2274 __ ldr(r0, FieldMemOperand(subject, HeapObject::kMapOffset)); | 2406 __ LoadP(r3, FieldMemOperand(subject, HeapObject::kMapOffset)); |
2275 __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset)); | 2407 __ lbz(r3, FieldMemOperand(r3, Map::kInstanceTypeOffset)); |
2276 if (FLAG_debug_code) { | 2408 if (FLAG_debug_code) { |
2277 // Assert that we do not have a cons or slice (indirect strings) here. | 2409 // Assert that we do not have a cons or slice (indirect strings) here. |
2278 // Sequential strings have already been ruled out. | 2410 // Sequential strings have already been ruled out. |
2279 __ tst(r0, Operand(kIsIndirectStringMask)); | 2411 STATIC_ASSERT(kIsIndirectStringMask == 1); |
2280 __ Assert(eq, kExternalStringExpectedButNotFound); | 2412 __ andi(r0, r3, Operand(kIsIndirectStringMask)); |
| 2413 __ Assert(eq, kExternalStringExpectedButNotFound, cr0); |
2281 } | 2414 } |
2282 __ ldr(subject, | 2415 __ LoadP(subject, |
2283 FieldMemOperand(subject, ExternalString::kResourceDataOffset)); | 2416 FieldMemOperand(subject, ExternalString::kResourceDataOffset)); |
2284 // Move the pointer so that offset-wise, it looks like a sequential string. | 2417 // Move the pointer so that offset-wise, it looks like a sequential string. |
2285 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqOneByteString::kHeaderSize); | 2418 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqOneByteString::kHeaderSize); |
2286 __ sub(subject, | 2419 __ subi(subject, subject, |
2287 subject, | 2420 Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); |
2288 Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); | 2421 __ b(&seq_string); // Go to (5). |
2289 __ jmp(&seq_string); // Go to (5). | |
2290 | 2422 |
2291 // (8) Short external string or not a string? If yes, bail out to runtime. | 2423 // (8) Short external string or not a string? If yes, bail out to runtime. |
2292 __ bind(¬_long_external); | 2424 __ bind(¬_long_external); |
2293 STATIC_ASSERT(kNotStringTag != 0 && kShortExternalStringTag !=0); | 2425 STATIC_ASSERT(kNotStringTag != 0 && kShortExternalStringTag != 0); |
2294 __ tst(r1, Operand(kIsNotStringMask | kShortExternalStringMask)); | 2426 __ andi(r0, r4, Operand(kIsNotStringMask | kShortExternalStringMask)); |
2295 __ b(ne, &runtime); | 2427 __ bne(&runtime, cr0); |
2296 | 2428 |
2297 // (9) Sliced string. Replace subject with parent. Go to (4). | 2429 // (9) Sliced string. Replace subject with parent. Go to (4). |
2298 // Load offset into r9 and replace subject string with parent. | 2430 // Load offset into r11 and replace subject string with parent. |
2299 __ ldr(r9, FieldMemOperand(subject, SlicedString::kOffsetOffset)); | 2431 __ LoadP(r11, FieldMemOperand(subject, SlicedString::kOffsetOffset)); |
2300 __ SmiUntag(r9); | 2432 __ SmiUntag(r11); |
2301 __ ldr(subject, FieldMemOperand(subject, SlicedString::kParentOffset)); | 2433 __ LoadP(subject, FieldMemOperand(subject, SlicedString::kParentOffset)); |
2302 __ jmp(&check_underlying); // Go to (4). | 2434 __ b(&check_underlying); // Go to (4). |
2303 #endif // V8_INTERPRETED_REGEXP | 2435 #endif // V8_INTERPRETED_REGEXP |
2304 } | 2436 } |
2305 | 2437 |
2306 | 2438 |
2307 static void GenerateRecordCallTarget(MacroAssembler* masm) { | 2439 static void GenerateRecordCallTarget(MacroAssembler* masm) { |
2308 // Cache the called function in a feedback vector slot. Cache states | 2440 // Cache the called function in a feedback vector slot. Cache states |
2309 // are uninitialized, monomorphic (indicated by a JSFunction), and | 2441 // are uninitialized, monomorphic (indicated by a JSFunction), and |
2310 // megamorphic. | 2442 // megamorphic. |
2311 // r0 : number of arguments to the construct function | 2443 // r3 : number of arguments to the construct function |
2312 // r1 : the function to call | 2444 // r4 : the function to call |
2313 // r2 : Feedback vector | 2445 // r5 : Feedback vector |
2314 // r3 : slot in feedback vector (Smi) | 2446 // r6 : slot in feedback vector (Smi) |
2315 Label initialize, done, miss, megamorphic, not_array_function; | 2447 Label initialize, done, miss, megamorphic, not_array_function; |
2316 | 2448 |
2317 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), | 2449 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), |
2318 masm->isolate()->heap()->megamorphic_symbol()); | 2450 masm->isolate()->heap()->megamorphic_symbol()); |
2319 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), | 2451 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), |
2320 masm->isolate()->heap()->uninitialized_symbol()); | 2452 masm->isolate()->heap()->uninitialized_symbol()); |
2321 | 2453 |
2322 // Load the cache state into r4. | 2454 // Load the cache state into r7. |
2323 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3)); | 2455 __ SmiToPtrArrayOffset(r7, r6); |
2324 __ ldr(r4, FieldMemOperand(r4, FixedArray::kHeaderSize)); | 2456 __ add(r7, r5, r7); |
| 2457 __ LoadP(r7, FieldMemOperand(r7, FixedArray::kHeaderSize)); |
2325 | 2458 |
2326 // A monomorphic cache hit or an already megamorphic state: invoke the | 2459 // A monomorphic cache hit or an already megamorphic state: invoke the |
2327 // function without changing the state. | 2460 // function without changing the state. |
2328 __ cmp(r4, r1); | 2461 __ cmp(r7, r4); |
2329 __ b(eq, &done); | 2462 __ b(eq, &done); |
2330 | 2463 |
2331 if (!FLAG_pretenuring_call_new) { | 2464 if (!FLAG_pretenuring_call_new) { |
2332 // If we came here, we need to see if we are the array function. | 2465 // If we came here, we need to see if we are the array function. |
2333 // If we didn't have a matching function, and we didn't find the megamorph | 2466 // If we didn't have a matching function, and we didn't find the megamorph |
2334 // sentinel, then we have in the slot either some other function or an | 2467 // sentinel, then we have in the slot either some other function or an |
2335 // AllocationSite. Do a map check on the object in ecx. | 2468 // AllocationSite. Do a map check on the object in ecx. |
2336 __ ldr(r5, FieldMemOperand(r4, 0)); | 2469 __ LoadP(r8, FieldMemOperand(r7, 0)); |
2337 __ CompareRoot(r5, Heap::kAllocationSiteMapRootIndex); | 2470 __ CompareRoot(r8, Heap::kAllocationSiteMapRootIndex); |
2338 __ b(ne, &miss); | 2471 __ bne(&miss); |
2339 | 2472 |
2340 // Make sure the function is the Array() function | 2473 // Make sure the function is the Array() function |
2341 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, r4); | 2474 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, r7); |
2342 __ cmp(r1, r4); | 2475 __ cmp(r4, r7); |
2343 __ b(ne, &megamorphic); | 2476 __ bne(&megamorphic); |
2344 __ jmp(&done); | 2477 __ b(&done); |
2345 } | 2478 } |
2346 | 2479 |
2347 __ bind(&miss); | 2480 __ bind(&miss); |
2348 | 2481 |
2349 // A monomorphic miss (i.e, here the cache is not uninitialized) goes | 2482 // A monomorphic miss (i.e, here the cache is not uninitialized) goes |
2350 // megamorphic. | 2483 // megamorphic. |
2351 __ CompareRoot(r4, Heap::kuninitialized_symbolRootIndex); | 2484 __ CompareRoot(r7, Heap::kuninitialized_symbolRootIndex); |
2352 __ b(eq, &initialize); | 2485 __ beq(&initialize); |
2353 // MegamorphicSentinel is an immortal immovable object (undefined) so no | 2486 // MegamorphicSentinel is an immortal immovable object (undefined) so no |
2354 // write-barrier is needed. | 2487 // write-barrier is needed. |
2355 __ bind(&megamorphic); | 2488 __ bind(&megamorphic); |
2356 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3)); | 2489 __ SmiToPtrArrayOffset(r7, r6); |
| 2490 __ add(r7, r5, r7); |
2357 __ LoadRoot(ip, Heap::kmegamorphic_symbolRootIndex); | 2491 __ LoadRoot(ip, Heap::kmegamorphic_symbolRootIndex); |
2358 __ str(ip, FieldMemOperand(r4, FixedArray::kHeaderSize)); | 2492 __ StoreP(ip, FieldMemOperand(r7, FixedArray::kHeaderSize), r0); |
2359 __ jmp(&done); | 2493 __ jmp(&done); |
2360 | 2494 |
2361 // An uninitialized cache is patched with the function | 2495 // An uninitialized cache is patched with the function |
2362 __ bind(&initialize); | 2496 __ bind(&initialize); |
2363 | 2497 |
2364 if (!FLAG_pretenuring_call_new) { | 2498 if (!FLAG_pretenuring_call_new) { |
2365 // Make sure the function is the Array() function | 2499 // Make sure the function is the Array() function. |
2366 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, r4); | 2500 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, r7); |
2367 __ cmp(r1, r4); | 2501 __ cmp(r4, r7); |
2368 __ b(ne, ¬_array_function); | 2502 __ bne(¬_array_function); |
2369 | 2503 |
2370 // The target function is the Array constructor, | 2504 // The target function is the Array constructor, |
2371 // Create an AllocationSite if we don't already have it, store it in the | 2505 // Create an AllocationSite if we don't already have it, store it in the |
2372 // slot. | 2506 // slot. |
2373 { | 2507 { |
2374 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 2508 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
2375 | 2509 |
2376 // Arguments register must be smi-tagged to call out. | 2510 // Arguments register must be smi-tagged to call out. |
2377 __ SmiTag(r0); | 2511 __ SmiTag(r3); |
2378 __ Push(r3, r2, r1, r0); | 2512 __ Push(r6, r5, r4, r3); |
2379 | 2513 |
2380 CreateAllocationSiteStub create_stub(masm->isolate()); | 2514 CreateAllocationSiteStub create_stub(masm->isolate()); |
2381 __ CallStub(&create_stub); | 2515 __ CallStub(&create_stub); |
2382 | 2516 |
2383 __ Pop(r3, r2, r1, r0); | 2517 __ Pop(r6, r5, r4, r3); |
2384 __ SmiUntag(r0); | 2518 __ SmiUntag(r3); |
2385 } | 2519 } |
2386 __ b(&done); | 2520 __ b(&done); |
2387 | 2521 |
2388 __ bind(¬_array_function); | 2522 __ bind(¬_array_function); |
2389 } | 2523 } |
2390 | 2524 |
2391 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3)); | 2525 __ SmiToPtrArrayOffset(r7, r6); |
2392 __ add(r4, r4, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | 2526 __ add(r7, r5, r7); |
2393 __ str(r1, MemOperand(r4, 0)); | 2527 __ addi(r7, r7, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
| 2528 __ StoreP(r4, MemOperand(r7, 0)); |
2394 | 2529 |
2395 __ Push(r4, r2, r1); | 2530 __ Push(r7, r5, r4); |
2396 __ RecordWrite(r2, r4, r1, kLRHasNotBeenSaved, kDontSaveFPRegs, | 2531 __ RecordWrite(r5, r7, r4, kLRHasNotBeenSaved, kDontSaveFPRegs, |
2397 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); | 2532 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); |
2398 __ Pop(r4, r2, r1); | 2533 __ Pop(r7, r5, r4); |
2399 | 2534 |
2400 __ bind(&done); | 2535 __ bind(&done); |
2401 } | 2536 } |
2402 | 2537 |
2403 | 2538 |
2404 static void EmitContinueIfStrictOrNative(MacroAssembler* masm, Label* cont) { | 2539 static void EmitContinueIfStrictOrNative(MacroAssembler* masm, Label* cont) { |
2405 // Do not transform the receiver for strict mode functions. | 2540 // Do not transform the receiver for strict mode functions and natives. |
2406 __ ldr(r3, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); | 2541 __ LoadP(r6, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); |
2407 __ ldr(r4, FieldMemOperand(r3, SharedFunctionInfo::kCompilerHintsOffset)); | 2542 __ lwz(r7, FieldMemOperand(r6, SharedFunctionInfo::kCompilerHintsOffset)); |
2408 __ tst(r4, Operand(1 << (SharedFunctionInfo::kStrictModeFunction + | 2543 __ TestBit(r7, |
2409 kSmiTagSize))); | 2544 #if V8_TARGET_ARCH_PPC64 |
2410 __ b(ne, cont); | 2545 SharedFunctionInfo::kStrictModeFunction, |
| 2546 #else |
| 2547 SharedFunctionInfo::kStrictModeFunction + kSmiTagSize, |
| 2548 #endif |
| 2549 r0); |
| 2550 __ bne(cont, cr0); |
2411 | 2551 |
2412 // Do not transform the receiver for native (Compilerhints already in r3). | 2552 // Do not transform the receiver for native. |
2413 __ tst(r4, Operand(1 << (SharedFunctionInfo::kNative + kSmiTagSize))); | 2553 __ TestBit(r7, |
2414 __ b(ne, cont); | 2554 #if V8_TARGET_ARCH_PPC64 |
| 2555 SharedFunctionInfo::kNative, |
| 2556 #else |
| 2557 SharedFunctionInfo::kNative + kSmiTagSize, |
| 2558 #endif |
| 2559 r0); |
| 2560 __ bne(cont, cr0); |
2415 } | 2561 } |
2416 | 2562 |
2417 | 2563 |
2418 static void EmitSlowCase(MacroAssembler* masm, | 2564 static void EmitSlowCase(MacroAssembler* masm, int argc, Label* non_function) { |
2419 int argc, | |
2420 Label* non_function) { | |
2421 // Check for function proxy. | 2565 // Check for function proxy. |
2422 __ cmp(r4, Operand(JS_FUNCTION_PROXY_TYPE)); | 2566 STATIC_ASSERT(JS_FUNCTION_PROXY_TYPE < 0xffffu); |
2423 __ b(ne, non_function); | 2567 __ cmpi(r7, Operand(JS_FUNCTION_PROXY_TYPE)); |
2424 __ push(r1); // put proxy as additional argument | 2568 __ bne(non_function); |
2425 __ mov(r0, Operand(argc + 1, RelocInfo::NONE32)); | 2569 __ push(r4); // put proxy as additional argument |
2426 __ mov(r2, Operand::Zero()); | 2570 __ li(r3, Operand(argc + 1)); |
2427 __ GetBuiltinFunction(r1, Builtins::CALL_FUNCTION_PROXY); | 2571 __ li(r5, Operand::Zero()); |
| 2572 __ GetBuiltinFunction(r4, Builtins::CALL_FUNCTION_PROXY); |
2428 { | 2573 { |
2429 Handle<Code> adaptor = | 2574 Handle<Code> adaptor = |
2430 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(); | 2575 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(); |
2431 __ Jump(adaptor, RelocInfo::CODE_TARGET); | 2576 __ Jump(adaptor, RelocInfo::CODE_TARGET); |
2432 } | 2577 } |
2433 | 2578 |
2434 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead | 2579 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead |
2435 // of the original receiver from the call site). | 2580 // of the original receiver from the call site). |
2436 __ bind(non_function); | 2581 __ bind(non_function); |
2437 __ str(r1, MemOperand(sp, argc * kPointerSize)); | 2582 __ StoreP(r4, MemOperand(sp, argc * kPointerSize), r0); |
2438 __ mov(r0, Operand(argc)); // Set up the number of arguments. | 2583 __ li(r3, Operand(argc)); // Set up the number of arguments. |
2439 __ mov(r2, Operand::Zero()); | 2584 __ li(r5, Operand::Zero()); |
2440 __ GetBuiltinFunction(r1, Builtins::CALL_NON_FUNCTION); | 2585 __ GetBuiltinFunction(r4, Builtins::CALL_NON_FUNCTION); |
2441 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 2586 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
2442 RelocInfo::CODE_TARGET); | 2587 RelocInfo::CODE_TARGET); |
2443 } | 2588 } |
2444 | 2589 |
2445 | 2590 |
2446 static void EmitWrapCase(MacroAssembler* masm, int argc, Label* cont) { | 2591 static void EmitWrapCase(MacroAssembler* masm, int argc, Label* cont) { |
2447 // Wrap the receiver and patch it back onto the stack. | 2592 // Wrap the receiver and patch it back onto the stack. |
2448 { FrameAndConstantPoolScope frame_scope(masm, StackFrame::INTERNAL); | 2593 { |
2449 __ Push(r1, r3); | 2594 FrameAndConstantPoolScope frame_scope(masm, StackFrame::INTERNAL); |
| 2595 __ Push(r4, r6); |
2450 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); | 2596 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); |
2451 __ pop(r1); | 2597 __ pop(r4); |
2452 } | 2598 } |
2453 __ str(r0, MemOperand(sp, argc * kPointerSize)); | 2599 __ StoreP(r3, MemOperand(sp, argc * kPointerSize), r0); |
2454 __ jmp(cont); | 2600 __ b(cont); |
2455 } | 2601 } |
2456 | 2602 |
2457 | 2603 |
2458 static void CallFunctionNoFeedback(MacroAssembler* masm, | 2604 static void CallFunctionNoFeedback(MacroAssembler* masm, int argc, |
2459 int argc, bool needs_checks, | 2605 bool needs_checks, bool call_as_method) { |
2460 bool call_as_method) { | 2606 // r4 : the function to call |
2461 // r1 : the function to call | |
2462 Label slow, non_function, wrap, cont; | 2607 Label slow, non_function, wrap, cont; |
2463 | 2608 |
2464 if (needs_checks) { | 2609 if (needs_checks) { |
2465 // Check that the function is really a JavaScript function. | 2610 // Check that the function is really a JavaScript function. |
2466 // r1: pushed function (to be verified) | 2611 // r4: pushed function (to be verified) |
2467 __ JumpIfSmi(r1, &non_function); | 2612 __ JumpIfSmi(r4, &non_function); |
2468 | 2613 |
2469 // Goto slow case if we do not have a function. | 2614 // Goto slow case if we do not have a function. |
2470 __ CompareObjectType(r1, r4, r4, JS_FUNCTION_TYPE); | 2615 __ CompareObjectType(r4, r7, r7, JS_FUNCTION_TYPE); |
2471 __ b(ne, &slow); | 2616 __ bne(&slow); |
2472 } | 2617 } |
2473 | 2618 |
2474 // Fast-case: Invoke the function now. | 2619 // Fast-case: Invoke the function now. |
2475 // r1: pushed function | 2620 // r4: pushed function |
2476 ParameterCount actual(argc); | 2621 ParameterCount actual(argc); |
2477 | 2622 |
2478 if (call_as_method) { | 2623 if (call_as_method) { |
2479 if (needs_checks) { | 2624 if (needs_checks) { |
2480 EmitContinueIfStrictOrNative(masm, &cont); | 2625 EmitContinueIfStrictOrNative(masm, &cont); |
2481 } | 2626 } |
2482 | 2627 |
2483 // Compute the receiver in sloppy mode. | 2628 // Compute the receiver in sloppy mode. |
2484 __ ldr(r3, MemOperand(sp, argc * kPointerSize)); | 2629 __ LoadP(r6, MemOperand(sp, argc * kPointerSize), r0); |
2485 | 2630 |
2486 if (needs_checks) { | 2631 if (needs_checks) { |
2487 __ JumpIfSmi(r3, &wrap); | 2632 __ JumpIfSmi(r6, &wrap); |
2488 __ CompareObjectType(r3, r4, r4, FIRST_SPEC_OBJECT_TYPE); | 2633 __ CompareObjectType(r6, r7, r7, FIRST_SPEC_OBJECT_TYPE); |
2489 __ b(lt, &wrap); | 2634 __ blt(&wrap); |
2490 } else { | 2635 } else { |
2491 __ jmp(&wrap); | 2636 __ b(&wrap); |
2492 } | 2637 } |
2493 | 2638 |
2494 __ bind(&cont); | 2639 __ bind(&cont); |
2495 } | 2640 } |
2496 | 2641 |
2497 __ InvokeFunction(r1, actual, JUMP_FUNCTION, NullCallWrapper()); | 2642 __ InvokeFunction(r4, actual, JUMP_FUNCTION, NullCallWrapper()); |
2498 | 2643 |
2499 if (needs_checks) { | 2644 if (needs_checks) { |
2500 // Slow-case: Non-function called. | 2645 // Slow-case: Non-function called. |
2501 __ bind(&slow); | 2646 __ bind(&slow); |
2502 EmitSlowCase(masm, argc, &non_function); | 2647 EmitSlowCase(masm, argc, &non_function); |
2503 } | 2648 } |
2504 | 2649 |
2505 if (call_as_method) { | 2650 if (call_as_method) { |
2506 __ bind(&wrap); | 2651 __ bind(&wrap); |
2507 EmitWrapCase(masm, argc, &cont); | 2652 EmitWrapCase(masm, argc, &cont); |
2508 } | 2653 } |
2509 } | 2654 } |
2510 | 2655 |
2511 | 2656 |
2512 void CallFunctionStub::Generate(MacroAssembler* masm) { | 2657 void CallFunctionStub::Generate(MacroAssembler* masm) { |
2513 CallFunctionNoFeedback(masm, argc(), NeedsChecks(), CallAsMethod()); | 2658 CallFunctionNoFeedback(masm, argc(), NeedsChecks(), CallAsMethod()); |
2514 } | 2659 } |
2515 | 2660 |
2516 | 2661 |
2517 void CallConstructStub::Generate(MacroAssembler* masm) { | 2662 void CallConstructStub::Generate(MacroAssembler* masm) { |
2518 // r0 : number of arguments | 2663 // r3 : number of arguments |
2519 // r1 : the function to call | 2664 // r4 : the function to call |
2520 // r2 : feedback vector | 2665 // r5 : feedback vector |
2521 // r3 : (only if r2 is not the megamorphic symbol) slot in feedback | 2666 // r6 : (only if r5 is not the megamorphic symbol) slot in feedback |
2522 // vector (Smi) | 2667 // vector (Smi) |
2523 Label slow, non_function_call; | 2668 Label slow, non_function_call; |
2524 | 2669 |
2525 // Check that the function is not a smi. | 2670 // Check that the function is not a smi. |
2526 __ JumpIfSmi(r1, &non_function_call); | 2671 __ JumpIfSmi(r4, &non_function_call); |
2527 // Check that the function is a JSFunction. | 2672 // Check that the function is a JSFunction. |
2528 __ CompareObjectType(r1, r4, r4, JS_FUNCTION_TYPE); | 2673 __ CompareObjectType(r4, r7, r7, JS_FUNCTION_TYPE); |
2529 __ b(ne, &slow); | 2674 __ bne(&slow); |
2530 | 2675 |
2531 if (RecordCallTarget()) { | 2676 if (RecordCallTarget()) { |
2532 GenerateRecordCallTarget(masm); | 2677 GenerateRecordCallTarget(masm); |
2533 | 2678 |
2534 __ add(r5, r2, Operand::PointerOffsetFromSmiKey(r3)); | 2679 __ SmiToPtrArrayOffset(r8, r6); |
| 2680 __ add(r8, r5, r8); |
2535 if (FLAG_pretenuring_call_new) { | 2681 if (FLAG_pretenuring_call_new) { |
2536 // Put the AllocationSite from the feedback vector into r2. | 2682 // Put the AllocationSite from the feedback vector into r5. |
2537 // By adding kPointerSize we encode that we know the AllocationSite | 2683 // By adding kPointerSize we encode that we know the AllocationSite |
2538 // entry is at the feedback vector slot given by r3 + 1. | 2684 // entry is at the feedback vector slot given by r6 + 1. |
2539 __ ldr(r2, FieldMemOperand(r5, FixedArray::kHeaderSize + kPointerSize)); | 2685 __ LoadP(r5, FieldMemOperand(r8, FixedArray::kHeaderSize + kPointerSize)); |
2540 } else { | 2686 } else { |
2541 Label feedback_register_initialized; | 2687 Label feedback_register_initialized; |
2542 // Put the AllocationSite from the feedback vector into r2, or undefined. | 2688 // Put the AllocationSite from the feedback vector into r5, or undefined. |
2543 __ ldr(r2, FieldMemOperand(r5, FixedArray::kHeaderSize)); | 2689 __ LoadP(r5, FieldMemOperand(r8, FixedArray::kHeaderSize)); |
2544 __ ldr(r5, FieldMemOperand(r2, AllocationSite::kMapOffset)); | 2690 __ LoadP(r8, FieldMemOperand(r5, AllocationSite::kMapOffset)); |
2545 __ CompareRoot(r5, Heap::kAllocationSiteMapRootIndex); | 2691 __ CompareRoot(r8, Heap::kAllocationSiteMapRootIndex); |
2546 __ b(eq, &feedback_register_initialized); | 2692 __ beq(&feedback_register_initialized); |
2547 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex); | 2693 __ LoadRoot(r5, Heap::kUndefinedValueRootIndex); |
2548 __ bind(&feedback_register_initialized); | 2694 __ bind(&feedback_register_initialized); |
2549 } | 2695 } |
2550 | 2696 |
2551 __ AssertUndefinedOrAllocationSite(r2, r5); | 2697 __ AssertUndefinedOrAllocationSite(r5, r8); |
2552 } | 2698 } |
2553 | 2699 |
2554 // Jump to the function-specific construct stub. | 2700 // Jump to the function-specific construct stub. |
2555 Register jmp_reg = r4; | 2701 Register jmp_reg = r7; |
2556 __ ldr(jmp_reg, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); | 2702 __ LoadP(jmp_reg, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); |
2557 __ ldr(jmp_reg, FieldMemOperand(jmp_reg, | 2703 __ LoadP(jmp_reg, |
2558 SharedFunctionInfo::kConstructStubOffset)); | 2704 FieldMemOperand(jmp_reg, SharedFunctionInfo::kConstructStubOffset)); |
2559 __ add(pc, jmp_reg, Operand(Code::kHeaderSize - kHeapObjectTag)); | 2705 __ addi(ip, jmp_reg, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 2706 __ JumpToJSEntry(ip); |
2560 | 2707 |
2561 // r0: number of arguments | 2708 // r3: number of arguments |
2562 // r1: called object | 2709 // r4: called object |
2563 // r4: object type | 2710 // r7: object type |
2564 Label do_call; | 2711 Label do_call; |
2565 __ bind(&slow); | 2712 __ bind(&slow); |
2566 __ cmp(r4, Operand(JS_FUNCTION_PROXY_TYPE)); | 2713 STATIC_ASSERT(JS_FUNCTION_PROXY_TYPE < 0xffffu); |
2567 __ b(ne, &non_function_call); | 2714 __ cmpi(r7, Operand(JS_FUNCTION_PROXY_TYPE)); |
2568 __ GetBuiltinFunction(r1, Builtins::CALL_FUNCTION_PROXY_AS_CONSTRUCTOR); | 2715 __ bne(&non_function_call); |
2569 __ jmp(&do_call); | 2716 __ GetBuiltinFunction(r4, Builtins::CALL_FUNCTION_PROXY_AS_CONSTRUCTOR); |
| 2717 __ b(&do_call); |
2570 | 2718 |
2571 __ bind(&non_function_call); | 2719 __ bind(&non_function_call); |
2572 __ GetBuiltinFunction(r1, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); | 2720 __ GetBuiltinFunction(r4, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); |
2573 __ bind(&do_call); | 2721 __ bind(&do_call); |
2574 // Set expected number of arguments to zero (not changing r0). | 2722 // Set expected number of arguments to zero (not changing r3). |
2575 __ mov(r2, Operand::Zero()); | 2723 __ li(r5, Operand::Zero()); |
2576 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 2724 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
2577 RelocInfo::CODE_TARGET); | 2725 RelocInfo::CODE_TARGET); |
2578 } | 2726 } |
2579 | 2727 |
2580 | 2728 |
2581 static void EmitLoadTypeFeedbackVector(MacroAssembler* masm, Register vector) { | 2729 static void EmitLoadTypeFeedbackVector(MacroAssembler* masm, Register vector) { |
2582 __ ldr(vector, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 2730 __ LoadP(vector, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
2583 __ ldr(vector, FieldMemOperand(vector, | 2731 __ LoadP(vector, |
2584 JSFunction::kSharedFunctionInfoOffset)); | 2732 FieldMemOperand(vector, JSFunction::kSharedFunctionInfoOffset)); |
2585 __ ldr(vector, FieldMemOperand(vector, | 2733 __ LoadP(vector, |
2586 SharedFunctionInfo::kFeedbackVectorOffset)); | 2734 FieldMemOperand(vector, SharedFunctionInfo::kFeedbackVectorOffset)); |
2587 } | 2735 } |
2588 | 2736 |
2589 | 2737 |
2590 void CallIC_ArrayStub::Generate(MacroAssembler* masm) { | 2738 void CallIC_ArrayStub::Generate(MacroAssembler* masm) { |
2591 // r1 - function | 2739 // r4 - function |
2592 // r3 - slot id | 2740 // r6 - slot id |
2593 Label miss; | 2741 Label miss; |
2594 int argc = arg_count(); | 2742 int argc = arg_count(); |
2595 ParameterCount actual(argc); | 2743 ParameterCount actual(argc); |
2596 | 2744 |
2597 EmitLoadTypeFeedbackVector(masm, r2); | 2745 EmitLoadTypeFeedbackVector(masm, r5); |
2598 | 2746 |
2599 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, r4); | 2747 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, r7); |
2600 __ cmp(r1, r4); | 2748 __ cmp(r4, r7); |
2601 __ b(ne, &miss); | 2749 __ bne(&miss); |
2602 | 2750 |
2603 __ mov(r0, Operand(arg_count())); | 2751 __ mov(r3, Operand(arg_count())); |
2604 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3)); | 2752 __ SmiToPtrArrayOffset(r7, r6); |
2605 __ ldr(r4, FieldMemOperand(r4, FixedArray::kHeaderSize)); | 2753 __ add(r7, r5, r7); |
| 2754 __ LoadP(r7, FieldMemOperand(r7, FixedArray::kHeaderSize)); |
2606 | 2755 |
2607 // Verify that r4 contains an AllocationSite | 2756 // Verify that r7 contains an AllocationSite |
2608 __ ldr(r5, FieldMemOperand(r4, HeapObject::kMapOffset)); | 2757 __ LoadP(r8, FieldMemOperand(r7, HeapObject::kMapOffset)); |
2609 __ CompareRoot(r5, Heap::kAllocationSiteMapRootIndex); | 2758 __ CompareRoot(r8, Heap::kAllocationSiteMapRootIndex); |
2610 __ b(ne, &miss); | 2759 __ bne(&miss); |
2611 | 2760 |
2612 __ mov(r2, r4); | 2761 __ mr(r5, r7); |
2613 ArrayConstructorStub stub(masm->isolate(), arg_count()); | 2762 ArrayConstructorStub stub(masm->isolate(), arg_count()); |
2614 __ TailCallStub(&stub); | 2763 __ TailCallStub(&stub); |
2615 | 2764 |
2616 __ bind(&miss); | 2765 __ bind(&miss); |
2617 GenerateMiss(masm); | 2766 GenerateMiss(masm); |
2618 | 2767 |
2619 // The slow case, we need this no matter what to complete a call after a miss. | 2768 // The slow case, we need this no matter what to complete a call after a miss. |
2620 CallFunctionNoFeedback(masm, | 2769 CallFunctionNoFeedback(masm, arg_count(), true, CallAsMethod()); |
2621 arg_count(), | |
2622 true, | |
2623 CallAsMethod()); | |
2624 | 2770 |
2625 // Unreachable. | 2771 // Unreachable. |
2626 __ stop("Unexpected code address"); | 2772 __ stop("Unexpected code address"); |
2627 } | 2773 } |
2628 | 2774 |
2629 | 2775 |
2630 void CallICStub::Generate(MacroAssembler* masm) { | 2776 void CallICStub::Generate(MacroAssembler* masm) { |
2631 // r1 - function | 2777 // r4 - function |
2632 // r3 - slot id (Smi) | 2778 // r6 - slot id (Smi) |
2633 const int with_types_offset = | |
2634 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kWithTypesIndex); | |
2635 const int generic_offset = | |
2636 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kGenericCountIndex); | |
2637 Label extra_checks_or_miss, slow_start; | 2779 Label extra_checks_or_miss, slow_start; |
2638 Label slow, non_function, wrap, cont; | 2780 Label slow, non_function, wrap, cont; |
2639 Label have_js_function; | 2781 Label have_js_function; |
2640 int argc = arg_count(); | 2782 int argc = arg_count(); |
2641 ParameterCount actual(argc); | 2783 ParameterCount actual(argc); |
2642 | 2784 |
2643 EmitLoadTypeFeedbackVector(masm, r2); | 2785 EmitLoadTypeFeedbackVector(masm, r5); |
2644 | 2786 |
2645 // The checks. First, does r1 match the recorded monomorphic target? | 2787 // The checks. First, does r4 match the recorded monomorphic target? |
2646 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3)); | 2788 __ SmiToPtrArrayOffset(r7, r6); |
2647 __ ldr(r4, FieldMemOperand(r4, FixedArray::kHeaderSize)); | 2789 __ add(r7, r5, r7); |
2648 __ cmp(r1, r4); | 2790 __ LoadP(r7, FieldMemOperand(r7, FixedArray::kHeaderSize)); |
2649 __ b(ne, &extra_checks_or_miss); | 2791 __ cmp(r4, r7); |
| 2792 __ bne(&extra_checks_or_miss); |
2650 | 2793 |
2651 __ bind(&have_js_function); | 2794 __ bind(&have_js_function); |
2652 if (CallAsMethod()) { | 2795 if (CallAsMethod()) { |
2653 EmitContinueIfStrictOrNative(masm, &cont); | 2796 EmitContinueIfStrictOrNative(masm, &cont); |
2654 // Compute the receiver in sloppy mode. | 2797 // Compute the receiver in sloppy mode. |
2655 __ ldr(r3, MemOperand(sp, argc * kPointerSize)); | 2798 __ LoadP(r6, MemOperand(sp, argc * kPointerSize), r0); |
2656 | 2799 |
2657 __ JumpIfSmi(r3, &wrap); | 2800 __ JumpIfSmi(r6, &wrap); |
2658 __ CompareObjectType(r3, r4, r4, FIRST_SPEC_OBJECT_TYPE); | 2801 __ CompareObjectType(r6, r7, r7, FIRST_SPEC_OBJECT_TYPE); |
2659 __ b(lt, &wrap); | 2802 __ blt(&wrap); |
2660 | 2803 |
2661 __ bind(&cont); | 2804 __ bind(&cont); |
2662 } | 2805 } |
2663 | 2806 |
2664 __ InvokeFunction(r1, actual, JUMP_FUNCTION, NullCallWrapper()); | 2807 __ InvokeFunction(r4, actual, JUMP_FUNCTION, NullCallWrapper()); |
2665 | 2808 |
2666 __ bind(&slow); | 2809 __ bind(&slow); |
2667 EmitSlowCase(masm, argc, &non_function); | 2810 EmitSlowCase(masm, argc, &non_function); |
2668 | 2811 |
2669 if (CallAsMethod()) { | 2812 if (CallAsMethod()) { |
2670 __ bind(&wrap); | 2813 __ bind(&wrap); |
2671 EmitWrapCase(masm, argc, &cont); | 2814 EmitWrapCase(masm, argc, &cont); |
2672 } | 2815 } |
2673 | 2816 |
2674 __ bind(&extra_checks_or_miss); | 2817 __ bind(&extra_checks_or_miss); |
2675 Label uninitialized, miss; | 2818 Label miss; |
2676 | 2819 |
2677 __ CompareRoot(r4, Heap::kmegamorphic_symbolRootIndex); | 2820 __ CompareRoot(r7, Heap::kmegamorphic_symbolRootIndex); |
2678 __ b(eq, &slow_start); | 2821 __ beq(&slow_start); |
| 2822 __ CompareRoot(r7, Heap::kuninitialized_symbolRootIndex); |
| 2823 __ beq(&miss); |
2679 | 2824 |
2680 // The following cases attempt to handle MISS cases without going to the | 2825 if (!FLAG_trace_ic) { |
2681 // runtime. | 2826 // We are going megamorphic. If the feedback is a JSFunction, it is fine |
2682 if (FLAG_trace_ic) { | 2827 // to handle it here. More complex cases are dealt with in the runtime. |
2683 __ jmp(&miss); | 2828 __ AssertNotSmi(r7); |
| 2829 __ CompareObjectType(r7, r8, r8, JS_FUNCTION_TYPE); |
| 2830 __ bne(&miss); |
| 2831 __ SmiToPtrArrayOffset(r7, r6); |
| 2832 __ add(r7, r5, r7); |
| 2833 __ LoadRoot(ip, Heap::kmegamorphic_symbolRootIndex); |
| 2834 __ StoreP(ip, FieldMemOperand(r7, FixedArray::kHeaderSize), r0); |
| 2835 // We have to update statistics for runtime profiling. |
| 2836 const int with_types_offset = |
| 2837 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kWithTypesIndex); |
| 2838 __ LoadP(r7, FieldMemOperand(r5, with_types_offset)); |
| 2839 __ SubSmiLiteral(r7, r7, Smi::FromInt(1), r0); |
| 2840 __ StoreP(r7, FieldMemOperand(r5, with_types_offset), r0); |
| 2841 const int generic_offset = |
| 2842 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kGenericCountIndex); |
| 2843 __ LoadP(r7, FieldMemOperand(r5, generic_offset)); |
| 2844 __ AddSmiLiteral(r7, r7, Smi::FromInt(1), r0); |
| 2845 __ StoreP(r7, FieldMemOperand(r5, generic_offset), r0); |
| 2846 __ jmp(&slow_start); |
2684 } | 2847 } |
2685 | 2848 |
2686 __ CompareRoot(r4, Heap::kuninitialized_symbolRootIndex); | 2849 // We are here because tracing is on or we are going monomorphic. |
2687 __ b(eq, &uninitialized); | |
2688 | |
2689 // We are going megamorphic. If the feedback is a JSFunction, it is fine | |
2690 // to handle it here. More complex cases are dealt with in the runtime. | |
2691 __ AssertNotSmi(r4); | |
2692 __ CompareObjectType(r4, r5, r5, JS_FUNCTION_TYPE); | |
2693 __ b(ne, &miss); | |
2694 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3)); | |
2695 __ LoadRoot(ip, Heap::kmegamorphic_symbolRootIndex); | |
2696 __ str(ip, FieldMemOperand(r4, FixedArray::kHeaderSize)); | |
2697 // We have to update statistics for runtime profiling. | |
2698 __ ldr(r4, FieldMemOperand(r2, with_types_offset)); | |
2699 __ sub(r4, r4, Operand(Smi::FromInt(1))); | |
2700 __ str(r4, FieldMemOperand(r2, with_types_offset)); | |
2701 __ ldr(r4, FieldMemOperand(r2, generic_offset)); | |
2702 __ add(r4, r4, Operand(Smi::FromInt(1))); | |
2703 __ str(r4, FieldMemOperand(r2, generic_offset)); | |
2704 __ jmp(&slow_start); | |
2705 | |
2706 __ bind(&uninitialized); | |
2707 | |
2708 // We are going monomorphic, provided we actually have a JSFunction. | |
2709 __ JumpIfSmi(r1, &miss); | |
2710 | |
2711 // Goto miss case if we do not have a function. | |
2712 __ CompareObjectType(r1, r4, r4, JS_FUNCTION_TYPE); | |
2713 __ b(ne, &miss); | |
2714 | |
2715 // Make sure the function is not the Array() function, which requires special | |
2716 // behavior on MISS. | |
2717 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, r4); | |
2718 __ cmp(r1, r4); | |
2719 __ b(eq, &miss); | |
2720 | |
2721 // Update stats. | |
2722 __ ldr(r4, FieldMemOperand(r2, with_types_offset)); | |
2723 __ add(r4, r4, Operand(Smi::FromInt(1))); | |
2724 __ str(r4, FieldMemOperand(r2, with_types_offset)); | |
2725 | |
2726 // Store the function. | |
2727 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3)); | |
2728 __ add(r4, r4, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | |
2729 __ str(r1, MemOperand(r4, 0)); | |
2730 | |
2731 // Update the write barrier. | |
2732 __ mov(r5, r1); | |
2733 __ RecordWrite(r2, r4, r5, kLRHasNotBeenSaved, kDontSaveFPRegs, | |
2734 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); | |
2735 __ jmp(&have_js_function); | |
2736 | |
2737 // We are here because tracing is on or we encountered a MISS case we can't | |
2738 // handle here. | |
2739 __ bind(&miss); | 2850 __ bind(&miss); |
2740 GenerateMiss(masm); | 2851 GenerateMiss(masm); |
2741 | 2852 |
2742 // the slow case | 2853 // the slow case |
2743 __ bind(&slow_start); | 2854 __ bind(&slow_start); |
2744 // Check that the function is really a JavaScript function. | 2855 // Check that the function is really a JavaScript function. |
2745 // r1: pushed function (to be verified) | 2856 // r4: pushed function (to be verified) |
2746 __ JumpIfSmi(r1, &non_function); | 2857 __ JumpIfSmi(r4, &non_function); |
2747 | 2858 |
2748 // Goto slow case if we do not have a function. | 2859 // Goto slow case if we do not have a function. |
2749 __ CompareObjectType(r1, r4, r4, JS_FUNCTION_TYPE); | 2860 __ CompareObjectType(r4, r7, r7, JS_FUNCTION_TYPE); |
2750 __ b(ne, &slow); | 2861 __ bne(&slow); |
2751 __ jmp(&have_js_function); | 2862 __ b(&have_js_function); |
2752 } | 2863 } |
2753 | 2864 |
2754 | 2865 |
2755 void CallICStub::GenerateMiss(MacroAssembler* masm) { | 2866 void CallICStub::GenerateMiss(MacroAssembler* masm) { |
2756 // Get the receiver of the function from the stack; 1 ~ return address. | 2867 // Get the receiver of the function from the stack; 1 ~ return address. |
2757 __ ldr(r4, MemOperand(sp, (arg_count() + 1) * kPointerSize)); | 2868 __ LoadP(r7, MemOperand(sp, (arg_count() + 1) * kPointerSize), r0); |
2758 | 2869 |
2759 { | 2870 { |
2760 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 2871 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
2761 | 2872 |
2762 // Push the receiver and the function and feedback info. | 2873 // Push the receiver and the function and feedback info. |
2763 __ Push(r4, r1, r2, r3); | 2874 __ Push(r7, r4, r5, r6); |
2764 | 2875 |
2765 // Call the entry. | 2876 // Call the entry. |
2766 IC::UtilityId id = GetICState() == DEFAULT ? IC::kCallIC_Miss | 2877 IC::UtilityId id = GetICState() == DEFAULT ? IC::kCallIC_Miss |
2767 : IC::kCallIC_Customization_Miss; | 2878 : IC::kCallIC_Customization_Miss; |
2768 | 2879 |
2769 ExternalReference miss = ExternalReference(IC_Utility(id), | 2880 ExternalReference miss = ExternalReference(IC_Utility(id), masm->isolate()); |
2770 masm->isolate()); | |
2771 __ CallExternalReference(miss, 4); | 2881 __ CallExternalReference(miss, 4); |
2772 | 2882 |
2773 // Move result to edi and exit the internal frame. | 2883 // Move result to r4 and exit the internal frame. |
2774 __ mov(r1, r0); | 2884 __ mr(r4, r3); |
2775 } | 2885 } |
2776 } | 2886 } |
2777 | 2887 |
2778 | 2888 |
2779 // StringCharCodeAtGenerator | 2889 // StringCharCodeAtGenerator |
2780 void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) { | 2890 void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) { |
2781 // If the receiver is a smi trigger the non-string case. | 2891 // If the receiver is a smi trigger the non-string case. |
2782 if (check_mode_ == RECEIVER_IS_UNKNOWN) { | 2892 if (check_mode_ == RECEIVER_IS_UNKNOWN) { |
2783 __ JumpIfSmi(object_, receiver_not_string_); | 2893 __ JumpIfSmi(object_, receiver_not_string_); |
2784 | 2894 |
2785 // Fetch the instance type of the receiver into result register. | 2895 // Fetch the instance type of the receiver into result register. |
2786 __ ldr(result_, FieldMemOperand(object_, HeapObject::kMapOffset)); | 2896 __ LoadP(result_, FieldMemOperand(object_, HeapObject::kMapOffset)); |
2787 __ ldrb(result_, FieldMemOperand(result_, Map::kInstanceTypeOffset)); | 2897 __ lbz(result_, FieldMemOperand(result_, Map::kInstanceTypeOffset)); |
2788 // If the receiver is not a string trigger the non-string case. | 2898 // If the receiver is not a string trigger the non-string case. |
2789 __ tst(result_, Operand(kIsNotStringMask)); | 2899 __ andi(r0, result_, Operand(kIsNotStringMask)); |
2790 __ b(ne, receiver_not_string_); | 2900 __ bne(receiver_not_string_, cr0); |
2791 } | 2901 } |
2792 | 2902 |
2793 // If the index is non-smi trigger the non-smi case. | 2903 // If the index is non-smi trigger the non-smi case. |
2794 __ JumpIfNotSmi(index_, &index_not_smi_); | 2904 __ JumpIfNotSmi(index_, &index_not_smi_); |
2795 __ bind(&got_smi_index_); | 2905 __ bind(&got_smi_index_); |
2796 | 2906 |
2797 // Check for index out of range. | 2907 // Check for index out of range. |
2798 __ ldr(ip, FieldMemOperand(object_, String::kLengthOffset)); | 2908 __ LoadP(ip, FieldMemOperand(object_, String::kLengthOffset)); |
2799 __ cmp(ip, Operand(index_)); | 2909 __ cmpl(ip, index_); |
2800 __ b(ls, index_out_of_range_); | 2910 __ ble(index_out_of_range_); |
2801 | 2911 |
2802 __ SmiUntag(index_); | 2912 __ SmiUntag(index_); |
2803 | 2913 |
2804 StringCharLoadGenerator::Generate(masm, | 2914 StringCharLoadGenerator::Generate(masm, object_, index_, result_, |
2805 object_, | |
2806 index_, | |
2807 result_, | |
2808 &call_runtime_); | 2915 &call_runtime_); |
2809 | 2916 |
2810 __ SmiTag(result_); | 2917 __ SmiTag(result_); |
2811 __ bind(&exit_); | 2918 __ bind(&exit_); |
2812 } | 2919 } |
2813 | 2920 |
2814 | 2921 |
2815 void StringCharCodeAtGenerator::GenerateSlow( | 2922 void StringCharCodeAtGenerator::GenerateSlow( |
2816 MacroAssembler* masm, | 2923 MacroAssembler* masm, const RuntimeCallHelper& call_helper) { |
2817 const RuntimeCallHelper& call_helper) { | |
2818 __ Abort(kUnexpectedFallthroughToCharCodeAtSlowCase); | 2924 __ Abort(kUnexpectedFallthroughToCharCodeAtSlowCase); |
2819 | 2925 |
2820 // Index is not a smi. | 2926 // Index is not a smi. |
2821 __ bind(&index_not_smi_); | 2927 __ bind(&index_not_smi_); |
2822 // If index is a heap number, try converting it to an integer. | 2928 // If index is a heap number, try converting it to an integer. |
2823 __ CheckMap(index_, | 2929 __ CheckMap(index_, result_, Heap::kHeapNumberMapRootIndex, index_not_number_, |
2824 result_, | |
2825 Heap::kHeapNumberMapRootIndex, | |
2826 index_not_number_, | |
2827 DONT_DO_SMI_CHECK); | 2930 DONT_DO_SMI_CHECK); |
2828 call_helper.BeforeCall(masm); | 2931 call_helper.BeforeCall(masm); |
2829 __ push(object_); | 2932 __ push(object_); |
2830 __ push(index_); // Consumed by runtime conversion function. | 2933 __ push(index_); // Consumed by runtime conversion function. |
2831 if (index_flags_ == STRING_INDEX_IS_NUMBER) { | 2934 if (index_flags_ == STRING_INDEX_IS_NUMBER) { |
2832 __ CallRuntime(Runtime::kNumberToIntegerMapMinusZero, 1); | 2935 __ CallRuntime(Runtime::kNumberToIntegerMapMinusZero, 1); |
2833 } else { | 2936 } else { |
2834 DCHECK(index_flags_ == STRING_INDEX_IS_ARRAY_INDEX); | 2937 DCHECK(index_flags_ == STRING_INDEX_IS_ARRAY_INDEX); |
2835 // NumberToSmi discards numbers that are not exact integers. | 2938 // NumberToSmi discards numbers that are not exact integers. |
2836 __ CallRuntime(Runtime::kNumberToSmi, 1); | 2939 __ CallRuntime(Runtime::kNumberToSmi, 1); |
2837 } | 2940 } |
2838 // Save the conversion result before the pop instructions below | 2941 // Save the conversion result before the pop instructions below |
2839 // have a chance to overwrite it. | 2942 // have a chance to overwrite it. |
2840 __ Move(index_, r0); | 2943 __ Move(index_, r3); |
2841 __ pop(object_); | 2944 __ pop(object_); |
2842 // Reload the instance type. | 2945 // Reload the instance type. |
2843 __ ldr(result_, FieldMemOperand(object_, HeapObject::kMapOffset)); | 2946 __ LoadP(result_, FieldMemOperand(object_, HeapObject::kMapOffset)); |
2844 __ ldrb(result_, FieldMemOperand(result_, Map::kInstanceTypeOffset)); | 2947 __ lbz(result_, FieldMemOperand(result_, Map::kInstanceTypeOffset)); |
2845 call_helper.AfterCall(masm); | 2948 call_helper.AfterCall(masm); |
2846 // If index is still not a smi, it must be out of range. | 2949 // If index is still not a smi, it must be out of range. |
2847 __ JumpIfNotSmi(index_, index_out_of_range_); | 2950 __ JumpIfNotSmi(index_, index_out_of_range_); |
2848 // Otherwise, return to the fast path. | 2951 // Otherwise, return to the fast path. |
2849 __ jmp(&got_smi_index_); | 2952 __ b(&got_smi_index_); |
2850 | 2953 |
2851 // Call runtime. We get here when the receiver is a string and the | 2954 // Call runtime. We get here when the receiver is a string and the |
2852 // index is a number, but the code of getting the actual character | 2955 // index is a number, but the code of getting the actual character |
2853 // is too complex (e.g., when the string needs to be flattened). | 2956 // is too complex (e.g., when the string needs to be flattened). |
2854 __ bind(&call_runtime_); | 2957 __ bind(&call_runtime_); |
2855 call_helper.BeforeCall(masm); | 2958 call_helper.BeforeCall(masm); |
2856 __ SmiTag(index_); | 2959 __ SmiTag(index_); |
2857 __ Push(object_, index_); | 2960 __ Push(object_, index_); |
2858 __ CallRuntime(Runtime::kStringCharCodeAtRT, 2); | 2961 __ CallRuntime(Runtime::kStringCharCodeAtRT, 2); |
2859 __ Move(result_, r0); | 2962 __ Move(result_, r3); |
2860 call_helper.AfterCall(masm); | 2963 call_helper.AfterCall(masm); |
2861 __ jmp(&exit_); | 2964 __ b(&exit_); |
2862 | 2965 |
2863 __ Abort(kUnexpectedFallthroughFromCharCodeAtSlowCase); | 2966 __ Abort(kUnexpectedFallthroughFromCharCodeAtSlowCase); |
2864 } | 2967 } |
2865 | 2968 |
2866 | 2969 |
2867 // ------------------------------------------------------------------------- | 2970 // ------------------------------------------------------------------------- |
2868 // StringCharFromCodeGenerator | 2971 // StringCharFromCodeGenerator |
2869 | 2972 |
2870 void StringCharFromCodeGenerator::GenerateFast(MacroAssembler* masm) { | 2973 void StringCharFromCodeGenerator::GenerateFast(MacroAssembler* masm) { |
2871 // Fast case of Heap::LookupSingleCharacterStringFromCode. | 2974 // Fast case of Heap::LookupSingleCharacterStringFromCode. |
2872 STATIC_ASSERT(kSmiTag == 0); | |
2873 STATIC_ASSERT(kSmiShiftSize == 0); | |
2874 DCHECK(base::bits::IsPowerOfTwo32(String::kMaxOneByteCharCode + 1)); | 2975 DCHECK(base::bits::IsPowerOfTwo32(String::kMaxOneByteCharCode + 1)); |
2875 __ tst(code_, | 2976 __ LoadSmiLiteral(r0, Smi::FromInt(~String::kMaxOneByteCharCode)); |
2876 Operand(kSmiTagMask | | 2977 __ ori(r0, r0, Operand(kSmiTagMask)); |
2877 ((~String::kMaxOneByteCharCode) << kSmiTagSize))); | 2978 __ and_(r0, code_, r0); |
2878 __ b(ne, &slow_case_); | 2979 __ cmpi(r0, Operand::Zero()); |
| 2980 __ bne(&slow_case_); |
2879 | 2981 |
2880 __ LoadRoot(result_, Heap::kSingleCharacterStringCacheRootIndex); | 2982 __ LoadRoot(result_, Heap::kSingleCharacterStringCacheRootIndex); |
2881 // At this point code register contains smi tagged one-byte char code. | 2983 // At this point code register contains smi tagged one-byte char code. |
2882 __ add(result_, result_, Operand::PointerOffsetFromSmiKey(code_)); | 2984 __ mr(r0, code_); |
2883 __ ldr(result_, FieldMemOperand(result_, FixedArray::kHeaderSize)); | 2985 __ SmiToPtrArrayOffset(code_, code_); |
| 2986 __ add(result_, result_, code_); |
| 2987 __ mr(code_, r0); |
| 2988 __ LoadP(result_, FieldMemOperand(result_, FixedArray::kHeaderSize)); |
2884 __ CompareRoot(result_, Heap::kUndefinedValueRootIndex); | 2989 __ CompareRoot(result_, Heap::kUndefinedValueRootIndex); |
2885 __ b(eq, &slow_case_); | 2990 __ beq(&slow_case_); |
2886 __ bind(&exit_); | 2991 __ bind(&exit_); |
2887 } | 2992 } |
2888 | 2993 |
2889 | 2994 |
2890 void StringCharFromCodeGenerator::GenerateSlow( | 2995 void StringCharFromCodeGenerator::GenerateSlow( |
2891 MacroAssembler* masm, | 2996 MacroAssembler* masm, const RuntimeCallHelper& call_helper) { |
2892 const RuntimeCallHelper& call_helper) { | |
2893 __ Abort(kUnexpectedFallthroughToCharFromCodeSlowCase); | 2997 __ Abort(kUnexpectedFallthroughToCharFromCodeSlowCase); |
2894 | 2998 |
2895 __ bind(&slow_case_); | 2999 __ bind(&slow_case_); |
2896 call_helper.BeforeCall(masm); | 3000 call_helper.BeforeCall(masm); |
2897 __ push(code_); | 3001 __ push(code_); |
2898 __ CallRuntime(Runtime::kCharFromCode, 1); | 3002 __ CallRuntime(Runtime::kCharFromCode, 1); |
2899 __ Move(result_, r0); | 3003 __ Move(result_, r3); |
2900 call_helper.AfterCall(masm); | 3004 call_helper.AfterCall(masm); |
2901 __ jmp(&exit_); | 3005 __ b(&exit_); |
2902 | 3006 |
2903 __ Abort(kUnexpectedFallthroughFromCharFromCodeSlowCase); | 3007 __ Abort(kUnexpectedFallthroughFromCharFromCodeSlowCase); |
2904 } | 3008 } |
2905 | 3009 |
2906 | 3010 |
2907 enum CopyCharactersFlags { COPY_ONE_BYTE = 1, DEST_ALWAYS_ALIGNED = 2 }; | 3011 enum CopyCharactersFlags { COPY_ONE_BYTE = 1, DEST_ALWAYS_ALIGNED = 2 }; |
2908 | 3012 |
2909 | 3013 |
2910 void StringHelper::GenerateCopyCharacters(MacroAssembler* masm, | 3014 void StringHelper::GenerateCopyCharacters(MacroAssembler* masm, Register dest, |
2911 Register dest, | 3015 Register src, Register count, |
2912 Register src, | |
2913 Register count, | |
2914 Register scratch, | 3016 Register scratch, |
2915 String::Encoding encoding) { | 3017 String::Encoding encoding) { |
2916 if (FLAG_debug_code) { | 3018 if (FLAG_debug_code) { |
2917 // Check that destination is word aligned. | 3019 // Check that destination is word aligned. |
2918 __ tst(dest, Operand(kPointerAlignmentMask)); | 3020 __ andi(r0, dest, Operand(kPointerAlignmentMask)); |
2919 __ Check(eq, kDestinationOfCopyNotAligned); | 3021 __ Check(eq, kDestinationOfCopyNotAligned, cr0); |
2920 } | 3022 } |
2921 | 3023 |
2922 // Assumes word reads and writes are little endian. | |
2923 // Nothing to do for zero characters. | 3024 // Nothing to do for zero characters. |
2924 Label done; | 3025 Label done; |
2925 if (encoding == String::TWO_BYTE_ENCODING) { | 3026 if (encoding == String::TWO_BYTE_ENCODING) { |
2926 __ add(count, count, Operand(count), SetCC); | 3027 // double the length |
| 3028 __ add(count, count, count, LeaveOE, SetRC); |
| 3029 __ beq(&done, cr0); |
| 3030 } else { |
| 3031 __ cmpi(count, Operand::Zero()); |
| 3032 __ beq(&done); |
2927 } | 3033 } |
2928 | 3034 |
2929 Register limit = count; // Read until dest equals this. | 3035 // Copy count bytes from src to dst. |
2930 __ add(limit, dest, Operand(count)); | 3036 Label byte_loop; |
2931 | 3037 __ mtctr(count); |
2932 Label loop_entry, loop; | 3038 __ bind(&byte_loop); |
2933 // Copy bytes from src to dest until dest hits limit. | 3039 __ lbz(scratch, MemOperand(src)); |
2934 __ b(&loop_entry); | 3040 __ addi(src, src, Operand(1)); |
2935 __ bind(&loop); | 3041 __ stb(scratch, MemOperand(dest)); |
2936 __ ldrb(scratch, MemOperand(src, 1, PostIndex), lt); | 3042 __ addi(dest, dest, Operand(1)); |
2937 __ strb(scratch, MemOperand(dest, 1, PostIndex)); | 3043 __ bdnz(&byte_loop); |
2938 __ bind(&loop_entry); | |
2939 __ cmp(dest, Operand(limit)); | |
2940 __ b(lt, &loop); | |
2941 | 3044 |
2942 __ bind(&done); | 3045 __ bind(&done); |
2943 } | 3046 } |
2944 | 3047 |
2945 | 3048 |
2946 void SubStringStub::Generate(MacroAssembler* masm) { | 3049 void SubStringStub::Generate(MacroAssembler* masm) { |
2947 Label runtime; | 3050 Label runtime; |
2948 | 3051 |
2949 // Stack frame on entry. | 3052 // Stack frame on entry. |
2950 // lr: return address | 3053 // lr: return address |
2951 // sp[0]: to | 3054 // sp[0]: to |
2952 // sp[4]: from | 3055 // sp[4]: from |
2953 // sp[8]: string | 3056 // sp[8]: string |
2954 | 3057 |
2955 // This stub is called from the native-call %_SubString(...), so | 3058 // This stub is called from the native-call %_SubString(...), so |
2956 // nothing can be assumed about the arguments. It is tested that: | 3059 // nothing can be assumed about the arguments. It is tested that: |
2957 // "string" is a sequential string, | 3060 // "string" is a sequential string, |
2958 // both "from" and "to" are smis, and | 3061 // both "from" and "to" are smis, and |
2959 // 0 <= from <= to <= string.length. | 3062 // 0 <= from <= to <= string.length. |
2960 // If any of these assumptions fail, we call the runtime system. | 3063 // If any of these assumptions fail, we call the runtime system. |
2961 | 3064 |
2962 const int kToOffset = 0 * kPointerSize; | 3065 const int kToOffset = 0 * kPointerSize; |
2963 const int kFromOffset = 1 * kPointerSize; | 3066 const int kFromOffset = 1 * kPointerSize; |
2964 const int kStringOffset = 2 * kPointerSize; | 3067 const int kStringOffset = 2 * kPointerSize; |
2965 | 3068 |
2966 __ Ldrd(r2, r3, MemOperand(sp, kToOffset)); | 3069 __ LoadP(r5, MemOperand(sp, kToOffset)); |
2967 STATIC_ASSERT(kFromOffset == kToOffset + 4); | 3070 __ LoadP(r6, MemOperand(sp, kFromOffset)); |
2968 STATIC_ASSERT(kSmiTag == 0); | |
2969 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); | |
2970 | 3071 |
2971 // Arithmetic shift right by one un-smi-tags. In this case we rotate right | 3072 // If either to or from had the smi tag bit set, then fail to generic runtime |
2972 // instead because we bail out on non-smi values: ROR and ASR are equivalent | 3073 __ JumpIfNotSmi(r5, &runtime); |
2973 // for smis but they set the flags in a way that's easier to optimize. | 3074 __ JumpIfNotSmi(r6, &runtime); |
2974 __ mov(r2, Operand(r2, ROR, 1), SetCC); | 3075 __ SmiUntag(r5); |
2975 __ mov(r3, Operand(r3, ROR, 1), SetCC, cc); | 3076 __ SmiUntag(r6, SetRC); |
2976 // If either to or from had the smi tag bit set, then C is set now, and N | 3077 // Both r5 and r6 are untagged integers. |
2977 // has the same value: we rotated by 1, so the bottom bit is now the top bit. | 3078 |
2978 // We want to bailout to runtime here if From is negative. In that case, the | 3079 // We want to bailout to runtime here if From is negative. |
2979 // next instruction is not executed and we fall through to bailing out to | 3080 __ blt(&runtime, cr0); // From < 0. |
2980 // runtime. | 3081 |
2981 // Executed if both r2 and r3 are untagged integers. | 3082 __ cmpl(r6, r5); |
2982 __ sub(r2, r2, Operand(r3), SetCC, cc); | 3083 __ bgt(&runtime); // Fail if from > to. |
2983 // One of the above un-smis or the above SUB could have set N==1. | 3084 __ sub(r5, r5, r6); |
2984 __ b(mi, &runtime); // Either "from" or "to" is not an smi, or from > to. | |
2985 | 3085 |
2986 // Make sure first argument is a string. | 3086 // Make sure first argument is a string. |
2987 __ ldr(r0, MemOperand(sp, kStringOffset)); | 3087 __ LoadP(r3, MemOperand(sp, kStringOffset)); |
2988 __ JumpIfSmi(r0, &runtime); | 3088 __ JumpIfSmi(r3, &runtime); |
2989 Condition is_string = masm->IsObjectStringType(r0, r1); | 3089 Condition is_string = masm->IsObjectStringType(r3, r4); |
2990 __ b(NegateCondition(is_string), &runtime); | 3090 __ b(NegateCondition(is_string), &runtime, cr0); |
2991 | 3091 |
2992 Label single_char; | 3092 Label single_char; |
2993 __ cmp(r2, Operand(1)); | 3093 __ cmpi(r5, Operand(1)); |
2994 __ b(eq, &single_char); | 3094 __ b(eq, &single_char); |
2995 | 3095 |
2996 // Short-cut for the case of trivial substring. | 3096 // Short-cut for the case of trivial substring. |
2997 Label return_r0; | 3097 Label return_r3; |
2998 // r0: original string | 3098 // r3: original string |
2999 // r2: result string length | 3099 // r5: result string length |
3000 __ ldr(r4, FieldMemOperand(r0, String::kLengthOffset)); | 3100 __ LoadP(r7, FieldMemOperand(r3, String::kLengthOffset)); |
3001 __ cmp(r2, Operand(r4, ASR, 1)); | 3101 __ SmiUntag(r0, r7); |
| 3102 __ cmpl(r5, r0); |
3002 // Return original string. | 3103 // Return original string. |
3003 __ b(eq, &return_r0); | 3104 __ beq(&return_r3); |
3004 // Longer than original string's length or negative: unsafe arguments. | 3105 // Longer than original string's length or negative: unsafe arguments. |
3005 __ b(hi, &runtime); | 3106 __ bgt(&runtime); |
3006 // Shorter than original string's length: an actual substring. | 3107 // Shorter than original string's length: an actual substring. |
3007 | 3108 |
3008 // Deal with different string types: update the index if necessary | 3109 // Deal with different string types: update the index if necessary |
3009 // and put the underlying string into r5. | 3110 // and put the underlying string into r8. |
3010 // r0: original string | 3111 // r3: original string |
3011 // r1: instance type | 3112 // r4: instance type |
3012 // r2: length | 3113 // r5: length |
3013 // r3: from index (untagged) | 3114 // r6: from index (untagged) |
3014 Label underlying_unpacked, sliced_string, seq_or_external_string; | 3115 Label underlying_unpacked, sliced_string, seq_or_external_string; |
3015 // If the string is not indirect, it can only be sequential or external. | 3116 // If the string is not indirect, it can only be sequential or external. |
3016 STATIC_ASSERT(kIsIndirectStringMask == (kSlicedStringTag & kConsStringTag)); | 3117 STATIC_ASSERT(kIsIndirectStringMask == (kSlicedStringTag & kConsStringTag)); |
3017 STATIC_ASSERT(kIsIndirectStringMask != 0); | 3118 STATIC_ASSERT(kIsIndirectStringMask != 0); |
3018 __ tst(r1, Operand(kIsIndirectStringMask)); | 3119 __ andi(r0, r4, Operand(kIsIndirectStringMask)); |
3019 __ b(eq, &seq_or_external_string); | 3120 __ beq(&seq_or_external_string, cr0); |
3020 | 3121 |
3021 __ tst(r1, Operand(kSlicedNotConsMask)); | 3122 __ andi(r0, r4, Operand(kSlicedNotConsMask)); |
3022 __ b(ne, &sliced_string); | 3123 __ bne(&sliced_string, cr0); |
3023 // Cons string. Check whether it is flat, then fetch first part. | 3124 // Cons string. Check whether it is flat, then fetch first part. |
3024 __ ldr(r5, FieldMemOperand(r0, ConsString::kSecondOffset)); | 3125 __ LoadP(r8, FieldMemOperand(r3, ConsString::kSecondOffset)); |
3025 __ CompareRoot(r5, Heap::kempty_stringRootIndex); | 3126 __ CompareRoot(r8, Heap::kempty_stringRootIndex); |
3026 __ b(ne, &runtime); | 3127 __ bne(&runtime); |
3027 __ ldr(r5, FieldMemOperand(r0, ConsString::kFirstOffset)); | 3128 __ LoadP(r8, FieldMemOperand(r3, ConsString::kFirstOffset)); |
3028 // Update instance type. | 3129 // Update instance type. |
3029 __ ldr(r1, FieldMemOperand(r5, HeapObject::kMapOffset)); | 3130 __ LoadP(r4, FieldMemOperand(r8, HeapObject::kMapOffset)); |
3030 __ ldrb(r1, FieldMemOperand(r1, Map::kInstanceTypeOffset)); | 3131 __ lbz(r4, FieldMemOperand(r4, Map::kInstanceTypeOffset)); |
3031 __ jmp(&underlying_unpacked); | 3132 __ b(&underlying_unpacked); |
3032 | 3133 |
3033 __ bind(&sliced_string); | 3134 __ bind(&sliced_string); |
3034 // Sliced string. Fetch parent and correct start index by offset. | 3135 // Sliced string. Fetch parent and correct start index by offset. |
3035 __ ldr(r5, FieldMemOperand(r0, SlicedString::kParentOffset)); | 3136 __ LoadP(r8, FieldMemOperand(r3, SlicedString::kParentOffset)); |
3036 __ ldr(r4, FieldMemOperand(r0, SlicedString::kOffsetOffset)); | 3137 __ LoadP(r7, FieldMemOperand(r3, SlicedString::kOffsetOffset)); |
3037 __ add(r3, r3, Operand(r4, ASR, 1)); // Add offset to index. | 3138 __ SmiUntag(r4, r7); |
| 3139 __ add(r6, r6, r4); // Add offset to index. |
3038 // Update instance type. | 3140 // Update instance type. |
3039 __ ldr(r1, FieldMemOperand(r5, HeapObject::kMapOffset)); | 3141 __ LoadP(r4, FieldMemOperand(r8, HeapObject::kMapOffset)); |
3040 __ ldrb(r1, FieldMemOperand(r1, Map::kInstanceTypeOffset)); | 3142 __ lbz(r4, FieldMemOperand(r4, Map::kInstanceTypeOffset)); |
3041 __ jmp(&underlying_unpacked); | 3143 __ b(&underlying_unpacked); |
3042 | 3144 |
3043 __ bind(&seq_or_external_string); | 3145 __ bind(&seq_or_external_string); |
3044 // Sequential or external string. Just move string to the expected register. | 3146 // Sequential or external string. Just move string to the expected register. |
3045 __ mov(r5, r0); | 3147 __ mr(r8, r3); |
3046 | 3148 |
3047 __ bind(&underlying_unpacked); | 3149 __ bind(&underlying_unpacked); |
3048 | 3150 |
3049 if (FLAG_string_slices) { | 3151 if (FLAG_string_slices) { |
3050 Label copy_routine; | 3152 Label copy_routine; |
3051 // r5: underlying subject string | 3153 // r8: underlying subject string |
3052 // r1: instance type of underlying subject string | 3154 // r4: instance type of underlying subject string |
3053 // r2: length | 3155 // r5: length |
3054 // r3: adjusted start index (untagged) | 3156 // r6: adjusted start index (untagged) |
3055 __ cmp(r2, Operand(SlicedString::kMinLength)); | 3157 __ cmpi(r5, Operand(SlicedString::kMinLength)); |
3056 // Short slice. Copy instead of slicing. | 3158 // Short slice. Copy instead of slicing. |
3057 __ b(lt, ©_routine); | 3159 __ blt(©_routine); |
3058 // Allocate new sliced string. At this point we do not reload the instance | 3160 // Allocate new sliced string. At this point we do not reload the instance |
3059 // type including the string encoding because we simply rely on the info | 3161 // type including the string encoding because we simply rely on the info |
3060 // provided by the original string. It does not matter if the original | 3162 // provided by the original string. It does not matter if the original |
3061 // string's encoding is wrong because we always have to recheck encoding of | 3163 // string's encoding is wrong because we always have to recheck encoding of |
3062 // the newly created string's parent anyways due to externalized strings. | 3164 // the newly created string's parent anyways due to externalized strings. |
3063 Label two_byte_slice, set_slice_header; | 3165 Label two_byte_slice, set_slice_header; |
3064 STATIC_ASSERT((kStringEncodingMask & kOneByteStringTag) != 0); | 3166 STATIC_ASSERT((kStringEncodingMask & kOneByteStringTag) != 0); |
3065 STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0); | 3167 STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0); |
3066 __ tst(r1, Operand(kStringEncodingMask)); | 3168 __ andi(r0, r4, Operand(kStringEncodingMask)); |
3067 __ b(eq, &two_byte_slice); | 3169 __ beq(&two_byte_slice, cr0); |
3068 __ AllocateOneByteSlicedString(r0, r2, r6, r4, &runtime); | 3170 __ AllocateOneByteSlicedString(r3, r5, r9, r10, &runtime); |
3069 __ jmp(&set_slice_header); | 3171 __ b(&set_slice_header); |
3070 __ bind(&two_byte_slice); | 3172 __ bind(&two_byte_slice); |
3071 __ AllocateTwoByteSlicedString(r0, r2, r6, r4, &runtime); | 3173 __ AllocateTwoByteSlicedString(r3, r5, r9, r10, &runtime); |
3072 __ bind(&set_slice_header); | 3174 __ bind(&set_slice_header); |
3073 __ mov(r3, Operand(r3, LSL, 1)); | 3175 __ SmiTag(r6); |
3074 __ str(r5, FieldMemOperand(r0, SlicedString::kParentOffset)); | 3176 __ StoreP(r8, FieldMemOperand(r3, SlicedString::kParentOffset), r0); |
3075 __ str(r3, FieldMemOperand(r0, SlicedString::kOffsetOffset)); | 3177 __ StoreP(r6, FieldMemOperand(r3, SlicedString::kOffsetOffset), r0); |
3076 __ jmp(&return_r0); | 3178 __ b(&return_r3); |
3077 | 3179 |
3078 __ bind(©_routine); | 3180 __ bind(©_routine); |
3079 } | 3181 } |
3080 | 3182 |
3081 // r5: underlying subject string | 3183 // r8: underlying subject string |
3082 // r1: instance type of underlying subject string | 3184 // r4: instance type of underlying subject string |
3083 // r2: length | 3185 // r5: length |
3084 // r3: adjusted start index (untagged) | 3186 // r6: adjusted start index (untagged) |
3085 Label two_byte_sequential, sequential_string, allocate_result; | 3187 Label two_byte_sequential, sequential_string, allocate_result; |
3086 STATIC_ASSERT(kExternalStringTag != 0); | 3188 STATIC_ASSERT(kExternalStringTag != 0); |
3087 STATIC_ASSERT(kSeqStringTag == 0); | 3189 STATIC_ASSERT(kSeqStringTag == 0); |
3088 __ tst(r1, Operand(kExternalStringTag)); | 3190 __ andi(r0, r4, Operand(kExternalStringTag)); |
3089 __ b(eq, &sequential_string); | 3191 __ beq(&sequential_string, cr0); |
3090 | 3192 |
3091 // Handle external string. | 3193 // Handle external string. |
3092 // Rule out short external strings. | 3194 // Rule out short external strings. |
3093 STATIC_ASSERT(kShortExternalStringTag != 0); | 3195 STATIC_ASSERT(kShortExternalStringTag != 0); |
3094 __ tst(r1, Operand(kShortExternalStringTag)); | 3196 __ andi(r0, r4, Operand(kShortExternalStringTag)); |
3095 __ b(ne, &runtime); | 3197 __ bne(&runtime, cr0); |
3096 __ ldr(r5, FieldMemOperand(r5, ExternalString::kResourceDataOffset)); | 3198 __ LoadP(r8, FieldMemOperand(r8, ExternalString::kResourceDataOffset)); |
3097 // r5 already points to the first character of underlying string. | 3199 // r8 already points to the first character of underlying string. |
3098 __ jmp(&allocate_result); | 3200 __ b(&allocate_result); |
3099 | 3201 |
3100 __ bind(&sequential_string); | 3202 __ bind(&sequential_string); |
3101 // Locate first character of underlying subject string. | 3203 // Locate first character of underlying subject string. |
3102 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqOneByteString::kHeaderSize); | 3204 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqOneByteString::kHeaderSize); |
3103 __ add(r5, r5, Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); | 3205 __ addi(r8, r8, Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); |
3104 | 3206 |
3105 __ bind(&allocate_result); | 3207 __ bind(&allocate_result); |
3106 // Sequential acii string. Allocate the result. | 3208 // Sequential acii string. Allocate the result. |
3107 STATIC_ASSERT((kOneByteStringTag & kStringEncodingMask) != 0); | 3209 STATIC_ASSERT((kOneByteStringTag & kStringEncodingMask) != 0); |
3108 __ tst(r1, Operand(kStringEncodingMask)); | 3210 __ andi(r0, r4, Operand(kStringEncodingMask)); |
3109 __ b(eq, &two_byte_sequential); | 3211 __ beq(&two_byte_sequential, cr0); |
3110 | 3212 |
3111 // Allocate and copy the resulting one-byte string. | 3213 // Allocate and copy the resulting one-byte string. |
3112 __ AllocateOneByteString(r0, r2, r4, r6, r1, &runtime); | 3214 __ AllocateOneByteString(r3, r5, r7, r9, r10, &runtime); |
3113 | 3215 |
3114 // Locate first character of substring to copy. | 3216 // Locate first character of substring to copy. |
3115 __ add(r5, r5, r3); | 3217 __ add(r8, r8, r6); |
3116 // Locate first character of result. | 3218 // Locate first character of result. |
3117 __ add(r1, r0, Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); | 3219 __ addi(r4, r3, Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); |
3118 | 3220 |
3119 // r0: result string | 3221 // r3: result string |
3120 // r1: first character of result string | 3222 // r4: first character of result string |
3121 // r2: result string length | 3223 // r5: result string length |
3122 // r5: first character of substring to copy | 3224 // r8: first character of substring to copy |
3123 STATIC_ASSERT((SeqOneByteString::kHeaderSize & kObjectAlignmentMask) == 0); | 3225 STATIC_ASSERT((SeqOneByteString::kHeaderSize & kObjectAlignmentMask) == 0); |
3124 StringHelper::GenerateCopyCharacters( | 3226 StringHelper::GenerateCopyCharacters(masm, r4, r8, r5, r6, |
3125 masm, r1, r5, r2, r3, String::ONE_BYTE_ENCODING); | 3227 String::ONE_BYTE_ENCODING); |
3126 __ jmp(&return_r0); | 3228 __ b(&return_r3); |
3127 | 3229 |
3128 // Allocate and copy the resulting two-byte string. | 3230 // Allocate and copy the resulting two-byte string. |
3129 __ bind(&two_byte_sequential); | 3231 __ bind(&two_byte_sequential); |
3130 __ AllocateTwoByteString(r0, r2, r4, r6, r1, &runtime); | 3232 __ AllocateTwoByteString(r3, r5, r7, r9, r10, &runtime); |
3131 | 3233 |
3132 // Locate first character of substring to copy. | 3234 // Locate first character of substring to copy. |
3133 STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0); | 3235 __ ShiftLeftImm(r4, r6, Operand(1)); |
3134 __ add(r5, r5, Operand(r3, LSL, 1)); | 3236 __ add(r8, r8, r4); |
3135 // Locate first character of result. | 3237 // Locate first character of result. |
3136 __ add(r1, r0, Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); | 3238 __ addi(r4, r3, Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); |
3137 | 3239 |
3138 // r0: result string. | 3240 // r3: result string. |
3139 // r1: first character of result. | 3241 // r4: first character of result. |
3140 // r2: result length. | 3242 // r5: result length. |
3141 // r5: first character of substring to copy. | 3243 // r8: first character of substring to copy. |
3142 STATIC_ASSERT((SeqTwoByteString::kHeaderSize & kObjectAlignmentMask) == 0); | 3244 STATIC_ASSERT((SeqTwoByteString::kHeaderSize & kObjectAlignmentMask) == 0); |
3143 StringHelper::GenerateCopyCharacters( | 3245 StringHelper::GenerateCopyCharacters(masm, r4, r8, r5, r6, |
3144 masm, r1, r5, r2, r3, String::TWO_BYTE_ENCODING); | 3246 String::TWO_BYTE_ENCODING); |
3145 | 3247 |
3146 __ bind(&return_r0); | 3248 __ bind(&return_r3); |
3147 Counters* counters = isolate()->counters(); | 3249 Counters* counters = isolate()->counters(); |
3148 __ IncrementCounter(counters->sub_string_native(), 1, r3, r4); | 3250 __ IncrementCounter(counters->sub_string_native(), 1, r6, r7); |
3149 __ Drop(3); | 3251 __ Drop(3); |
3150 __ Ret(); | 3252 __ Ret(); |
3151 | 3253 |
3152 // Just jump to runtime to create the sub string. | 3254 // Just jump to runtime to create the sub string. |
3153 __ bind(&runtime); | 3255 __ bind(&runtime); |
3154 __ TailCallRuntime(Runtime::kSubString, 3, 1); | 3256 __ TailCallRuntime(Runtime::kSubString, 3, 1); |
3155 | 3257 |
3156 __ bind(&single_char); | 3258 __ bind(&single_char); |
3157 // r0: original string | 3259 // r3: original string |
3158 // r1: instance type | 3260 // r4: instance type |
3159 // r2: length | 3261 // r5: length |
3160 // r3: from index (untagged) | 3262 // r6: from index (untagged) |
3161 __ SmiTag(r3, r3); | 3263 __ SmiTag(r6, r6); |
3162 StringCharAtGenerator generator(r0, r3, r2, r0, &runtime, &runtime, &runtime, | 3264 StringCharAtGenerator generator(r3, r6, r5, r3, &runtime, &runtime, &runtime, |
3163 STRING_INDEX_IS_NUMBER, RECEIVER_IS_STRING); | 3265 STRING_INDEX_IS_NUMBER, RECEIVER_IS_STRING); |
3164 generator.GenerateFast(masm); | 3266 generator.GenerateFast(masm); |
3165 __ Drop(3); | 3267 __ Drop(3); |
3166 __ Ret(); | 3268 __ Ret(); |
3167 generator.SkipSlow(masm, &runtime); | 3269 generator.SkipSlow(masm, &runtime); |
3168 } | 3270 } |
3169 | 3271 |
3170 | 3272 |
3171 void ToNumberStub::Generate(MacroAssembler* masm) { | 3273 void StringHelper::GenerateFlatOneByteStringEquals(MacroAssembler* masm, |
3172 // The ToNumber stub takes one argument in r0. | 3274 Register left, |
3173 Label check_heap_number, call_builtin; | 3275 Register right, |
3174 __ JumpIfNotSmi(r0, &check_heap_number); | 3276 Register scratch1, |
3175 __ Ret(); | 3277 Register scratch2) { |
3176 | |
3177 __ bind(&check_heap_number); | |
3178 __ ldr(r1, FieldMemOperand(r0, HeapObject::kMapOffset)); | |
3179 __ CompareRoot(r1, Heap::kHeapNumberMapRootIndex); | |
3180 __ b(ne, &call_builtin); | |
3181 __ Ret(); | |
3182 | |
3183 __ bind(&call_builtin); | |
3184 __ push(r0); | |
3185 __ InvokeBuiltin(Builtins::TO_NUMBER, JUMP_FUNCTION); | |
3186 } | |
3187 | |
3188 | |
3189 void StringHelper::GenerateFlatOneByteStringEquals( | |
3190 MacroAssembler* masm, Register left, Register right, Register scratch1, | |
3191 Register scratch2, Register scratch3) { | |
3192 Register length = scratch1; | 3278 Register length = scratch1; |
3193 | 3279 |
3194 // Compare lengths. | 3280 // Compare lengths. |
3195 Label strings_not_equal, check_zero_length; | 3281 Label strings_not_equal, check_zero_length; |
3196 __ ldr(length, FieldMemOperand(left, String::kLengthOffset)); | 3282 __ LoadP(length, FieldMemOperand(left, String::kLengthOffset)); |
3197 __ ldr(scratch2, FieldMemOperand(right, String::kLengthOffset)); | 3283 __ LoadP(scratch2, FieldMemOperand(right, String::kLengthOffset)); |
3198 __ cmp(length, scratch2); | 3284 __ cmp(length, scratch2); |
3199 __ b(eq, &check_zero_length); | 3285 __ beq(&check_zero_length); |
3200 __ bind(&strings_not_equal); | 3286 __ bind(&strings_not_equal); |
3201 __ mov(r0, Operand(Smi::FromInt(NOT_EQUAL))); | 3287 __ LoadSmiLiteral(r3, Smi::FromInt(NOT_EQUAL)); |
3202 __ Ret(); | 3288 __ Ret(); |
3203 | 3289 |
3204 // Check if the length is zero. | 3290 // Check if the length is zero. |
3205 Label compare_chars; | 3291 Label compare_chars; |
3206 __ bind(&check_zero_length); | 3292 __ bind(&check_zero_length); |
3207 STATIC_ASSERT(kSmiTag == 0); | 3293 STATIC_ASSERT(kSmiTag == 0); |
3208 __ cmp(length, Operand::Zero()); | 3294 __ cmpi(length, Operand::Zero()); |
3209 __ b(ne, &compare_chars); | 3295 __ bne(&compare_chars); |
3210 __ mov(r0, Operand(Smi::FromInt(EQUAL))); | 3296 __ LoadSmiLiteral(r3, Smi::FromInt(EQUAL)); |
3211 __ Ret(); | 3297 __ Ret(); |
3212 | 3298 |
3213 // Compare characters. | 3299 // Compare characters. |
3214 __ bind(&compare_chars); | 3300 __ bind(&compare_chars); |
3215 GenerateOneByteCharsCompareLoop(masm, left, right, length, scratch2, scratch3, | 3301 GenerateOneByteCharsCompareLoop(masm, left, right, length, scratch2, |
3216 &strings_not_equal); | 3302 &strings_not_equal); |
3217 | 3303 |
3218 // Characters are equal. | 3304 // Characters are equal. |
3219 __ mov(r0, Operand(Smi::FromInt(EQUAL))); | 3305 __ LoadSmiLiteral(r3, Smi::FromInt(EQUAL)); |
3220 __ Ret(); | 3306 __ Ret(); |
3221 } | 3307 } |
3222 | 3308 |
3223 | 3309 |
3224 void StringHelper::GenerateCompareFlatOneByteStrings( | 3310 void StringHelper::GenerateCompareFlatOneByteStrings( |
3225 MacroAssembler* masm, Register left, Register right, Register scratch1, | 3311 MacroAssembler* masm, Register left, Register right, Register scratch1, |
3226 Register scratch2, Register scratch3, Register scratch4) { | 3312 Register scratch2, Register scratch3) { |
3227 Label result_not_equal, compare_lengths; | 3313 Label skip, result_not_equal, compare_lengths; |
3228 // Find minimum length and length difference. | 3314 // Find minimum length and length difference. |
3229 __ ldr(scratch1, FieldMemOperand(left, String::kLengthOffset)); | 3315 __ LoadP(scratch1, FieldMemOperand(left, String::kLengthOffset)); |
3230 __ ldr(scratch2, FieldMemOperand(right, String::kLengthOffset)); | 3316 __ LoadP(scratch2, FieldMemOperand(right, String::kLengthOffset)); |
3231 __ sub(scratch3, scratch1, Operand(scratch2), SetCC); | 3317 __ sub(scratch3, scratch1, scratch2, LeaveOE, SetRC); |
3232 Register length_delta = scratch3; | 3318 Register length_delta = scratch3; |
3233 __ mov(scratch1, scratch2, LeaveCC, gt); | 3319 __ ble(&skip, cr0); |
| 3320 __ mr(scratch1, scratch2); |
| 3321 __ bind(&skip); |
3234 Register min_length = scratch1; | 3322 Register min_length = scratch1; |
3235 STATIC_ASSERT(kSmiTag == 0); | 3323 STATIC_ASSERT(kSmiTag == 0); |
3236 __ cmp(min_length, Operand::Zero()); | 3324 __ cmpi(min_length, Operand::Zero()); |
3237 __ b(eq, &compare_lengths); | 3325 __ beq(&compare_lengths); |
3238 | 3326 |
3239 // Compare loop. | 3327 // Compare loop. |
3240 GenerateOneByteCharsCompareLoop(masm, left, right, min_length, scratch2, | 3328 GenerateOneByteCharsCompareLoop(masm, left, right, min_length, scratch2, |
3241 scratch4, &result_not_equal); | 3329 &result_not_equal); |
3242 | 3330 |
3243 // Compare lengths - strings up to min-length are equal. | 3331 // Compare lengths - strings up to min-length are equal. |
3244 __ bind(&compare_lengths); | 3332 __ bind(&compare_lengths); |
3245 DCHECK(Smi::FromInt(EQUAL) == static_cast<Smi*>(0)); | 3333 DCHECK(Smi::FromInt(EQUAL) == static_cast<Smi*>(0)); |
3246 // Use length_delta as result if it's zero. | 3334 // Use length_delta as result if it's zero. |
3247 __ mov(r0, Operand(length_delta), SetCC); | 3335 __ mr(r3, length_delta); |
| 3336 __ cmpi(r3, Operand::Zero()); |
3248 __ bind(&result_not_equal); | 3337 __ bind(&result_not_equal); |
3249 // Conditionally update the result based either on length_delta or | 3338 // Conditionally update the result based either on length_delta or |
3250 // the last comparion performed in the loop above. | 3339 // the last comparion performed in the loop above. |
3251 __ mov(r0, Operand(Smi::FromInt(GREATER)), LeaveCC, gt); | 3340 Label less_equal, equal; |
3252 __ mov(r0, Operand(Smi::FromInt(LESS)), LeaveCC, lt); | 3341 __ ble(&less_equal); |
| 3342 __ LoadSmiLiteral(r3, Smi::FromInt(GREATER)); |
| 3343 __ Ret(); |
| 3344 __ bind(&less_equal); |
| 3345 __ beq(&equal); |
| 3346 __ LoadSmiLiteral(r3, Smi::FromInt(LESS)); |
| 3347 __ bind(&equal); |
3253 __ Ret(); | 3348 __ Ret(); |
3254 } | 3349 } |
3255 | 3350 |
3256 | 3351 |
3257 void StringHelper::GenerateOneByteCharsCompareLoop( | 3352 void StringHelper::GenerateOneByteCharsCompareLoop( |
3258 MacroAssembler* masm, Register left, Register right, Register length, | 3353 MacroAssembler* masm, Register left, Register right, Register length, |
3259 Register scratch1, Register scratch2, Label* chars_not_equal) { | 3354 Register scratch1, Label* chars_not_equal) { |
3260 // Change index to run from -length to -1 by adding length to string | 3355 // Change index to run from -length to -1 by adding length to string |
3261 // start. This means that loop ends when index reaches zero, which | 3356 // start. This means that loop ends when index reaches zero, which |
3262 // doesn't need an additional compare. | 3357 // doesn't need an additional compare. |
3263 __ SmiUntag(length); | 3358 __ SmiUntag(length); |
3264 __ add(scratch1, length, | 3359 __ addi(scratch1, length, |
3265 Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); | 3360 Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); |
3266 __ add(left, left, Operand(scratch1)); | 3361 __ add(left, left, scratch1); |
3267 __ add(right, right, Operand(scratch1)); | 3362 __ add(right, right, scratch1); |
3268 __ rsb(length, length, Operand::Zero()); | 3363 __ subfic(length, length, Operand::Zero()); |
3269 Register index = length; // index = -length; | 3364 Register index = length; // index = -length; |
3270 | 3365 |
3271 // Compare loop. | 3366 // Compare loop. |
3272 Label loop; | 3367 Label loop; |
3273 __ bind(&loop); | 3368 __ bind(&loop); |
3274 __ ldrb(scratch1, MemOperand(left, index)); | 3369 __ lbzx(scratch1, MemOperand(left, index)); |
3275 __ ldrb(scratch2, MemOperand(right, index)); | 3370 __ lbzx(r0, MemOperand(right, index)); |
3276 __ cmp(scratch1, scratch2); | 3371 __ cmp(scratch1, r0); |
3277 __ b(ne, chars_not_equal); | 3372 __ bne(chars_not_equal); |
3278 __ add(index, index, Operand(1), SetCC); | 3373 __ addi(index, index, Operand(1)); |
3279 __ b(ne, &loop); | 3374 __ cmpi(index, Operand::Zero()); |
| 3375 __ bne(&loop); |
3280 } | 3376 } |
3281 | 3377 |
3282 | 3378 |
3283 void StringCompareStub::Generate(MacroAssembler* masm) { | 3379 void StringCompareStub::Generate(MacroAssembler* masm) { |
3284 Label runtime; | 3380 Label runtime; |
3285 | 3381 |
3286 Counters* counters = isolate()->counters(); | 3382 Counters* counters = isolate()->counters(); |
3287 | 3383 |
3288 // Stack frame on entry. | 3384 // Stack frame on entry. |
3289 // sp[0]: right string | 3385 // sp[0]: right string |
3290 // sp[4]: left string | 3386 // sp[4]: left string |
3291 __ Ldrd(r0 , r1, MemOperand(sp)); // Load right in r0, left in r1. | 3387 __ LoadP(r3, MemOperand(sp)); // Load right in r3, left in r4. |
| 3388 __ LoadP(r4, MemOperand(sp, kPointerSize)); |
3292 | 3389 |
3293 Label not_same; | 3390 Label not_same; |
3294 __ cmp(r0, r1); | 3391 __ cmp(r3, r4); |
3295 __ b(ne, ¬_same); | 3392 __ bne(¬_same); |
3296 STATIC_ASSERT(EQUAL == 0); | 3393 STATIC_ASSERT(EQUAL == 0); |
3297 STATIC_ASSERT(kSmiTag == 0); | 3394 STATIC_ASSERT(kSmiTag == 0); |
3298 __ mov(r0, Operand(Smi::FromInt(EQUAL))); | 3395 __ LoadSmiLiteral(r3, Smi::FromInt(EQUAL)); |
3299 __ IncrementCounter(counters->string_compare_native(), 1, r1, r2); | 3396 __ IncrementCounter(counters->string_compare_native(), 1, r4, r5); |
3300 __ add(sp, sp, Operand(2 * kPointerSize)); | 3397 __ addi(sp, sp, Operand(2 * kPointerSize)); |
3301 __ Ret(); | 3398 __ Ret(); |
3302 | 3399 |
3303 __ bind(¬_same); | 3400 __ bind(¬_same); |
3304 | 3401 |
3305 // Check that both objects are sequential one-byte strings. | 3402 // Check that both objects are sequential one-byte strings. |
3306 __ JumpIfNotBothSequentialOneByteStrings(r1, r0, r2, r3, &runtime); | 3403 __ JumpIfNotBothSequentialOneByteStrings(r4, r3, r5, r6, &runtime); |
3307 | 3404 |
3308 // Compare flat one-byte strings natively. Remove arguments from stack first. | 3405 // Compare flat one-byte strings natively. Remove arguments from stack first. |
3309 __ IncrementCounter(counters->string_compare_native(), 1, r2, r3); | 3406 __ IncrementCounter(counters->string_compare_native(), 1, r5, r6); |
3310 __ add(sp, sp, Operand(2 * kPointerSize)); | 3407 __ addi(sp, sp, Operand(2 * kPointerSize)); |
3311 StringHelper::GenerateCompareFlatOneByteStrings(masm, r1, r0, r2, r3, r4, r5); | 3408 StringHelper::GenerateCompareFlatOneByteStrings(masm, r4, r3, r5, r6, r7); |
3312 | 3409 |
3313 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) | 3410 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) |
3314 // tagged as a small integer. | 3411 // tagged as a small integer. |
3315 __ bind(&runtime); | 3412 __ bind(&runtime); |
3316 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); | 3413 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); |
3317 } | 3414 } |
3318 | 3415 |
3319 | 3416 |
3320 void BinaryOpICWithAllocationSiteStub::Generate(MacroAssembler* masm) { | 3417 void BinaryOpICWithAllocationSiteStub::Generate(MacroAssembler* masm) { |
3321 // ----------- S t a t e ------------- | 3418 // ----------- S t a t e ------------- |
3322 // -- r1 : left | 3419 // -- r4 : left |
3323 // -- r0 : right | 3420 // -- r3 : right |
3324 // -- lr : return address | 3421 // -- lr : return address |
3325 // ----------------------------------- | 3422 // ----------------------------------- |
3326 | 3423 |
3327 // Load r2 with the allocation site. We stick an undefined dummy value here | 3424 // Load r5 with the allocation site. We stick an undefined dummy value here |
3328 // and replace it with the real allocation site later when we instantiate this | 3425 // and replace it with the real allocation site later when we instantiate this |
3329 // stub in BinaryOpICWithAllocationSiteStub::GetCodeCopyFromTemplate(). | 3426 // stub in BinaryOpICWithAllocationSiteStub::GetCodeCopyFromTemplate(). |
3330 __ Move(r2, handle(isolate()->heap()->undefined_value())); | 3427 __ Move(r5, handle(isolate()->heap()->undefined_value())); |
3331 | 3428 |
3332 // Make sure that we actually patched the allocation site. | 3429 // Make sure that we actually patched the allocation site. |
3333 if (FLAG_debug_code) { | 3430 if (FLAG_debug_code) { |
3334 __ tst(r2, Operand(kSmiTagMask)); | 3431 __ TestIfSmi(r5, r0); |
3335 __ Assert(ne, kExpectedAllocationSite); | 3432 __ Assert(ne, kExpectedAllocationSite, cr0); |
3336 __ push(r2); | 3433 __ push(r5); |
3337 __ ldr(r2, FieldMemOperand(r2, HeapObject::kMapOffset)); | 3434 __ LoadP(r5, FieldMemOperand(r5, HeapObject::kMapOffset)); |
3338 __ LoadRoot(ip, Heap::kAllocationSiteMapRootIndex); | 3435 __ LoadRoot(ip, Heap::kAllocationSiteMapRootIndex); |
3339 __ cmp(r2, ip); | 3436 __ cmp(r5, ip); |
3340 __ pop(r2); | 3437 __ pop(r5); |
3341 __ Assert(eq, kExpectedAllocationSite); | 3438 __ Assert(eq, kExpectedAllocationSite); |
3342 } | 3439 } |
3343 | 3440 |
3344 // Tail call into the stub that handles binary operations with allocation | 3441 // Tail call into the stub that handles binary operations with allocation |
3345 // sites. | 3442 // sites. |
3346 BinaryOpWithAllocationSiteStub stub(isolate(), state()); | 3443 BinaryOpWithAllocationSiteStub stub(isolate(), state()); |
3347 __ TailCallStub(&stub); | 3444 __ TailCallStub(&stub); |
3348 } | 3445 } |
3349 | 3446 |
3350 | 3447 |
3351 void CompareICStub::GenerateSmis(MacroAssembler* masm) { | 3448 void CompareICStub::GenerateSmis(MacroAssembler* masm) { |
3352 DCHECK(state() == CompareICState::SMI); | 3449 DCHECK(state() == CompareICState::SMI); |
3353 Label miss; | 3450 Label miss; |
3354 __ orr(r2, r1, r0); | 3451 __ orx(r5, r4, r3); |
3355 __ JumpIfNotSmi(r2, &miss); | 3452 __ JumpIfNotSmi(r5, &miss); |
3356 | 3453 |
3357 if (GetCondition() == eq) { | 3454 if (GetCondition() == eq) { |
3358 // For equality we do not care about the sign of the result. | 3455 // For equality we do not care about the sign of the result. |
3359 __ sub(r0, r0, r1, SetCC); | 3456 // __ sub(r3, r3, r4, SetCC); |
| 3457 __ sub(r3, r3, r4); |
3360 } else { | 3458 } else { |
3361 // Untag before subtracting to avoid handling overflow. | 3459 // Untag before subtracting to avoid handling overflow. |
3362 __ SmiUntag(r1); | 3460 __ SmiUntag(r4); |
3363 __ sub(r0, r1, Operand::SmiUntag(r0)); | 3461 __ SmiUntag(r3); |
| 3462 __ sub(r3, r4, r3); |
3364 } | 3463 } |
3365 __ Ret(); | 3464 __ Ret(); |
3366 | 3465 |
3367 __ bind(&miss); | 3466 __ bind(&miss); |
3368 GenerateMiss(masm); | 3467 GenerateMiss(masm); |
3369 } | 3468 } |
3370 | 3469 |
3371 | 3470 |
3372 void CompareICStub::GenerateNumbers(MacroAssembler* masm) { | 3471 void CompareICStub::GenerateNumbers(MacroAssembler* masm) { |
3373 DCHECK(state() == CompareICState::NUMBER); | 3472 DCHECK(state() == CompareICState::NUMBER); |
3374 | 3473 |
3375 Label generic_stub; | 3474 Label generic_stub; |
3376 Label unordered, maybe_undefined1, maybe_undefined2; | 3475 Label unordered, maybe_undefined1, maybe_undefined2; |
3377 Label miss; | 3476 Label miss; |
| 3477 Label equal, less_than; |
3378 | 3478 |
3379 if (left() == CompareICState::SMI) { | 3479 if (left() == CompareICState::SMI) { |
3380 __ JumpIfNotSmi(r1, &miss); | 3480 __ JumpIfNotSmi(r4, &miss); |
3381 } | 3481 } |
3382 if (right() == CompareICState::SMI) { | 3482 if (right() == CompareICState::SMI) { |
3383 __ JumpIfNotSmi(r0, &miss); | 3483 __ JumpIfNotSmi(r3, &miss); |
3384 } | 3484 } |
3385 | 3485 |
3386 // Inlining the double comparison and falling back to the general compare | 3486 // Inlining the double comparison and falling back to the general compare |
3387 // stub if NaN is involved. | 3487 // stub if NaN is involved. |
3388 // Load left and right operand. | 3488 // Load left and right operand. |
3389 Label done, left, left_smi, right_smi; | 3489 Label done, left, left_smi, right_smi; |
3390 __ JumpIfSmi(r0, &right_smi); | 3490 __ JumpIfSmi(r3, &right_smi); |
3391 __ CheckMap(r0, r2, Heap::kHeapNumberMapRootIndex, &maybe_undefined1, | 3491 __ CheckMap(r3, r5, Heap::kHeapNumberMapRootIndex, &maybe_undefined1, |
3392 DONT_DO_SMI_CHECK); | 3492 DONT_DO_SMI_CHECK); |
3393 __ sub(r2, r0, Operand(kHeapObjectTag)); | 3493 __ lfd(d1, FieldMemOperand(r3, HeapNumber::kValueOffset)); |
3394 __ vldr(d1, r2, HeapNumber::kValueOffset); | |
3395 __ b(&left); | 3494 __ b(&left); |
3396 __ bind(&right_smi); | 3495 __ bind(&right_smi); |
3397 __ SmiToDouble(d1, r0); | 3496 __ SmiToDouble(d1, r3); |
3398 | 3497 |
3399 __ bind(&left); | 3498 __ bind(&left); |
3400 __ JumpIfSmi(r1, &left_smi); | 3499 __ JumpIfSmi(r4, &left_smi); |
3401 __ CheckMap(r1, r2, Heap::kHeapNumberMapRootIndex, &maybe_undefined2, | 3500 __ CheckMap(r4, r5, Heap::kHeapNumberMapRootIndex, &maybe_undefined2, |
3402 DONT_DO_SMI_CHECK); | 3501 DONT_DO_SMI_CHECK); |
3403 __ sub(r2, r1, Operand(kHeapObjectTag)); | 3502 __ lfd(d0, FieldMemOperand(r4, HeapNumber::kValueOffset)); |
3404 __ vldr(d0, r2, HeapNumber::kValueOffset); | |
3405 __ b(&done); | 3503 __ b(&done); |
3406 __ bind(&left_smi); | 3504 __ bind(&left_smi); |
3407 __ SmiToDouble(d0, r1); | 3505 __ SmiToDouble(d0, r4); |
3408 | 3506 |
3409 __ bind(&done); | 3507 __ bind(&done); |
3410 // Compare operands. | 3508 |
3411 __ VFPCompareAndSetFlags(d0, d1); | 3509 // Compare operands |
| 3510 __ fcmpu(d0, d1); |
3412 | 3511 |
3413 // Don't base result on status bits when a NaN is involved. | 3512 // Don't base result on status bits when a NaN is involved. |
3414 __ b(vs, &unordered); | 3513 __ bunordered(&unordered); |
3415 | 3514 |
3416 // Return a result of -1, 0, or 1, based on status bits. | 3515 // Return a result of -1, 0, or 1, based on status bits. |
3417 __ mov(r0, Operand(EQUAL), LeaveCC, eq); | 3516 __ beq(&equal); |
3418 __ mov(r0, Operand(LESS), LeaveCC, lt); | 3517 __ blt(&less_than); |
3419 __ mov(r0, Operand(GREATER), LeaveCC, gt); | 3518 // assume greater than |
| 3519 __ li(r3, Operand(GREATER)); |
| 3520 __ Ret(); |
| 3521 __ bind(&equal); |
| 3522 __ li(r3, Operand(EQUAL)); |
| 3523 __ Ret(); |
| 3524 __ bind(&less_than); |
| 3525 __ li(r3, Operand(LESS)); |
3420 __ Ret(); | 3526 __ Ret(); |
3421 | 3527 |
3422 __ bind(&unordered); | 3528 __ bind(&unordered); |
3423 __ bind(&generic_stub); | 3529 __ bind(&generic_stub); |
3424 CompareICStub stub(isolate(), op(), CompareICState::GENERIC, | 3530 CompareICStub stub(isolate(), op(), CompareICState::GENERIC, |
3425 CompareICState::GENERIC, CompareICState::GENERIC); | 3531 CompareICState::GENERIC, CompareICState::GENERIC); |
3426 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); | 3532 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); |
3427 | 3533 |
3428 __ bind(&maybe_undefined1); | 3534 __ bind(&maybe_undefined1); |
3429 if (Token::IsOrderedRelationalCompareOp(op())) { | 3535 if (Token::IsOrderedRelationalCompareOp(op())) { |
3430 __ CompareRoot(r0, Heap::kUndefinedValueRootIndex); | 3536 __ CompareRoot(r3, Heap::kUndefinedValueRootIndex); |
3431 __ b(ne, &miss); | 3537 __ bne(&miss); |
3432 __ JumpIfSmi(r1, &unordered); | 3538 __ JumpIfSmi(r4, &unordered); |
3433 __ CompareObjectType(r1, r2, r2, HEAP_NUMBER_TYPE); | 3539 __ CompareObjectType(r4, r5, r5, HEAP_NUMBER_TYPE); |
3434 __ b(ne, &maybe_undefined2); | 3540 __ bne(&maybe_undefined2); |
3435 __ jmp(&unordered); | 3541 __ b(&unordered); |
3436 } | 3542 } |
3437 | 3543 |
3438 __ bind(&maybe_undefined2); | 3544 __ bind(&maybe_undefined2); |
3439 if (Token::IsOrderedRelationalCompareOp(op())) { | 3545 if (Token::IsOrderedRelationalCompareOp(op())) { |
3440 __ CompareRoot(r1, Heap::kUndefinedValueRootIndex); | 3546 __ CompareRoot(r4, Heap::kUndefinedValueRootIndex); |
3441 __ b(eq, &unordered); | 3547 __ beq(&unordered); |
3442 } | 3548 } |
3443 | 3549 |
3444 __ bind(&miss); | 3550 __ bind(&miss); |
3445 GenerateMiss(masm); | 3551 GenerateMiss(masm); |
3446 } | 3552 } |
3447 | 3553 |
3448 | 3554 |
3449 void CompareICStub::GenerateInternalizedStrings(MacroAssembler* masm) { | 3555 void CompareICStub::GenerateInternalizedStrings(MacroAssembler* masm) { |
3450 DCHECK(state() == CompareICState::INTERNALIZED_STRING); | 3556 DCHECK(state() == CompareICState::INTERNALIZED_STRING); |
3451 Label miss; | 3557 Label miss, not_equal; |
3452 | 3558 |
3453 // Registers containing left and right operands respectively. | 3559 // Registers containing left and right operands respectively. |
3454 Register left = r1; | 3560 Register left = r4; |
3455 Register right = r0; | 3561 Register right = r3; |
3456 Register tmp1 = r2; | 3562 Register tmp1 = r5; |
3457 Register tmp2 = r3; | 3563 Register tmp2 = r6; |
3458 | 3564 |
3459 // Check that both operands are heap objects. | 3565 // Check that both operands are heap objects. |
3460 __ JumpIfEitherSmi(left, right, &miss); | 3566 __ JumpIfEitherSmi(left, right, &miss); |
3461 | 3567 |
3462 // Check that both operands are internalized strings. | 3568 // Check that both operands are symbols. |
3463 __ ldr(tmp1, FieldMemOperand(left, HeapObject::kMapOffset)); | 3569 __ LoadP(tmp1, FieldMemOperand(left, HeapObject::kMapOffset)); |
3464 __ ldr(tmp2, FieldMemOperand(right, HeapObject::kMapOffset)); | 3570 __ LoadP(tmp2, FieldMemOperand(right, HeapObject::kMapOffset)); |
3465 __ ldrb(tmp1, FieldMemOperand(tmp1, Map::kInstanceTypeOffset)); | 3571 __ lbz(tmp1, FieldMemOperand(tmp1, Map::kInstanceTypeOffset)); |
3466 __ ldrb(tmp2, FieldMemOperand(tmp2, Map::kInstanceTypeOffset)); | 3572 __ lbz(tmp2, FieldMemOperand(tmp2, Map::kInstanceTypeOffset)); |
3467 STATIC_ASSERT(kInternalizedTag == 0 && kStringTag == 0); | 3573 STATIC_ASSERT(kInternalizedTag == 0 && kStringTag == 0); |
3468 __ orr(tmp1, tmp1, Operand(tmp2)); | 3574 __ orx(tmp1, tmp1, tmp2); |
3469 __ tst(tmp1, Operand(kIsNotStringMask | kIsNotInternalizedMask)); | 3575 __ andi(r0, tmp1, Operand(kIsNotStringMask | kIsNotInternalizedMask)); |
3470 __ b(ne, &miss); | 3576 __ bne(&miss, cr0); |
3471 | 3577 |
3472 // Internalized strings are compared by identity. | 3578 // Internalized strings are compared by identity. |
3473 __ cmp(left, right); | 3579 __ cmp(left, right); |
3474 // Make sure r0 is non-zero. At this point input operands are | 3580 __ bne(¬_equal); |
| 3581 // Make sure r3 is non-zero. At this point input operands are |
3475 // guaranteed to be non-zero. | 3582 // guaranteed to be non-zero. |
3476 DCHECK(right.is(r0)); | 3583 DCHECK(right.is(r3)); |
3477 STATIC_ASSERT(EQUAL == 0); | 3584 STATIC_ASSERT(EQUAL == 0); |
3478 STATIC_ASSERT(kSmiTag == 0); | 3585 STATIC_ASSERT(kSmiTag == 0); |
3479 __ mov(r0, Operand(Smi::FromInt(EQUAL)), LeaveCC, eq); | 3586 __ LoadSmiLiteral(r3, Smi::FromInt(EQUAL)); |
| 3587 __ bind(¬_equal); |
3480 __ Ret(); | 3588 __ Ret(); |
3481 | 3589 |
3482 __ bind(&miss); | 3590 __ bind(&miss); |
3483 GenerateMiss(masm); | 3591 GenerateMiss(masm); |
3484 } | 3592 } |
3485 | 3593 |
3486 | 3594 |
3487 void CompareICStub::GenerateUniqueNames(MacroAssembler* masm) { | 3595 void CompareICStub::GenerateUniqueNames(MacroAssembler* masm) { |
3488 DCHECK(state() == CompareICState::UNIQUE_NAME); | 3596 DCHECK(state() == CompareICState::UNIQUE_NAME); |
3489 DCHECK(GetCondition() == eq); | 3597 DCHECK(GetCondition() == eq); |
3490 Label miss; | 3598 Label miss; |
3491 | 3599 |
3492 // Registers containing left and right operands respectively. | 3600 // Registers containing left and right operands respectively. |
3493 Register left = r1; | 3601 Register left = r4; |
3494 Register right = r0; | 3602 Register right = r3; |
3495 Register tmp1 = r2; | 3603 Register tmp1 = r5; |
3496 Register tmp2 = r3; | 3604 Register tmp2 = r6; |
3497 | 3605 |
3498 // Check that both operands are heap objects. | 3606 // Check that both operands are heap objects. |
3499 __ JumpIfEitherSmi(left, right, &miss); | 3607 __ JumpIfEitherSmi(left, right, &miss); |
3500 | 3608 |
3501 // Check that both operands are unique names. This leaves the instance | 3609 // Check that both operands are unique names. This leaves the instance |
3502 // types loaded in tmp1 and tmp2. | 3610 // types loaded in tmp1 and tmp2. |
3503 __ ldr(tmp1, FieldMemOperand(left, HeapObject::kMapOffset)); | 3611 __ LoadP(tmp1, FieldMemOperand(left, HeapObject::kMapOffset)); |
3504 __ ldr(tmp2, FieldMemOperand(right, HeapObject::kMapOffset)); | 3612 __ LoadP(tmp2, FieldMemOperand(right, HeapObject::kMapOffset)); |
3505 __ ldrb(tmp1, FieldMemOperand(tmp1, Map::kInstanceTypeOffset)); | 3613 __ lbz(tmp1, FieldMemOperand(tmp1, Map::kInstanceTypeOffset)); |
3506 __ ldrb(tmp2, FieldMemOperand(tmp2, Map::kInstanceTypeOffset)); | 3614 __ lbz(tmp2, FieldMemOperand(tmp2, Map::kInstanceTypeOffset)); |
3507 | 3615 |
3508 __ JumpIfNotUniqueNameInstanceType(tmp1, &miss); | 3616 __ JumpIfNotUniqueNameInstanceType(tmp1, &miss); |
3509 __ JumpIfNotUniqueNameInstanceType(tmp2, &miss); | 3617 __ JumpIfNotUniqueNameInstanceType(tmp2, &miss); |
3510 | 3618 |
3511 // Unique names are compared by identity. | 3619 // Unique names are compared by identity. |
3512 __ cmp(left, right); | 3620 __ cmp(left, right); |
3513 // Make sure r0 is non-zero. At this point input operands are | 3621 __ bne(&miss); |
| 3622 // Make sure r3 is non-zero. At this point input operands are |
3514 // guaranteed to be non-zero. | 3623 // guaranteed to be non-zero. |
3515 DCHECK(right.is(r0)); | 3624 DCHECK(right.is(r3)); |
3516 STATIC_ASSERT(EQUAL == 0); | 3625 STATIC_ASSERT(EQUAL == 0); |
3517 STATIC_ASSERT(kSmiTag == 0); | 3626 STATIC_ASSERT(kSmiTag == 0); |
3518 __ mov(r0, Operand(Smi::FromInt(EQUAL)), LeaveCC, eq); | 3627 __ LoadSmiLiteral(r3, Smi::FromInt(EQUAL)); |
3519 __ Ret(); | 3628 __ Ret(); |
3520 | 3629 |
3521 __ bind(&miss); | 3630 __ bind(&miss); |
3522 GenerateMiss(masm); | 3631 GenerateMiss(masm); |
3523 } | 3632 } |
3524 | 3633 |
3525 | 3634 |
3526 void CompareICStub::GenerateStrings(MacroAssembler* masm) { | 3635 void CompareICStub::GenerateStrings(MacroAssembler* masm) { |
3527 DCHECK(state() == CompareICState::STRING); | 3636 DCHECK(state() == CompareICState::STRING); |
3528 Label miss; | 3637 Label miss, not_identical, is_symbol; |
3529 | 3638 |
3530 bool equality = Token::IsEqualityOp(op()); | 3639 bool equality = Token::IsEqualityOp(op()); |
3531 | 3640 |
3532 // Registers containing left and right operands respectively. | 3641 // Registers containing left and right operands respectively. |
3533 Register left = r1; | 3642 Register left = r4; |
3534 Register right = r0; | 3643 Register right = r3; |
3535 Register tmp1 = r2; | 3644 Register tmp1 = r5; |
3536 Register tmp2 = r3; | 3645 Register tmp2 = r6; |
3537 Register tmp3 = r4; | 3646 Register tmp3 = r7; |
3538 Register tmp4 = r5; | 3647 Register tmp4 = r8; |
3539 | 3648 |
3540 // Check that both operands are heap objects. | 3649 // Check that both operands are heap objects. |
3541 __ JumpIfEitherSmi(left, right, &miss); | 3650 __ JumpIfEitherSmi(left, right, &miss); |
3542 | 3651 |
3543 // Check that both operands are strings. This leaves the instance | 3652 // Check that both operands are strings. This leaves the instance |
3544 // types loaded in tmp1 and tmp2. | 3653 // types loaded in tmp1 and tmp2. |
3545 __ ldr(tmp1, FieldMemOperand(left, HeapObject::kMapOffset)); | 3654 __ LoadP(tmp1, FieldMemOperand(left, HeapObject::kMapOffset)); |
3546 __ ldr(tmp2, FieldMemOperand(right, HeapObject::kMapOffset)); | 3655 __ LoadP(tmp2, FieldMemOperand(right, HeapObject::kMapOffset)); |
3547 __ ldrb(tmp1, FieldMemOperand(tmp1, Map::kInstanceTypeOffset)); | 3656 __ lbz(tmp1, FieldMemOperand(tmp1, Map::kInstanceTypeOffset)); |
3548 __ ldrb(tmp2, FieldMemOperand(tmp2, Map::kInstanceTypeOffset)); | 3657 __ lbz(tmp2, FieldMemOperand(tmp2, Map::kInstanceTypeOffset)); |
3549 STATIC_ASSERT(kNotStringTag != 0); | 3658 STATIC_ASSERT(kNotStringTag != 0); |
3550 __ orr(tmp3, tmp1, tmp2); | 3659 __ orx(tmp3, tmp1, tmp2); |
3551 __ tst(tmp3, Operand(kIsNotStringMask)); | 3660 __ andi(r0, tmp3, Operand(kIsNotStringMask)); |
3552 __ b(ne, &miss); | 3661 __ bne(&miss, cr0); |
3553 | 3662 |
3554 // Fast check for identical strings. | 3663 // Fast check for identical strings. |
3555 __ cmp(left, right); | 3664 __ cmp(left, right); |
3556 STATIC_ASSERT(EQUAL == 0); | 3665 STATIC_ASSERT(EQUAL == 0); |
3557 STATIC_ASSERT(kSmiTag == 0); | 3666 STATIC_ASSERT(kSmiTag == 0); |
3558 __ mov(r0, Operand(Smi::FromInt(EQUAL)), LeaveCC, eq); | 3667 __ bne(¬_identical); |
3559 __ Ret(eq); | 3668 __ LoadSmiLiteral(r3, Smi::FromInt(EQUAL)); |
| 3669 __ Ret(); |
| 3670 __ bind(¬_identical); |
3560 | 3671 |
3561 // Handle not identical strings. | 3672 // Handle not identical strings. |
3562 | 3673 |
3563 // Check that both strings are internalized strings. If they are, we're done | 3674 // Check that both strings are internalized strings. If they are, we're done |
3564 // because we already know they are not identical. We know they are both | 3675 // because we already know they are not identical. We know they are both |
3565 // strings. | 3676 // strings. |
3566 if (equality) { | 3677 if (equality) { |
3567 DCHECK(GetCondition() == eq); | 3678 DCHECK(GetCondition() == eq); |
3568 STATIC_ASSERT(kInternalizedTag == 0); | 3679 STATIC_ASSERT(kInternalizedTag == 0); |
3569 __ orr(tmp3, tmp1, Operand(tmp2)); | 3680 __ orx(tmp3, tmp1, tmp2); |
3570 __ tst(tmp3, Operand(kIsNotInternalizedMask)); | 3681 __ andi(r0, tmp3, Operand(kIsNotInternalizedMask)); |
3571 // Make sure r0 is non-zero. At this point input operands are | 3682 __ bne(&is_symbol, cr0); |
| 3683 // Make sure r3 is non-zero. At this point input operands are |
3572 // guaranteed to be non-zero. | 3684 // guaranteed to be non-zero. |
3573 DCHECK(right.is(r0)); | 3685 DCHECK(right.is(r3)); |
3574 __ Ret(eq); | 3686 __ Ret(); |
| 3687 __ bind(&is_symbol); |
3575 } | 3688 } |
3576 | 3689 |
3577 // Check that both strings are sequential one-byte. | 3690 // Check that both strings are sequential one-byte. |
3578 Label runtime; | 3691 Label runtime; |
3579 __ JumpIfBothInstanceTypesAreNotSequentialOneByte(tmp1, tmp2, tmp3, tmp4, | 3692 __ JumpIfBothInstanceTypesAreNotSequentialOneByte(tmp1, tmp2, tmp3, tmp4, |
3580 &runtime); | 3693 &runtime); |
3581 | 3694 |
3582 // Compare flat one-byte strings. Returns when done. | 3695 // Compare flat one-byte strings. Returns when done. |
3583 if (equality) { | 3696 if (equality) { |
3584 StringHelper::GenerateFlatOneByteStringEquals(masm, left, right, tmp1, tmp2, | 3697 StringHelper::GenerateFlatOneByteStringEquals(masm, left, right, tmp1, |
3585 tmp3); | 3698 tmp2); |
3586 } else { | 3699 } else { |
3587 StringHelper::GenerateCompareFlatOneByteStrings(masm, left, right, tmp1, | 3700 StringHelper::GenerateCompareFlatOneByteStrings(masm, left, right, tmp1, |
3588 tmp2, tmp3, tmp4); | 3701 tmp2, tmp3); |
3589 } | 3702 } |
3590 | 3703 |
3591 // Handle more complex cases in runtime. | 3704 // Handle more complex cases in runtime. |
3592 __ bind(&runtime); | 3705 __ bind(&runtime); |
3593 __ Push(left, right); | 3706 __ Push(left, right); |
3594 if (equality) { | 3707 if (equality) { |
3595 __ TailCallRuntime(Runtime::kStringEquals, 2, 1); | 3708 __ TailCallRuntime(Runtime::kStringEquals, 2, 1); |
3596 } else { | 3709 } else { |
3597 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); | 3710 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); |
3598 } | 3711 } |
3599 | 3712 |
3600 __ bind(&miss); | 3713 __ bind(&miss); |
3601 GenerateMiss(masm); | 3714 GenerateMiss(masm); |
3602 } | 3715 } |
3603 | 3716 |
3604 | 3717 |
3605 void CompareICStub::GenerateObjects(MacroAssembler* masm) { | 3718 void CompareICStub::GenerateObjects(MacroAssembler* masm) { |
3606 DCHECK(state() == CompareICState::OBJECT); | 3719 DCHECK(state() == CompareICState::OBJECT); |
3607 Label miss; | 3720 Label miss; |
3608 __ and_(r2, r1, Operand(r0)); | 3721 __ and_(r5, r4, r3); |
3609 __ JumpIfSmi(r2, &miss); | 3722 __ JumpIfSmi(r5, &miss); |
3610 | 3723 |
3611 __ CompareObjectType(r0, r2, r2, JS_OBJECT_TYPE); | 3724 __ CompareObjectType(r3, r5, r5, JS_OBJECT_TYPE); |
3612 __ b(ne, &miss); | 3725 __ bne(&miss); |
3613 __ CompareObjectType(r1, r2, r2, JS_OBJECT_TYPE); | 3726 __ CompareObjectType(r4, r5, r5, JS_OBJECT_TYPE); |
3614 __ b(ne, &miss); | 3727 __ bne(&miss); |
3615 | 3728 |
3616 DCHECK(GetCondition() == eq); | 3729 DCHECK(GetCondition() == eq); |
3617 __ sub(r0, r0, Operand(r1)); | 3730 __ sub(r3, r3, r4); |
3618 __ Ret(); | 3731 __ Ret(); |
3619 | 3732 |
3620 __ bind(&miss); | 3733 __ bind(&miss); |
3621 GenerateMiss(masm); | 3734 GenerateMiss(masm); |
3622 } | 3735 } |
3623 | 3736 |
3624 | 3737 |
3625 void CompareICStub::GenerateKnownObjects(MacroAssembler* masm) { | 3738 void CompareICStub::GenerateKnownObjects(MacroAssembler* masm) { |
3626 Label miss; | 3739 Label miss; |
3627 __ and_(r2, r1, Operand(r0)); | 3740 __ and_(r5, r4, r3); |
3628 __ JumpIfSmi(r2, &miss); | 3741 __ JumpIfSmi(r5, &miss); |
3629 __ ldr(r2, FieldMemOperand(r0, HeapObject::kMapOffset)); | 3742 __ LoadP(r5, FieldMemOperand(r3, HeapObject::kMapOffset)); |
3630 __ ldr(r3, FieldMemOperand(r1, HeapObject::kMapOffset)); | 3743 __ LoadP(r6, FieldMemOperand(r4, HeapObject::kMapOffset)); |
3631 __ cmp(r2, Operand(known_map_)); | 3744 __ Cmpi(r5, Operand(known_map_), r0); |
3632 __ b(ne, &miss); | 3745 __ bne(&miss); |
3633 __ cmp(r3, Operand(known_map_)); | 3746 __ Cmpi(r6, Operand(known_map_), r0); |
3634 __ b(ne, &miss); | 3747 __ bne(&miss); |
3635 | 3748 |
3636 __ sub(r0, r0, Operand(r1)); | 3749 __ sub(r3, r3, r4); |
3637 __ Ret(); | 3750 __ Ret(); |
3638 | 3751 |
3639 __ bind(&miss); | 3752 __ bind(&miss); |
3640 GenerateMiss(masm); | 3753 GenerateMiss(masm); |
3641 } | 3754 } |
3642 | 3755 |
3643 | 3756 |
3644 void CompareICStub::GenerateMiss(MacroAssembler* masm) { | 3757 void CompareICStub::GenerateMiss(MacroAssembler* masm) { |
3645 { | 3758 { |
3646 // Call the runtime system in a fresh internal frame. | 3759 // Call the runtime system in a fresh internal frame. |
3647 ExternalReference miss = | 3760 ExternalReference miss = |
3648 ExternalReference(IC_Utility(IC::kCompareIC_Miss), isolate()); | 3761 ExternalReference(IC_Utility(IC::kCompareIC_Miss), isolate()); |
3649 | 3762 |
3650 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 3763 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
3651 __ Push(r1, r0); | 3764 __ Push(r4, r3); |
3652 __ Push(lr, r1, r0); | 3765 __ Push(r4, r3); |
3653 __ mov(ip, Operand(Smi::FromInt(op()))); | 3766 __ LoadSmiLiteral(r0, Smi::FromInt(op())); |
3654 __ push(ip); | 3767 __ push(r0); |
3655 __ CallExternalReference(miss, 3); | 3768 __ CallExternalReference(miss, 3); |
3656 // Compute the entry point of the rewritten stub. | 3769 // Compute the entry point of the rewritten stub. |
3657 __ add(r2, r0, Operand(Code::kHeaderSize - kHeapObjectTag)); | 3770 __ addi(r5, r3, Operand(Code::kHeaderSize - kHeapObjectTag)); |
3658 // Restore registers. | 3771 // Restore registers. |
3659 __ pop(lr); | 3772 __ Pop(r4, r3); |
3660 __ Pop(r1, r0); | |
3661 } | 3773 } |
3662 | 3774 |
3663 __ Jump(r2); | 3775 __ JumpToJSEntry(r5); |
3664 } | 3776 } |
3665 | 3777 |
3666 | 3778 |
| 3779 // This stub is paired with DirectCEntryStub::GenerateCall |
3667 void DirectCEntryStub::Generate(MacroAssembler* masm) { | 3780 void DirectCEntryStub::Generate(MacroAssembler* masm) { |
3668 // Place the return address on the stack, making the call | 3781 // Place the return address on the stack, making the call |
3669 // GC safe. The RegExp backend also relies on this. | 3782 // GC safe. The RegExp backend also relies on this. |
3670 __ str(lr, MemOperand(sp, 0)); | 3783 __ mflr(r0); |
3671 __ blx(ip); // Call the C++ function. | 3784 __ StoreP(r0, MemOperand(sp, kStackFrameExtraParamSlot * kPointerSize)); |
3672 __ VFPEnsureFPSCRState(r2); | 3785 __ Call(ip); // Call the C++ function. |
3673 __ ldr(pc, MemOperand(sp, 0)); | 3786 __ LoadP(r0, MemOperand(sp, kStackFrameExtraParamSlot * kPointerSize)); |
| 3787 __ mtlr(r0); |
| 3788 __ blr(); |
3674 } | 3789 } |
3675 | 3790 |
3676 | 3791 |
3677 void DirectCEntryStub::GenerateCall(MacroAssembler* masm, | 3792 void DirectCEntryStub::GenerateCall(MacroAssembler* masm, Register target) { |
3678 Register target) { | 3793 #if ABI_USES_FUNCTION_DESCRIPTORS && !defined(USE_SIMULATOR) |
3679 intptr_t code = | 3794 // Native AIX/PPC64 Linux use a function descriptor. |
3680 reinterpret_cast<intptr_t>(GetCode().location()); | 3795 __ LoadP(ToRegister(ABI_TOC_REGISTER), MemOperand(target, kPointerSize)); |
| 3796 __ LoadP(ip, MemOperand(target, 0)); // Instruction address |
| 3797 #else |
| 3798 // ip needs to be set for DirectCEentryStub::Generate, and also |
| 3799 // for ABI_TOC_ADDRESSABILITY_VIA_IP. |
3681 __ Move(ip, target); | 3800 __ Move(ip, target); |
3682 __ mov(lr, Operand(code, RelocInfo::CODE_TARGET)); | 3801 #endif |
3683 __ blx(lr); // Call the stub. | 3802 |
| 3803 intptr_t code = reinterpret_cast<intptr_t>(GetCode().location()); |
| 3804 __ mov(r0, Operand(code, RelocInfo::CODE_TARGET)); |
| 3805 __ Call(r0); // Call the stub. |
3684 } | 3806 } |
3685 | 3807 |
3686 | 3808 |
3687 void NameDictionaryLookupStub::GenerateNegativeLookup(MacroAssembler* masm, | 3809 void NameDictionaryLookupStub::GenerateNegativeLookup( |
3688 Label* miss, | 3810 MacroAssembler* masm, Label* miss, Label* done, Register receiver, |
3689 Label* done, | 3811 Register properties, Handle<Name> name, Register scratch0) { |
3690 Register receiver, | |
3691 Register properties, | |
3692 Handle<Name> name, | |
3693 Register scratch0) { | |
3694 DCHECK(name->IsUniqueName()); | 3812 DCHECK(name->IsUniqueName()); |
3695 // If names of slots in range from 1 to kProbes - 1 for the hash value are | 3813 // If names of slots in range from 1 to kProbes - 1 for the hash value are |
3696 // not equal to the name and kProbes-th slot is not used (its name is the | 3814 // not equal to the name and kProbes-th slot is not used (its name is the |
3697 // undefined value), it guarantees the hash table doesn't contain the | 3815 // undefined value), it guarantees the hash table doesn't contain the |
3698 // property. It's true even if some slots represent deleted properties | 3816 // property. It's true even if some slots represent deleted properties |
3699 // (their names are the hole value). | 3817 // (their names are the hole value). |
3700 for (int i = 0; i < kInlinedProbes; i++) { | 3818 for (int i = 0; i < kInlinedProbes; i++) { |
3701 // scratch0 points to properties hash. | 3819 // scratch0 points to properties hash. |
3702 // Compute the masked index: (hash + i + i * i) & mask. | 3820 // Compute the masked index: (hash + i + i * i) & mask. |
3703 Register index = scratch0; | 3821 Register index = scratch0; |
3704 // Capacity is smi 2^n. | 3822 // Capacity is smi 2^n. |
3705 __ ldr(index, FieldMemOperand(properties, kCapacityOffset)); | 3823 __ LoadP(index, FieldMemOperand(properties, kCapacityOffset)); |
3706 __ sub(index, index, Operand(1)); | 3824 __ subi(index, index, Operand(1)); |
3707 __ and_(index, index, Operand( | 3825 __ LoadSmiLiteral( |
3708 Smi::FromInt(name->Hash() + NameDictionary::GetProbeOffset(i)))); | 3826 ip, Smi::FromInt(name->Hash() + NameDictionary::GetProbeOffset(i))); |
| 3827 __ and_(index, index, ip); |
3709 | 3828 |
3710 // Scale the index by multiplying by the entry size. | 3829 // Scale the index by multiplying by the entry size. |
3711 DCHECK(NameDictionary::kEntrySize == 3); | 3830 DCHECK(NameDictionary::kEntrySize == 3); |
3712 __ add(index, index, Operand(index, LSL, 1)); // index *= 3. | 3831 __ ShiftLeftImm(ip, index, Operand(1)); |
| 3832 __ add(index, index, ip); // index *= 3. |
3713 | 3833 |
3714 Register entity_name = scratch0; | 3834 Register entity_name = scratch0; |
3715 // Having undefined at this place means the name is not contained. | 3835 // Having undefined at this place means the name is not contained. |
3716 DCHECK_EQ(kSmiTagSize, 1); | |
3717 Register tmp = properties; | 3836 Register tmp = properties; |
3718 __ add(tmp, properties, Operand(index, LSL, 1)); | 3837 __ SmiToPtrArrayOffset(ip, index); |
3719 __ ldr(entity_name, FieldMemOperand(tmp, kElementsStartOffset)); | 3838 __ add(tmp, properties, ip); |
| 3839 __ LoadP(entity_name, FieldMemOperand(tmp, kElementsStartOffset)); |
3720 | 3840 |
3721 DCHECK(!tmp.is(entity_name)); | 3841 DCHECK(!tmp.is(entity_name)); |
3722 __ LoadRoot(tmp, Heap::kUndefinedValueRootIndex); | 3842 __ LoadRoot(tmp, Heap::kUndefinedValueRootIndex); |
3723 __ cmp(entity_name, tmp); | 3843 __ cmp(entity_name, tmp); |
3724 __ b(eq, done); | 3844 __ beq(done); |
3725 | 3845 |
3726 // Load the hole ready for use below: | 3846 // Load the hole ready for use below: |
3727 __ LoadRoot(tmp, Heap::kTheHoleValueRootIndex); | 3847 __ LoadRoot(tmp, Heap::kTheHoleValueRootIndex); |
3728 | 3848 |
3729 // Stop if found the property. | 3849 // Stop if found the property. |
3730 __ cmp(entity_name, Operand(Handle<Name>(name))); | 3850 __ Cmpi(entity_name, Operand(Handle<Name>(name)), r0); |
3731 __ b(eq, miss); | 3851 __ beq(miss); |
3732 | 3852 |
3733 Label good; | 3853 Label good; |
3734 __ cmp(entity_name, tmp); | 3854 __ cmp(entity_name, tmp); |
3735 __ b(eq, &good); | 3855 __ beq(&good); |
3736 | 3856 |
3737 // Check if the entry name is not a unique name. | 3857 // Check if the entry name is not a unique name. |
3738 __ ldr(entity_name, FieldMemOperand(entity_name, HeapObject::kMapOffset)); | 3858 __ LoadP(entity_name, FieldMemOperand(entity_name, HeapObject::kMapOffset)); |
3739 __ ldrb(entity_name, | 3859 __ lbz(entity_name, FieldMemOperand(entity_name, Map::kInstanceTypeOffset)); |
3740 FieldMemOperand(entity_name, Map::kInstanceTypeOffset)); | |
3741 __ JumpIfNotUniqueNameInstanceType(entity_name, miss); | 3860 __ JumpIfNotUniqueNameInstanceType(entity_name, miss); |
3742 __ bind(&good); | 3861 __ bind(&good); |
3743 | 3862 |
3744 // Restore the properties. | 3863 // Restore the properties. |
3745 __ ldr(properties, | 3864 __ LoadP(properties, |
3746 FieldMemOperand(receiver, JSObject::kPropertiesOffset)); | 3865 FieldMemOperand(receiver, JSObject::kPropertiesOffset)); |
3747 } | 3866 } |
3748 | 3867 |
3749 const int spill_mask = | 3868 const int spill_mask = (r0.bit() | r9.bit() | r8.bit() | r7.bit() | r6.bit() | |
3750 (lr.bit() | r6.bit() | r5.bit() | r4.bit() | r3.bit() | | 3869 r5.bit() | r4.bit() | r3.bit()); |
3751 r2.bit() | r1.bit() | r0.bit()); | |
3752 | 3870 |
3753 __ stm(db_w, sp, spill_mask); | 3871 __ mflr(r0); |
3754 __ ldr(r0, FieldMemOperand(receiver, JSObject::kPropertiesOffset)); | 3872 __ MultiPush(spill_mask); |
3755 __ mov(r1, Operand(Handle<Name>(name))); | 3873 |
| 3874 __ LoadP(r3, FieldMemOperand(receiver, JSObject::kPropertiesOffset)); |
| 3875 __ mov(r4, Operand(Handle<Name>(name))); |
3756 NameDictionaryLookupStub stub(masm->isolate(), NEGATIVE_LOOKUP); | 3876 NameDictionaryLookupStub stub(masm->isolate(), NEGATIVE_LOOKUP); |
3757 __ CallStub(&stub); | 3877 __ CallStub(&stub); |
3758 __ cmp(r0, Operand::Zero()); | 3878 __ cmpi(r3, Operand::Zero()); |
3759 __ ldm(ia_w, sp, spill_mask); | |
3760 | 3879 |
3761 __ b(eq, done); | 3880 __ MultiPop(spill_mask); // MultiPop does not touch condition flags |
3762 __ b(ne, miss); | 3881 __ mtlr(r0); |
| 3882 |
| 3883 __ beq(done); |
| 3884 __ bne(miss); |
3763 } | 3885 } |
3764 | 3886 |
3765 | 3887 |
3766 // Probe the name dictionary in the |elements| register. Jump to the | 3888 // Probe the name dictionary in the |elements| register. Jump to the |
3767 // |done| label if a property with the given name is found. Jump to | 3889 // |done| label if a property with the given name is found. Jump to |
3768 // the |miss| label otherwise. | 3890 // the |miss| label otherwise. |
3769 // If lookup was successful |scratch2| will be equal to elements + 4 * index. | 3891 // If lookup was successful |scratch2| will be equal to elements + 4 * index. |
3770 void NameDictionaryLookupStub::GeneratePositiveLookup(MacroAssembler* masm, | 3892 void NameDictionaryLookupStub::GeneratePositiveLookup( |
3771 Label* miss, | 3893 MacroAssembler* masm, Label* miss, Label* done, Register elements, |
3772 Label* done, | 3894 Register name, Register scratch1, Register scratch2) { |
3773 Register elements, | |
3774 Register name, | |
3775 Register scratch1, | |
3776 Register scratch2) { | |
3777 DCHECK(!elements.is(scratch1)); | 3895 DCHECK(!elements.is(scratch1)); |
3778 DCHECK(!elements.is(scratch2)); | 3896 DCHECK(!elements.is(scratch2)); |
3779 DCHECK(!name.is(scratch1)); | 3897 DCHECK(!name.is(scratch1)); |
3780 DCHECK(!name.is(scratch2)); | 3898 DCHECK(!name.is(scratch2)); |
3781 | 3899 |
3782 __ AssertName(name); | 3900 __ AssertName(name); |
3783 | 3901 |
3784 // Compute the capacity mask. | 3902 // Compute the capacity mask. |
3785 __ ldr(scratch1, FieldMemOperand(elements, kCapacityOffset)); | 3903 __ LoadP(scratch1, FieldMemOperand(elements, kCapacityOffset)); |
3786 __ SmiUntag(scratch1); | 3904 __ SmiUntag(scratch1); // convert smi to int |
3787 __ sub(scratch1, scratch1, Operand(1)); | 3905 __ subi(scratch1, scratch1, Operand(1)); |
3788 | 3906 |
3789 // Generate an unrolled loop that performs a few probes before | 3907 // Generate an unrolled loop that performs a few probes before |
3790 // giving up. Measurements done on Gmail indicate that 2 probes | 3908 // giving up. Measurements done on Gmail indicate that 2 probes |
3791 // cover ~93% of loads from dictionaries. | 3909 // cover ~93% of loads from dictionaries. |
3792 for (int i = 0; i < kInlinedProbes; i++) { | 3910 for (int i = 0; i < kInlinedProbes; i++) { |
3793 // Compute the masked index: (hash + i + i * i) & mask. | 3911 // Compute the masked index: (hash + i + i * i) & mask. |
3794 __ ldr(scratch2, FieldMemOperand(name, Name::kHashFieldOffset)); | 3912 __ lwz(scratch2, FieldMemOperand(name, Name::kHashFieldOffset)); |
3795 if (i > 0) { | 3913 if (i > 0) { |
3796 // Add the probe offset (i + i * i) left shifted to avoid right shifting | 3914 // Add the probe offset (i + i * i) left shifted to avoid right shifting |
3797 // the hash in a separate instruction. The value hash + i + i * i is right | 3915 // the hash in a separate instruction. The value hash + i + i * i is right |
3798 // shifted in the following and instruction. | 3916 // shifted in the following and instruction. |
3799 DCHECK(NameDictionary::GetProbeOffset(i) < | 3917 DCHECK(NameDictionary::GetProbeOffset(i) < |
3800 1 << (32 - Name::kHashFieldOffset)); | 3918 1 << (32 - Name::kHashFieldOffset)); |
3801 __ add(scratch2, scratch2, Operand( | 3919 __ addi(scratch2, scratch2, |
3802 NameDictionary::GetProbeOffset(i) << Name::kHashShift)); | 3920 Operand(NameDictionary::GetProbeOffset(i) << Name::kHashShift)); |
3803 } | 3921 } |
3804 __ and_(scratch2, scratch1, Operand(scratch2, LSR, Name::kHashShift)); | 3922 __ srwi(scratch2, scratch2, Operand(Name::kHashShift)); |
| 3923 __ and_(scratch2, scratch1, scratch2); |
3805 | 3924 |
3806 // Scale the index by multiplying by the element size. | 3925 // Scale the index by multiplying by the element size. |
3807 DCHECK(NameDictionary::kEntrySize == 3); | 3926 DCHECK(NameDictionary::kEntrySize == 3); |
3808 // scratch2 = scratch2 * 3. | 3927 // scratch2 = scratch2 * 3. |
3809 __ add(scratch2, scratch2, Operand(scratch2, LSL, 1)); | 3928 __ ShiftLeftImm(ip, scratch2, Operand(1)); |
| 3929 __ add(scratch2, scratch2, ip); |
3810 | 3930 |
3811 // Check if the key is identical to the name. | 3931 // Check if the key is identical to the name. |
3812 __ add(scratch2, elements, Operand(scratch2, LSL, 2)); | 3932 __ ShiftLeftImm(ip, scratch2, Operand(kPointerSizeLog2)); |
3813 __ ldr(ip, FieldMemOperand(scratch2, kElementsStartOffset)); | 3933 __ add(scratch2, elements, ip); |
3814 __ cmp(name, Operand(ip)); | 3934 __ LoadP(ip, FieldMemOperand(scratch2, kElementsStartOffset)); |
3815 __ b(eq, done); | 3935 __ cmp(name, ip); |
| 3936 __ beq(done); |
3816 } | 3937 } |
3817 | 3938 |
3818 const int spill_mask = | 3939 const int spill_mask = (r0.bit() | r9.bit() | r8.bit() | r7.bit() | r6.bit() | |
3819 (lr.bit() | r6.bit() | r5.bit() | r4.bit() | | 3940 r5.bit() | r4.bit() | r3.bit()) & |
3820 r3.bit() | r2.bit() | r1.bit() | r0.bit()) & | 3941 ~(scratch1.bit() | scratch2.bit()); |
3821 ~(scratch1.bit() | scratch2.bit()); | |
3822 | 3942 |
3823 __ stm(db_w, sp, spill_mask); | 3943 __ mflr(r0); |
3824 if (name.is(r0)) { | 3944 __ MultiPush(spill_mask); |
3825 DCHECK(!elements.is(r1)); | 3945 if (name.is(r3)) { |
3826 __ Move(r1, name); | 3946 DCHECK(!elements.is(r4)); |
3827 __ Move(r0, elements); | 3947 __ mr(r4, name); |
| 3948 __ mr(r3, elements); |
3828 } else { | 3949 } else { |
3829 __ Move(r0, elements); | 3950 __ mr(r3, elements); |
3830 __ Move(r1, name); | 3951 __ mr(r4, name); |
3831 } | 3952 } |
3832 NameDictionaryLookupStub stub(masm->isolate(), POSITIVE_LOOKUP); | 3953 NameDictionaryLookupStub stub(masm->isolate(), POSITIVE_LOOKUP); |
3833 __ CallStub(&stub); | 3954 __ CallStub(&stub); |
3834 __ cmp(r0, Operand::Zero()); | 3955 __ cmpi(r3, Operand::Zero()); |
3835 __ mov(scratch2, Operand(r2)); | 3956 __ mr(scratch2, r5); |
3836 __ ldm(ia_w, sp, spill_mask); | 3957 __ MultiPop(spill_mask); |
| 3958 __ mtlr(r0); |
3837 | 3959 |
3838 __ b(ne, done); | 3960 __ bne(done); |
3839 __ b(eq, miss); | 3961 __ beq(miss); |
3840 } | 3962 } |
3841 | 3963 |
3842 | 3964 |
3843 void NameDictionaryLookupStub::Generate(MacroAssembler* masm) { | 3965 void NameDictionaryLookupStub::Generate(MacroAssembler* masm) { |
3844 // This stub overrides SometimesSetsUpAFrame() to return false. That means | 3966 // This stub overrides SometimesSetsUpAFrame() to return false. That means |
3845 // we cannot call anything that could cause a GC from this stub. | 3967 // we cannot call anything that could cause a GC from this stub. |
3846 // Registers: | 3968 // Registers: |
3847 // result: NameDictionary to probe | 3969 // result: NameDictionary to probe |
3848 // r1: key | 3970 // r4: key |
3849 // dictionary: NameDictionary to probe. | 3971 // dictionary: NameDictionary to probe. |
3850 // index: will hold an index of entry if lookup is successful. | 3972 // index: will hold an index of entry if lookup is successful. |
3851 // might alias with result_. | 3973 // might alias with result_. |
3852 // Returns: | 3974 // Returns: |
3853 // result_ is zero if lookup failed, non zero otherwise. | 3975 // result_ is zero if lookup failed, non zero otherwise. |
3854 | 3976 |
3855 Register result = r0; | 3977 Register result = r3; |
3856 Register dictionary = r0; | 3978 Register dictionary = r3; |
3857 Register key = r1; | 3979 Register key = r4; |
3858 Register index = r2; | 3980 Register index = r5; |
3859 Register mask = r3; | 3981 Register mask = r6; |
3860 Register hash = r4; | 3982 Register hash = r7; |
3861 Register undefined = r5; | 3983 Register undefined = r8; |
3862 Register entry_key = r6; | 3984 Register entry_key = r9; |
| 3985 Register scratch = r9; |
3863 | 3986 |
3864 Label in_dictionary, maybe_in_dictionary, not_in_dictionary; | 3987 Label in_dictionary, maybe_in_dictionary, not_in_dictionary; |
3865 | 3988 |
3866 __ ldr(mask, FieldMemOperand(dictionary, kCapacityOffset)); | 3989 __ LoadP(mask, FieldMemOperand(dictionary, kCapacityOffset)); |
3867 __ SmiUntag(mask); | 3990 __ SmiUntag(mask); |
3868 __ sub(mask, mask, Operand(1)); | 3991 __ subi(mask, mask, Operand(1)); |
3869 | 3992 |
3870 __ ldr(hash, FieldMemOperand(key, Name::kHashFieldOffset)); | 3993 __ lwz(hash, FieldMemOperand(key, Name::kHashFieldOffset)); |
3871 | 3994 |
3872 __ LoadRoot(undefined, Heap::kUndefinedValueRootIndex); | 3995 __ LoadRoot(undefined, Heap::kUndefinedValueRootIndex); |
3873 | 3996 |
3874 for (int i = kInlinedProbes; i < kTotalProbes; i++) { | 3997 for (int i = kInlinedProbes; i < kTotalProbes; i++) { |
3875 // Compute the masked index: (hash + i + i * i) & mask. | 3998 // Compute the masked index: (hash + i + i * i) & mask. |
3876 // Capacity is smi 2^n. | 3999 // Capacity is smi 2^n. |
3877 if (i > 0) { | 4000 if (i > 0) { |
3878 // Add the probe offset (i + i * i) left shifted to avoid right shifting | 4001 // Add the probe offset (i + i * i) left shifted to avoid right shifting |
3879 // the hash in a separate instruction. The value hash + i + i * i is right | 4002 // the hash in a separate instruction. The value hash + i + i * i is right |
3880 // shifted in the following and instruction. | 4003 // shifted in the following and instruction. |
3881 DCHECK(NameDictionary::GetProbeOffset(i) < | 4004 DCHECK(NameDictionary::GetProbeOffset(i) < |
3882 1 << (32 - Name::kHashFieldOffset)); | 4005 1 << (32 - Name::kHashFieldOffset)); |
3883 __ add(index, hash, Operand( | 4006 __ addi(index, hash, |
3884 NameDictionary::GetProbeOffset(i) << Name::kHashShift)); | 4007 Operand(NameDictionary::GetProbeOffset(i) << Name::kHashShift)); |
3885 } else { | 4008 } else { |
3886 __ mov(index, Operand(hash)); | 4009 __ mr(index, hash); |
3887 } | 4010 } |
3888 __ and_(index, mask, Operand(index, LSR, Name::kHashShift)); | 4011 __ srwi(r0, index, Operand(Name::kHashShift)); |
| 4012 __ and_(index, mask, r0); |
3889 | 4013 |
3890 // Scale the index by multiplying by the entry size. | 4014 // Scale the index by multiplying by the entry size. |
3891 DCHECK(NameDictionary::kEntrySize == 3); | 4015 DCHECK(NameDictionary::kEntrySize == 3); |
3892 __ add(index, index, Operand(index, LSL, 1)); // index *= 3. | 4016 __ ShiftLeftImm(scratch, index, Operand(1)); |
| 4017 __ add(index, index, scratch); // index *= 3. |
3893 | 4018 |
3894 DCHECK_EQ(kSmiTagSize, 1); | 4019 DCHECK_EQ(kSmiTagSize, 1); |
3895 __ add(index, dictionary, Operand(index, LSL, 2)); | 4020 __ ShiftLeftImm(scratch, index, Operand(kPointerSizeLog2)); |
3896 __ ldr(entry_key, FieldMemOperand(index, kElementsStartOffset)); | 4021 __ add(index, dictionary, scratch); |
| 4022 __ LoadP(entry_key, FieldMemOperand(index, kElementsStartOffset)); |
3897 | 4023 |
3898 // Having undefined at this place means the name is not contained. | 4024 // Having undefined at this place means the name is not contained. |
3899 __ cmp(entry_key, Operand(undefined)); | 4025 __ cmp(entry_key, undefined); |
3900 __ b(eq, ¬_in_dictionary); | 4026 __ beq(¬_in_dictionary); |
3901 | 4027 |
3902 // Stop if found the property. | 4028 // Stop if found the property. |
3903 __ cmp(entry_key, Operand(key)); | 4029 __ cmp(entry_key, key); |
3904 __ b(eq, &in_dictionary); | 4030 __ beq(&in_dictionary); |
3905 | 4031 |
3906 if (i != kTotalProbes - 1 && mode() == NEGATIVE_LOOKUP) { | 4032 if (i != kTotalProbes - 1 && mode() == NEGATIVE_LOOKUP) { |
3907 // Check if the entry name is not a unique name. | 4033 // Check if the entry name is not a unique name. |
3908 __ ldr(entry_key, FieldMemOperand(entry_key, HeapObject::kMapOffset)); | 4034 __ LoadP(entry_key, FieldMemOperand(entry_key, HeapObject::kMapOffset)); |
3909 __ ldrb(entry_key, | 4035 __ lbz(entry_key, FieldMemOperand(entry_key, Map::kInstanceTypeOffset)); |
3910 FieldMemOperand(entry_key, Map::kInstanceTypeOffset)); | |
3911 __ JumpIfNotUniqueNameInstanceType(entry_key, &maybe_in_dictionary); | 4036 __ JumpIfNotUniqueNameInstanceType(entry_key, &maybe_in_dictionary); |
3912 } | 4037 } |
3913 } | 4038 } |
3914 | 4039 |
3915 __ bind(&maybe_in_dictionary); | 4040 __ bind(&maybe_in_dictionary); |
3916 // If we are doing negative lookup then probing failure should be | 4041 // If we are doing negative lookup then probing failure should be |
3917 // treated as a lookup success. For positive lookup probing failure | 4042 // treated as a lookup success. For positive lookup probing failure |
3918 // should be treated as lookup failure. | 4043 // should be treated as lookup failure. |
3919 if (mode() == POSITIVE_LOOKUP) { | 4044 if (mode() == POSITIVE_LOOKUP) { |
3920 __ mov(result, Operand::Zero()); | 4045 __ li(result, Operand::Zero()); |
3921 __ Ret(); | 4046 __ Ret(); |
3922 } | 4047 } |
3923 | 4048 |
3924 __ bind(&in_dictionary); | 4049 __ bind(&in_dictionary); |
3925 __ mov(result, Operand(1)); | 4050 __ li(result, Operand(1)); |
3926 __ Ret(); | 4051 __ Ret(); |
3927 | 4052 |
3928 __ bind(¬_in_dictionary); | 4053 __ bind(¬_in_dictionary); |
3929 __ mov(result, Operand::Zero()); | 4054 __ li(result, Operand::Zero()); |
3930 __ Ret(); | 4055 __ Ret(); |
3931 } | 4056 } |
3932 | 4057 |
3933 | 4058 |
3934 void StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime( | 4059 void StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime( |
3935 Isolate* isolate) { | 4060 Isolate* isolate) { |
3936 StoreBufferOverflowStub stub1(isolate, kDontSaveFPRegs); | 4061 StoreBufferOverflowStub stub1(isolate, kDontSaveFPRegs); |
3937 stub1.GetCode(); | 4062 stub1.GetCode(); |
3938 // Hydrogen code stubs need stub2 at snapshot time. | 4063 // Hydrogen code stubs need stub2 at snapshot time. |
3939 StoreBufferOverflowStub stub2(isolate, kSaveFPRegs); | 4064 StoreBufferOverflowStub stub2(isolate, kSaveFPRegs); |
3940 stub2.GetCode(); | 4065 stub2.GetCode(); |
3941 } | 4066 } |
3942 | 4067 |
3943 | 4068 |
3944 // Takes the input in 3 registers: address_ value_ and object_. A pointer to | 4069 // Takes the input in 3 registers: address_ value_ and object_. A pointer to |
3945 // the value has just been written into the object, now this stub makes sure | 4070 // the value has just been written into the object, now this stub makes sure |
3946 // we keep the GC informed. The word in the object where the value has been | 4071 // we keep the GC informed. The word in the object where the value has been |
3947 // written is in the address register. | 4072 // written is in the address register. |
3948 void RecordWriteStub::Generate(MacroAssembler* masm) { | 4073 void RecordWriteStub::Generate(MacroAssembler* masm) { |
3949 Label skip_to_incremental_noncompacting; | 4074 Label skip_to_incremental_noncompacting; |
3950 Label skip_to_incremental_compacting; | 4075 Label skip_to_incremental_compacting; |
3951 | 4076 |
3952 // The first two instructions are generated with labels so as to get the | 4077 // The first two branch instructions are generated with labels so as to |
3953 // offset fixed up correctly by the bind(Label*) call. We patch it back and | 4078 // get the offset fixed up correctly by the bind(Label*) call. We patch |
3954 // forth between a compare instructions (a nop in this position) and the | 4079 // it back and forth between branch condition True and False |
3955 // real branch when we start and stop incremental heap marking. | 4080 // when we start and stop incremental heap marking. |
3956 // See RecordWriteStub::Patch for details. | 4081 // See RecordWriteStub::Patch for details. |
3957 { | 4082 |
3958 // Block literal pool emission, as the position of these two instructions | 4083 // Clear the bit, branch on True for NOP action initially |
3959 // is assumed by the patching code. | 4084 __ crclr(Assembler::encode_crbit(cr2, CR_LT)); |
3960 Assembler::BlockConstPoolScope block_const_pool(masm); | 4085 __ blt(&skip_to_incremental_noncompacting, cr2); |
3961 __ b(&skip_to_incremental_noncompacting); | 4086 __ blt(&skip_to_incremental_compacting, cr2); |
3962 __ b(&skip_to_incremental_compacting); | |
3963 } | |
3964 | 4087 |
3965 if (remembered_set_action() == EMIT_REMEMBERED_SET) { | 4088 if (remembered_set_action() == EMIT_REMEMBERED_SET) { |
3966 __ RememberedSetHelper(object(), address(), value(), save_fp_regs_mode(), | 4089 __ RememberedSetHelper(object(), address(), value(), save_fp_regs_mode(), |
3967 MacroAssembler::kReturnAtEnd); | 4090 MacroAssembler::kReturnAtEnd); |
3968 } | 4091 } |
3969 __ Ret(); | 4092 __ Ret(); |
3970 | 4093 |
3971 __ bind(&skip_to_incremental_noncompacting); | 4094 __ bind(&skip_to_incremental_noncompacting); |
3972 GenerateIncremental(masm, INCREMENTAL); | 4095 GenerateIncremental(masm, INCREMENTAL); |
3973 | 4096 |
3974 __ bind(&skip_to_incremental_compacting); | 4097 __ bind(&skip_to_incremental_compacting); |
3975 GenerateIncremental(masm, INCREMENTAL_COMPACTION); | 4098 GenerateIncremental(masm, INCREMENTAL_COMPACTION); |
3976 | 4099 |
3977 // Initial mode of the stub is expected to be STORE_BUFFER_ONLY. | 4100 // Initial mode of the stub is expected to be STORE_BUFFER_ONLY. |
3978 // Will be checked in IncrementalMarking::ActivateGeneratedStub. | 4101 // Will be checked in IncrementalMarking::ActivateGeneratedStub. |
3979 DCHECK(Assembler::GetBranchOffset(masm->instr_at(0)) < (1 << 12)); | 4102 // patching not required on PPC as the initial path is effectively NOP |
3980 DCHECK(Assembler::GetBranchOffset(masm->instr_at(4)) < (1 << 12)); | |
3981 PatchBranchIntoNop(masm, 0); | |
3982 PatchBranchIntoNop(masm, Assembler::kInstrSize); | |
3983 } | 4103 } |
3984 | 4104 |
3985 | 4105 |
3986 void RecordWriteStub::GenerateIncremental(MacroAssembler* masm, Mode mode) { | 4106 void RecordWriteStub::GenerateIncremental(MacroAssembler* masm, Mode mode) { |
3987 regs_.Save(masm); | 4107 regs_.Save(masm); |
3988 | 4108 |
3989 if (remembered_set_action() == EMIT_REMEMBERED_SET) { | 4109 if (remembered_set_action() == EMIT_REMEMBERED_SET) { |
3990 Label dont_need_remembered_set; | 4110 Label dont_need_remembered_set; |
3991 | 4111 |
3992 __ ldr(regs_.scratch0(), MemOperand(regs_.address(), 0)); | 4112 __ LoadP(regs_.scratch0(), MemOperand(regs_.address(), 0)); |
3993 __ JumpIfNotInNewSpace(regs_.scratch0(), // Value. | 4113 __ JumpIfNotInNewSpace(regs_.scratch0(), // Value. |
3994 regs_.scratch0(), | 4114 regs_.scratch0(), &dont_need_remembered_set); |
3995 &dont_need_remembered_set); | |
3996 | 4115 |
3997 __ CheckPageFlag(regs_.object(), | 4116 __ CheckPageFlag(regs_.object(), regs_.scratch0(), |
3998 regs_.scratch0(), | 4117 1 << MemoryChunk::SCAN_ON_SCAVENGE, ne, |
3999 1 << MemoryChunk::SCAN_ON_SCAVENGE, | |
4000 ne, | |
4001 &dont_need_remembered_set); | 4118 &dont_need_remembered_set); |
4002 | 4119 |
4003 // First notify the incremental marker if necessary, then update the | 4120 // First notify the incremental marker if necessary, then update the |
4004 // remembered set. | 4121 // remembered set. |
4005 CheckNeedsToInformIncrementalMarker( | 4122 CheckNeedsToInformIncrementalMarker( |
4006 masm, kUpdateRememberedSetOnNoNeedToInformIncrementalMarker, mode); | 4123 masm, kUpdateRememberedSetOnNoNeedToInformIncrementalMarker, mode); |
4007 InformIncrementalMarker(masm); | 4124 InformIncrementalMarker(masm); |
4008 regs_.Restore(masm); | 4125 regs_.Restore(masm); |
4009 __ RememberedSetHelper(object(), address(), value(), save_fp_regs_mode(), | 4126 __ RememberedSetHelper(object(), address(), value(), save_fp_regs_mode(), |
4010 MacroAssembler::kReturnAtEnd); | 4127 MacroAssembler::kReturnAtEnd); |
4011 | 4128 |
4012 __ bind(&dont_need_remembered_set); | 4129 __ bind(&dont_need_remembered_set); |
4013 } | 4130 } |
4014 | 4131 |
4015 CheckNeedsToInformIncrementalMarker( | 4132 CheckNeedsToInformIncrementalMarker( |
4016 masm, kReturnOnNoNeedToInformIncrementalMarker, mode); | 4133 masm, kReturnOnNoNeedToInformIncrementalMarker, mode); |
4017 InformIncrementalMarker(masm); | 4134 InformIncrementalMarker(masm); |
4018 regs_.Restore(masm); | 4135 regs_.Restore(masm); |
4019 __ Ret(); | 4136 __ Ret(); |
4020 } | 4137 } |
4021 | 4138 |
4022 | 4139 |
4023 void RecordWriteStub::InformIncrementalMarker(MacroAssembler* masm) { | 4140 void RecordWriteStub::InformIncrementalMarker(MacroAssembler* masm) { |
4024 regs_.SaveCallerSaveRegisters(masm, save_fp_regs_mode()); | 4141 regs_.SaveCallerSaveRegisters(masm, save_fp_regs_mode()); |
4025 int argument_count = 3; | 4142 int argument_count = 3; |
4026 __ PrepareCallCFunction(argument_count, regs_.scratch0()); | 4143 __ PrepareCallCFunction(argument_count, regs_.scratch0()); |
4027 Register address = | 4144 Register address = |
4028 r0.is(regs_.address()) ? regs_.scratch0() : regs_.address(); | 4145 r3.is(regs_.address()) ? regs_.scratch0() : regs_.address(); |
4029 DCHECK(!address.is(regs_.object())); | 4146 DCHECK(!address.is(regs_.object())); |
4030 DCHECK(!address.is(r0)); | 4147 DCHECK(!address.is(r3)); |
4031 __ Move(address, regs_.address()); | 4148 __ mr(address, regs_.address()); |
4032 __ Move(r0, regs_.object()); | 4149 __ mr(r3, regs_.object()); |
4033 __ Move(r1, address); | 4150 __ mr(r4, address); |
4034 __ mov(r2, Operand(ExternalReference::isolate_address(isolate()))); | 4151 __ mov(r5, Operand(ExternalReference::isolate_address(isolate()))); |
4035 | 4152 |
4036 AllowExternalCallThatCantCauseGC scope(masm); | 4153 AllowExternalCallThatCantCauseGC scope(masm); |
4037 __ CallCFunction( | 4154 __ CallCFunction( |
4038 ExternalReference::incremental_marking_record_write_function(isolate()), | 4155 ExternalReference::incremental_marking_record_write_function(isolate()), |
4039 argument_count); | 4156 argument_count); |
4040 regs_.RestoreCallerSaveRegisters(masm, save_fp_regs_mode()); | 4157 regs_.RestoreCallerSaveRegisters(masm, save_fp_regs_mode()); |
4041 } | 4158 } |
4042 | 4159 |
4043 | 4160 |
4044 void RecordWriteStub::CheckNeedsToInformIncrementalMarker( | 4161 void RecordWriteStub::CheckNeedsToInformIncrementalMarker( |
4045 MacroAssembler* masm, | 4162 MacroAssembler* masm, OnNoNeedToInformIncrementalMarker on_no_need, |
4046 OnNoNeedToInformIncrementalMarker on_no_need, | |
4047 Mode mode) { | 4163 Mode mode) { |
4048 Label on_black; | 4164 Label on_black; |
4049 Label need_incremental; | 4165 Label need_incremental; |
4050 Label need_incremental_pop_scratch; | 4166 Label need_incremental_pop_scratch; |
4051 | 4167 |
4052 __ and_(regs_.scratch0(), regs_.object(), Operand(~Page::kPageAlignmentMask)); | 4168 DCHECK((~Page::kPageAlignmentMask & 0xffff) == 0); |
4053 __ ldr(regs_.scratch1(), | 4169 __ lis(r0, Operand((~Page::kPageAlignmentMask >> 16))); |
4054 MemOperand(regs_.scratch0(), | 4170 __ and_(regs_.scratch0(), regs_.object(), r0); |
4055 MemoryChunk::kWriteBarrierCounterOffset)); | 4171 __ LoadP( |
4056 __ sub(regs_.scratch1(), regs_.scratch1(), Operand(1), SetCC); | 4172 regs_.scratch1(), |
4057 __ str(regs_.scratch1(), | 4173 MemOperand(regs_.scratch0(), MemoryChunk::kWriteBarrierCounterOffset)); |
4058 MemOperand(regs_.scratch0(), | 4174 __ subi(regs_.scratch1(), regs_.scratch1(), Operand(1)); |
4059 MemoryChunk::kWriteBarrierCounterOffset)); | 4175 __ StoreP( |
4060 __ b(mi, &need_incremental); | 4176 regs_.scratch1(), |
| 4177 MemOperand(regs_.scratch0(), MemoryChunk::kWriteBarrierCounterOffset)); |
| 4178 __ cmpi(regs_.scratch1(), Operand::Zero()); // PPC, we could do better here |
| 4179 __ blt(&need_incremental); |
4061 | 4180 |
4062 // Let's look at the color of the object: If it is not black we don't have | 4181 // Let's look at the color of the object: If it is not black we don't have |
4063 // to inform the incremental marker. | 4182 // to inform the incremental marker. |
4064 __ JumpIfBlack(regs_.object(), regs_.scratch0(), regs_.scratch1(), &on_black); | 4183 __ JumpIfBlack(regs_.object(), regs_.scratch0(), regs_.scratch1(), &on_black); |
4065 | 4184 |
4066 regs_.Restore(masm); | 4185 regs_.Restore(masm); |
4067 if (on_no_need == kUpdateRememberedSetOnNoNeedToInformIncrementalMarker) { | 4186 if (on_no_need == kUpdateRememberedSetOnNoNeedToInformIncrementalMarker) { |
4068 __ RememberedSetHelper(object(), address(), value(), save_fp_regs_mode(), | 4187 __ RememberedSetHelper(object(), address(), value(), save_fp_regs_mode(), |
4069 MacroAssembler::kReturnAtEnd); | 4188 MacroAssembler::kReturnAtEnd); |
4070 } else { | 4189 } else { |
4071 __ Ret(); | 4190 __ Ret(); |
4072 } | 4191 } |
4073 | 4192 |
4074 __ bind(&on_black); | 4193 __ bind(&on_black); |
4075 | 4194 |
4076 // Get the value from the slot. | 4195 // Get the value from the slot. |
4077 __ ldr(regs_.scratch0(), MemOperand(regs_.address(), 0)); | 4196 __ LoadP(regs_.scratch0(), MemOperand(regs_.address(), 0)); |
4078 | 4197 |
4079 if (mode == INCREMENTAL_COMPACTION) { | 4198 if (mode == INCREMENTAL_COMPACTION) { |
4080 Label ensure_not_white; | 4199 Label ensure_not_white; |
4081 | 4200 |
4082 __ CheckPageFlag(regs_.scratch0(), // Contains value. | 4201 __ CheckPageFlag(regs_.scratch0(), // Contains value. |
4083 regs_.scratch1(), // Scratch. | 4202 regs_.scratch1(), // Scratch. |
4084 MemoryChunk::kEvacuationCandidateMask, | 4203 MemoryChunk::kEvacuationCandidateMask, eq, |
4085 eq, | |
4086 &ensure_not_white); | 4204 &ensure_not_white); |
4087 | 4205 |
4088 __ CheckPageFlag(regs_.object(), | 4206 __ CheckPageFlag(regs_.object(), |
4089 regs_.scratch1(), // Scratch. | 4207 regs_.scratch1(), // Scratch. |
4090 MemoryChunk::kSkipEvacuationSlotsRecordingMask, | 4208 MemoryChunk::kSkipEvacuationSlotsRecordingMask, eq, |
4091 eq, | |
4092 &need_incremental); | 4209 &need_incremental); |
4093 | 4210 |
4094 __ bind(&ensure_not_white); | 4211 __ bind(&ensure_not_white); |
4095 } | 4212 } |
4096 | 4213 |
4097 // We need extra registers for this, so we push the object and the address | 4214 // We need extra registers for this, so we push the object and the address |
4098 // register temporarily. | 4215 // register temporarily. |
4099 __ Push(regs_.object(), regs_.address()); | 4216 __ Push(regs_.object(), regs_.address()); |
4100 __ EnsureNotWhite(regs_.scratch0(), // The value. | 4217 __ EnsureNotWhite(regs_.scratch0(), // The value. |
4101 regs_.scratch1(), // Scratch. | 4218 regs_.scratch1(), // Scratch. |
4102 regs_.object(), // Scratch. | 4219 regs_.object(), // Scratch. |
4103 regs_.address(), // Scratch. | 4220 regs_.address(), // Scratch. |
4104 &need_incremental_pop_scratch); | 4221 &need_incremental_pop_scratch); |
4105 __ Pop(regs_.object(), regs_.address()); | 4222 __ Pop(regs_.object(), regs_.address()); |
4106 | 4223 |
4107 regs_.Restore(masm); | 4224 regs_.Restore(masm); |
4108 if (on_no_need == kUpdateRememberedSetOnNoNeedToInformIncrementalMarker) { | 4225 if (on_no_need == kUpdateRememberedSetOnNoNeedToInformIncrementalMarker) { |
4109 __ RememberedSetHelper(object(), address(), value(), save_fp_regs_mode(), | 4226 __ RememberedSetHelper(object(), address(), value(), save_fp_regs_mode(), |
4110 MacroAssembler::kReturnAtEnd); | 4227 MacroAssembler::kReturnAtEnd); |
4111 } else { | 4228 } else { |
4112 __ Ret(); | 4229 __ Ret(); |
4113 } | 4230 } |
4114 | 4231 |
4115 __ bind(&need_incremental_pop_scratch); | 4232 __ bind(&need_incremental_pop_scratch); |
4116 __ Pop(regs_.object(), regs_.address()); | 4233 __ Pop(regs_.object(), regs_.address()); |
4117 | 4234 |
4118 __ bind(&need_incremental); | 4235 __ bind(&need_incremental); |
4119 | 4236 |
4120 // Fall through when we need to inform the incremental marker. | 4237 // Fall through when we need to inform the incremental marker. |
4121 } | 4238 } |
4122 | 4239 |
4123 | 4240 |
4124 void StoreArrayLiteralElementStub::Generate(MacroAssembler* masm) { | 4241 void StoreArrayLiteralElementStub::Generate(MacroAssembler* masm) { |
4125 // ----------- S t a t e ------------- | 4242 // ----------- S t a t e ------------- |
4126 // -- r0 : element value to store | 4243 // -- r3 : element value to store |
4127 // -- r3 : element index as smi | 4244 // -- r6 : element index as smi |
4128 // -- sp[0] : array literal index in function as smi | 4245 // -- sp[0] : array literal index in function as smi |
4129 // -- sp[4] : array literal | 4246 // -- sp[4] : array literal |
4130 // clobbers r1, r2, r4 | 4247 // clobbers r3, r5, r7 |
4131 // ----------------------------------- | 4248 // ----------------------------------- |
4132 | 4249 |
4133 Label element_done; | 4250 Label element_done; |
4134 Label double_elements; | 4251 Label double_elements; |
4135 Label smi_element; | 4252 Label smi_element; |
4136 Label slow_elements; | 4253 Label slow_elements; |
4137 Label fast_elements; | 4254 Label fast_elements; |
4138 | 4255 |
4139 // Get array literal index, array literal and its map. | 4256 // Get array literal index, array literal and its map. |
4140 __ ldr(r4, MemOperand(sp, 0 * kPointerSize)); | 4257 __ LoadP(r7, MemOperand(sp, 0 * kPointerSize)); |
4141 __ ldr(r1, MemOperand(sp, 1 * kPointerSize)); | 4258 __ LoadP(r4, MemOperand(sp, 1 * kPointerSize)); |
4142 __ ldr(r2, FieldMemOperand(r1, JSObject::kMapOffset)); | 4259 __ LoadP(r5, FieldMemOperand(r4, JSObject::kMapOffset)); |
4143 | 4260 |
4144 __ CheckFastElements(r2, r5, &double_elements); | 4261 __ CheckFastElements(r5, r8, &double_elements); |
4145 // FAST_*_SMI_ELEMENTS or FAST_*_ELEMENTS | 4262 // FAST_*_SMI_ELEMENTS or FAST_*_ELEMENTS |
4146 __ JumpIfSmi(r0, &smi_element); | 4263 __ JumpIfSmi(r3, &smi_element); |
4147 __ CheckFastSmiElements(r2, r5, &fast_elements); | 4264 __ CheckFastSmiElements(r5, r8, &fast_elements); |
4148 | 4265 |
4149 // Store into the array literal requires a elements transition. Call into | 4266 // Store into the array literal requires a elements transition. Call into |
4150 // the runtime. | 4267 // the runtime. |
4151 __ bind(&slow_elements); | 4268 __ bind(&slow_elements); |
4152 // call. | 4269 // call. |
4153 __ Push(r1, r3, r0); | 4270 __ Push(r4, r6, r3); |
4154 __ ldr(r5, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 4271 __ LoadP(r8, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
4155 __ ldr(r5, FieldMemOperand(r5, JSFunction::kLiteralsOffset)); | 4272 __ LoadP(r8, FieldMemOperand(r8, JSFunction::kLiteralsOffset)); |
4156 __ Push(r5, r4); | 4273 __ Push(r8, r7); |
4157 __ TailCallRuntime(Runtime::kStoreArrayLiteralElement, 5, 1); | 4274 __ TailCallRuntime(Runtime::kStoreArrayLiteralElement, 5, 1); |
4158 | 4275 |
4159 // Array literal has ElementsKind of FAST_*_ELEMENTS and value is an object. | 4276 // Array literal has ElementsKind of FAST_*_ELEMENTS and value is an object. |
4160 __ bind(&fast_elements); | 4277 __ bind(&fast_elements); |
4161 __ ldr(r5, FieldMemOperand(r1, JSObject::kElementsOffset)); | 4278 __ LoadP(r8, FieldMemOperand(r4, JSObject::kElementsOffset)); |
4162 __ add(r6, r5, Operand::PointerOffsetFromSmiKey(r3)); | 4279 __ SmiToPtrArrayOffset(r9, r6); |
4163 __ add(r6, r6, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | 4280 __ add(r9, r8, r9); |
4164 __ str(r0, MemOperand(r6, 0)); | 4281 #if V8_TARGET_ARCH_PPC64 |
| 4282 // add due to offset alignment requirements of StorePU |
| 4283 __ addi(r9, r9, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
| 4284 __ StoreP(r3, MemOperand(r9)); |
| 4285 #else |
| 4286 __ StorePU(r3, MemOperand(r9, FixedArray::kHeaderSize - kHeapObjectTag)); |
| 4287 #endif |
4165 // Update the write barrier for the array store. | 4288 // Update the write barrier for the array store. |
4166 __ RecordWrite(r5, r6, r0, kLRHasNotBeenSaved, kDontSaveFPRegs, | 4289 __ RecordWrite(r8, r9, r3, kLRHasNotBeenSaved, kDontSaveFPRegs, |
4167 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); | 4290 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); |
4168 __ Ret(); | 4291 __ Ret(); |
4169 | 4292 |
4170 // Array literal has ElementsKind of FAST_*_SMI_ELEMENTS or FAST_*_ELEMENTS, | 4293 // Array literal has ElementsKind of FAST_*_SMI_ELEMENTS or FAST_*_ELEMENTS, |
4171 // and value is Smi. | 4294 // and value is Smi. |
4172 __ bind(&smi_element); | 4295 __ bind(&smi_element); |
4173 __ ldr(r5, FieldMemOperand(r1, JSObject::kElementsOffset)); | 4296 __ LoadP(r8, FieldMemOperand(r4, JSObject::kElementsOffset)); |
4174 __ add(r6, r5, Operand::PointerOffsetFromSmiKey(r3)); | 4297 __ SmiToPtrArrayOffset(r9, r6); |
4175 __ str(r0, FieldMemOperand(r6, FixedArray::kHeaderSize)); | 4298 __ add(r9, r8, r9); |
| 4299 __ StoreP(r3, FieldMemOperand(r9, FixedArray::kHeaderSize), r0); |
4176 __ Ret(); | 4300 __ Ret(); |
4177 | 4301 |
4178 // Array literal has ElementsKind of FAST_DOUBLE_ELEMENTS. | 4302 // Array literal has ElementsKind of FAST_DOUBLE_ELEMENTS. |
4179 __ bind(&double_elements); | 4303 __ bind(&double_elements); |
4180 __ ldr(r5, FieldMemOperand(r1, JSObject::kElementsOffset)); | 4304 __ LoadP(r8, FieldMemOperand(r4, JSObject::kElementsOffset)); |
4181 __ StoreNumberToDoubleElements(r0, r3, r5, r6, d0, &slow_elements); | 4305 __ StoreNumberToDoubleElements(r3, r6, r8, r9, d0, &slow_elements); |
4182 __ Ret(); | 4306 __ Ret(); |
4183 } | 4307 } |
4184 | 4308 |
4185 | 4309 |
4186 void StubFailureTrampolineStub::Generate(MacroAssembler* masm) { | 4310 void StubFailureTrampolineStub::Generate(MacroAssembler* masm) { |
4187 CEntryStub ces(isolate(), 1, kSaveFPRegs); | 4311 CEntryStub ces(isolate(), 1, kSaveFPRegs); |
4188 __ Call(ces.GetCode(), RelocInfo::CODE_TARGET); | 4312 __ Call(ces.GetCode(), RelocInfo::CODE_TARGET); |
4189 int parameter_count_offset = | 4313 int parameter_count_offset = |
4190 StubFailureTrampolineFrame::kCallerStackParameterCountFrameOffset; | 4314 StubFailureTrampolineFrame::kCallerStackParameterCountFrameOffset; |
4191 __ ldr(r1, MemOperand(fp, parameter_count_offset)); | 4315 __ LoadP(r4, MemOperand(fp, parameter_count_offset)); |
4192 if (function_mode() == JS_FUNCTION_STUB_MODE) { | 4316 if (function_mode() == JS_FUNCTION_STUB_MODE) { |
4193 __ add(r1, r1, Operand(1)); | 4317 __ addi(r4, r4, Operand(1)); |
4194 } | 4318 } |
4195 masm->LeaveFrame(StackFrame::STUB_FAILURE_TRAMPOLINE); | 4319 masm->LeaveFrame(StackFrame::STUB_FAILURE_TRAMPOLINE); |
4196 __ mov(r1, Operand(r1, LSL, kPointerSizeLog2)); | 4320 __ slwi(r4, r4, Operand(kPointerSizeLog2)); |
4197 __ add(sp, sp, r1); | 4321 __ add(sp, sp, r4); |
4198 __ Ret(); | 4322 __ Ret(); |
4199 } | 4323 } |
4200 | 4324 |
4201 | 4325 |
4202 void LoadICTrampolineStub::Generate(MacroAssembler* masm) { | 4326 void LoadICTrampolineStub::Generate(MacroAssembler* masm) { |
4203 EmitLoadTypeFeedbackVector(masm, VectorLoadICDescriptor::VectorRegister()); | 4327 EmitLoadTypeFeedbackVector(masm, VectorLoadICDescriptor::VectorRegister()); |
4204 VectorLoadStub stub(isolate(), state()); | 4328 VectorLoadStub stub(isolate(), state()); |
4205 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); | 4329 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); |
4206 } | 4330 } |
4207 | 4331 |
4208 | 4332 |
4209 void KeyedLoadICTrampolineStub::Generate(MacroAssembler* masm) { | 4333 void KeyedLoadICTrampolineStub::Generate(MacroAssembler* masm) { |
4210 EmitLoadTypeFeedbackVector(masm, VectorLoadICDescriptor::VectorRegister()); | 4334 EmitLoadTypeFeedbackVector(masm, VectorLoadICDescriptor::VectorRegister()); |
4211 VectorKeyedLoadStub stub(isolate()); | 4335 VectorKeyedLoadStub stub(isolate()); |
4212 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); | 4336 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); |
4213 } | 4337 } |
4214 | 4338 |
4215 | 4339 |
4216 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { | 4340 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { |
4217 if (masm->isolate()->function_entry_hook() != NULL) { | 4341 if (masm->isolate()->function_entry_hook() != NULL) { |
| 4342 PredictableCodeSizeScope predictable(masm, |
| 4343 #if V8_TARGET_ARCH_PPC64 |
| 4344 14 * Assembler::kInstrSize); |
| 4345 #else |
| 4346 11 * Assembler::kInstrSize); |
| 4347 #endif |
4218 ProfileEntryHookStub stub(masm->isolate()); | 4348 ProfileEntryHookStub stub(masm->isolate()); |
4219 int code_size = masm->CallStubSize(&stub) + 2 * Assembler::kInstrSize; | 4349 __ mflr(r0); |
4220 PredictableCodeSizeScope predictable(masm, code_size); | 4350 __ Push(r0, ip); |
4221 __ push(lr); | |
4222 __ CallStub(&stub); | 4351 __ CallStub(&stub); |
4223 __ pop(lr); | 4352 __ Pop(r0, ip); |
| 4353 __ mtlr(r0); |
4224 } | 4354 } |
4225 } | 4355 } |
4226 | 4356 |
4227 | 4357 |
4228 void ProfileEntryHookStub::Generate(MacroAssembler* masm) { | 4358 void ProfileEntryHookStub::Generate(MacroAssembler* masm) { |
4229 // The entry hook is a "push lr" instruction, followed by a call. | 4359 // The entry hook is a "push lr, ip" instruction, followed by a call. |
4230 const int32_t kReturnAddressDistanceFromFunctionStart = | 4360 const int32_t kReturnAddressDistanceFromFunctionStart = |
4231 3 * Assembler::kInstrSize; | 4361 Assembler::kCallTargetAddressOffset + 3 * Assembler::kInstrSize; |
4232 | 4362 |
4233 // This should contain all kCallerSaved registers. | 4363 // This should contain all kJSCallerSaved registers. |
4234 const RegList kSavedRegs = | 4364 const RegList kSavedRegs = kJSCallerSaved | // Caller saved registers. |
4235 1 << 0 | // r0 | 4365 r15.bit(); // Saved stack pointer. |
4236 1 << 1 | // r1 | 4366 |
4237 1 << 2 | // r2 | |
4238 1 << 3 | // r3 | |
4239 1 << 5 | // r5 | |
4240 1 << 9; // r9 | |
4241 // We also save lr, so the count here is one higher than the mask indicates. | 4367 // We also save lr, so the count here is one higher than the mask indicates. |
4242 const int32_t kNumSavedRegs = 7; | 4368 const int32_t kNumSavedRegs = kNumJSCallerSaved + 2; |
4243 | |
4244 DCHECK((kCallerSaved & kSavedRegs) == kCallerSaved); | |
4245 | 4369 |
4246 // Save all caller-save registers as this may be called from anywhere. | 4370 // Save all caller-save registers as this may be called from anywhere. |
4247 __ stm(db_w, sp, kSavedRegs | lr.bit()); | 4371 __ mflr(ip); |
| 4372 __ MultiPush(kSavedRegs | ip.bit()); |
4248 | 4373 |
4249 // Compute the function's address for the first argument. | 4374 // Compute the function's address for the first argument. |
4250 __ sub(r0, lr, Operand(kReturnAddressDistanceFromFunctionStart)); | 4375 __ subi(r3, ip, Operand(kReturnAddressDistanceFromFunctionStart)); |
4251 | 4376 |
4252 // The caller's return address is above the saved temporaries. | 4377 // The caller's return address is two slots above the saved temporaries. |
4253 // Grab that for the second argument to the hook. | 4378 // Grab that for the second argument to the hook. |
4254 __ add(r1, sp, Operand(kNumSavedRegs * kPointerSize)); | 4379 __ addi(r4, sp, Operand((kNumSavedRegs + 1) * kPointerSize)); |
4255 | 4380 |
4256 // Align the stack if necessary. | 4381 // Align the stack if necessary. |
4257 int frame_alignment = masm->ActivationFrameAlignment(); | 4382 int frame_alignment = masm->ActivationFrameAlignment(); |
4258 if (frame_alignment > kPointerSize) { | 4383 if (frame_alignment > kPointerSize) { |
4259 __ mov(r5, sp); | 4384 __ mr(r15, sp); |
4260 DCHECK(base::bits::IsPowerOfTwo32(frame_alignment)); | 4385 DCHECK(base::bits::IsPowerOfTwo32(frame_alignment)); |
4261 __ and_(sp, sp, Operand(-frame_alignment)); | 4386 __ ClearRightImm(sp, sp, Operand(WhichPowerOf2(frame_alignment))); |
4262 } | 4387 } |
4263 | 4388 |
4264 #if V8_HOST_ARCH_ARM | 4389 #if !defined(USE_SIMULATOR) |
4265 int32_t entry_hook = | 4390 uintptr_t entry_hook = |
4266 reinterpret_cast<int32_t>(isolate()->function_entry_hook()); | 4391 reinterpret_cast<uintptr_t>(isolate()->function_entry_hook()); |
4267 __ mov(ip, Operand(entry_hook)); | 4392 __ mov(ip, Operand(entry_hook)); |
| 4393 |
| 4394 #if ABI_USES_FUNCTION_DESCRIPTORS |
| 4395 // Function descriptor |
| 4396 __ LoadP(ToRegister(ABI_TOC_REGISTER), MemOperand(ip, kPointerSize)); |
| 4397 __ LoadP(ip, MemOperand(ip, 0)); |
| 4398 #elif ABI_TOC_ADDRESSABILITY_VIA_IP |
| 4399 // ip set above, so nothing to do. |
| 4400 #endif |
| 4401 |
| 4402 // PPC LINUX ABI: |
| 4403 __ li(r0, Operand::Zero()); |
| 4404 __ StorePU(r0, MemOperand(sp, -kNumRequiredStackFrameSlots * kPointerSize)); |
4268 #else | 4405 #else |
4269 // Under the simulator we need to indirect the entry hook through a | 4406 // Under the simulator we need to indirect the entry hook through a |
4270 // trampoline function at a known address. | 4407 // trampoline function at a known address. |
4271 // It additionally takes an isolate as a third parameter | 4408 // It additionally takes an isolate as a third parameter |
4272 __ mov(r2, Operand(ExternalReference::isolate_address(isolate()))); | 4409 __ mov(r5, Operand(ExternalReference::isolate_address(isolate()))); |
4273 | 4410 |
4274 ApiFunction dispatcher(FUNCTION_ADDR(EntryHookTrampoline)); | 4411 ApiFunction dispatcher(FUNCTION_ADDR(EntryHookTrampoline)); |
4275 __ mov(ip, Operand(ExternalReference(&dispatcher, | 4412 __ mov(ip, Operand(ExternalReference( |
4276 ExternalReference::BUILTIN_CALL, | 4413 &dispatcher, ExternalReference::BUILTIN_CALL, isolate()))); |
4277 isolate()))); | |
4278 #endif | 4414 #endif |
4279 __ Call(ip); | 4415 __ Call(ip); |
4280 | 4416 |
| 4417 #if !defined(USE_SIMULATOR) |
| 4418 __ addi(sp, sp, Operand(kNumRequiredStackFrameSlots * kPointerSize)); |
| 4419 #endif |
| 4420 |
4281 // Restore the stack pointer if needed. | 4421 // Restore the stack pointer if needed. |
4282 if (frame_alignment > kPointerSize) { | 4422 if (frame_alignment > kPointerSize) { |
4283 __ mov(sp, r5); | 4423 __ mr(sp, r15); |
4284 } | 4424 } |
4285 | 4425 |
4286 // Also pop pc to get Ret(0). | 4426 // Also pop lr to get Ret(0). |
4287 __ ldm(ia_w, sp, kSavedRegs | pc.bit()); | 4427 __ MultiPop(kSavedRegs | ip.bit()); |
| 4428 __ mtlr(ip); |
| 4429 __ Ret(); |
4288 } | 4430 } |
4289 | 4431 |
4290 | 4432 |
4291 template<class T> | 4433 template <class T> |
4292 static void CreateArrayDispatch(MacroAssembler* masm, | 4434 static void CreateArrayDispatch(MacroAssembler* masm, |
4293 AllocationSiteOverrideMode mode) { | 4435 AllocationSiteOverrideMode mode) { |
4294 if (mode == DISABLE_ALLOCATION_SITES) { | 4436 if (mode == DISABLE_ALLOCATION_SITES) { |
4295 T stub(masm->isolate(), GetInitialFastElementsKind(), mode); | 4437 T stub(masm->isolate(), GetInitialFastElementsKind(), mode); |
4296 __ TailCallStub(&stub); | 4438 __ TailCallStub(&stub); |
4297 } else if (mode == DONT_OVERRIDE) { | 4439 } else if (mode == DONT_OVERRIDE) { |
4298 int last_index = GetSequenceIndexFromFastElementsKind( | 4440 int last_index = |
4299 TERMINAL_FAST_ELEMENTS_KIND); | 4441 GetSequenceIndexFromFastElementsKind(TERMINAL_FAST_ELEMENTS_KIND); |
4300 for (int i = 0; i <= last_index; ++i) { | 4442 for (int i = 0; i <= last_index; ++i) { |
4301 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); | 4443 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); |
4302 __ cmp(r3, Operand(kind)); | 4444 __ Cmpi(r6, Operand(kind), r0); |
4303 T stub(masm->isolate(), kind); | 4445 T stub(masm->isolate(), kind); |
4304 __ TailCallStub(&stub, eq); | 4446 __ TailCallStub(&stub, eq); |
4305 } | 4447 } |
4306 | 4448 |
4307 // If we reached this point there is a problem. | 4449 // If we reached this point there is a problem. |
4308 __ Abort(kUnexpectedElementsKindInArrayConstructor); | 4450 __ Abort(kUnexpectedElementsKindInArrayConstructor); |
4309 } else { | 4451 } else { |
4310 UNREACHABLE(); | 4452 UNREACHABLE(); |
4311 } | 4453 } |
4312 } | 4454 } |
4313 | 4455 |
4314 | 4456 |
4315 static void CreateArrayDispatchOneArgument(MacroAssembler* masm, | 4457 static void CreateArrayDispatchOneArgument(MacroAssembler* masm, |
4316 AllocationSiteOverrideMode mode) { | 4458 AllocationSiteOverrideMode mode) { |
4317 // r2 - allocation site (if mode != DISABLE_ALLOCATION_SITES) | 4459 // r5 - allocation site (if mode != DISABLE_ALLOCATION_SITES) |
4318 // r3 - kind (if mode != DISABLE_ALLOCATION_SITES) | 4460 // r6 - kind (if mode != DISABLE_ALLOCATION_SITES) |
4319 // r0 - number of arguments | 4461 // r3 - number of arguments |
4320 // r1 - constructor? | 4462 // r4 - constructor? |
4321 // sp[0] - last argument | 4463 // sp[0] - last argument |
4322 Label normal_sequence; | 4464 Label normal_sequence; |
4323 if (mode == DONT_OVERRIDE) { | 4465 if (mode == DONT_OVERRIDE) { |
4324 DCHECK(FAST_SMI_ELEMENTS == 0); | 4466 DCHECK(FAST_SMI_ELEMENTS == 0); |
4325 DCHECK(FAST_HOLEY_SMI_ELEMENTS == 1); | 4467 DCHECK(FAST_HOLEY_SMI_ELEMENTS == 1); |
4326 DCHECK(FAST_ELEMENTS == 2); | 4468 DCHECK(FAST_ELEMENTS == 2); |
4327 DCHECK(FAST_HOLEY_ELEMENTS == 3); | 4469 DCHECK(FAST_HOLEY_ELEMENTS == 3); |
4328 DCHECK(FAST_DOUBLE_ELEMENTS == 4); | 4470 DCHECK(FAST_DOUBLE_ELEMENTS == 4); |
4329 DCHECK(FAST_HOLEY_DOUBLE_ELEMENTS == 5); | 4471 DCHECK(FAST_HOLEY_DOUBLE_ELEMENTS == 5); |
4330 | 4472 |
4331 // is the low bit set? If so, we are holey and that is good. | 4473 // is the low bit set? If so, we are holey and that is good. |
4332 __ tst(r3, Operand(1)); | 4474 __ andi(r0, r6, Operand(1)); |
4333 __ b(ne, &normal_sequence); | 4475 __ bne(&normal_sequence, cr0); |
4334 } | 4476 } |
4335 | 4477 |
4336 // look at the first argument | 4478 // look at the first argument |
4337 __ ldr(r5, MemOperand(sp, 0)); | 4479 __ LoadP(r8, MemOperand(sp, 0)); |
4338 __ cmp(r5, Operand::Zero()); | 4480 __ cmpi(r8, Operand::Zero()); |
4339 __ b(eq, &normal_sequence); | 4481 __ beq(&normal_sequence); |
4340 | 4482 |
4341 if (mode == DISABLE_ALLOCATION_SITES) { | 4483 if (mode == DISABLE_ALLOCATION_SITES) { |
4342 ElementsKind initial = GetInitialFastElementsKind(); | 4484 ElementsKind initial = GetInitialFastElementsKind(); |
4343 ElementsKind holey_initial = GetHoleyElementsKind(initial); | 4485 ElementsKind holey_initial = GetHoleyElementsKind(initial); |
4344 | 4486 |
4345 ArraySingleArgumentConstructorStub stub_holey(masm->isolate(), | 4487 ArraySingleArgumentConstructorStub stub_holey( |
4346 holey_initial, | 4488 masm->isolate(), holey_initial, DISABLE_ALLOCATION_SITES); |
4347 DISABLE_ALLOCATION_SITES); | |
4348 __ TailCallStub(&stub_holey); | 4489 __ TailCallStub(&stub_holey); |
4349 | 4490 |
4350 __ bind(&normal_sequence); | 4491 __ bind(&normal_sequence); |
4351 ArraySingleArgumentConstructorStub stub(masm->isolate(), | 4492 ArraySingleArgumentConstructorStub stub(masm->isolate(), initial, |
4352 initial, | |
4353 DISABLE_ALLOCATION_SITES); | 4493 DISABLE_ALLOCATION_SITES); |
4354 __ TailCallStub(&stub); | 4494 __ TailCallStub(&stub); |
4355 } else if (mode == DONT_OVERRIDE) { | 4495 } else if (mode == DONT_OVERRIDE) { |
4356 // We are going to create a holey array, but our kind is non-holey. | 4496 // We are going to create a holey array, but our kind is non-holey. |
4357 // Fix kind and retry (only if we have an allocation site in the slot). | 4497 // Fix kind and retry (only if we have an allocation site in the slot). |
4358 __ add(r3, r3, Operand(1)); | 4498 __ addi(r6, r6, Operand(1)); |
4359 | 4499 |
4360 if (FLAG_debug_code) { | 4500 if (FLAG_debug_code) { |
4361 __ ldr(r5, FieldMemOperand(r2, 0)); | 4501 __ LoadP(r8, FieldMemOperand(r5, 0)); |
4362 __ CompareRoot(r5, Heap::kAllocationSiteMapRootIndex); | 4502 __ CompareRoot(r8, Heap::kAllocationSiteMapRootIndex); |
4363 __ Assert(eq, kExpectedAllocationSite); | 4503 __ Assert(eq, kExpectedAllocationSite); |
4364 } | 4504 } |
4365 | 4505 |
4366 // Save the resulting elements kind in type info. We can't just store r3 | 4506 // Save the resulting elements kind in type info. We can't just store r6 |
4367 // in the AllocationSite::transition_info field because elements kind is | 4507 // in the AllocationSite::transition_info field because elements kind is |
4368 // restricted to a portion of the field...upper bits need to be left alone. | 4508 // restricted to a portion of the field...upper bits need to be left alone. |
4369 STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0); | 4509 STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0); |
4370 __ ldr(r4, FieldMemOperand(r2, AllocationSite::kTransitionInfoOffset)); | 4510 __ LoadP(r7, FieldMemOperand(r5, AllocationSite::kTransitionInfoOffset)); |
4371 __ add(r4, r4, Operand(Smi::FromInt(kFastElementsKindPackedToHoley))); | 4511 __ AddSmiLiteral(r7, r7, Smi::FromInt(kFastElementsKindPackedToHoley), r0); |
4372 __ str(r4, FieldMemOperand(r2, AllocationSite::kTransitionInfoOffset)); | 4512 __ StoreP(r7, FieldMemOperand(r5, AllocationSite::kTransitionInfoOffset), |
| 4513 r0); |
4373 | 4514 |
4374 __ bind(&normal_sequence); | 4515 __ bind(&normal_sequence); |
4375 int last_index = GetSequenceIndexFromFastElementsKind( | 4516 int last_index = |
4376 TERMINAL_FAST_ELEMENTS_KIND); | 4517 GetSequenceIndexFromFastElementsKind(TERMINAL_FAST_ELEMENTS_KIND); |
4377 for (int i = 0; i <= last_index; ++i) { | 4518 for (int i = 0; i <= last_index; ++i) { |
4378 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); | 4519 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); |
4379 __ cmp(r3, Operand(kind)); | 4520 __ mov(r0, Operand(kind)); |
| 4521 __ cmp(r6, r0); |
4380 ArraySingleArgumentConstructorStub stub(masm->isolate(), kind); | 4522 ArraySingleArgumentConstructorStub stub(masm->isolate(), kind); |
4381 __ TailCallStub(&stub, eq); | 4523 __ TailCallStub(&stub, eq); |
4382 } | 4524 } |
4383 | 4525 |
4384 // If we reached this point there is a problem. | 4526 // If we reached this point there is a problem. |
4385 __ Abort(kUnexpectedElementsKindInArrayConstructor); | 4527 __ Abort(kUnexpectedElementsKindInArrayConstructor); |
4386 } else { | 4528 } else { |
4387 UNREACHABLE(); | 4529 UNREACHABLE(); |
4388 } | 4530 } |
4389 } | 4531 } |
4390 | 4532 |
4391 | 4533 |
4392 template<class T> | 4534 template <class T> |
4393 static void ArrayConstructorStubAheadOfTimeHelper(Isolate* isolate) { | 4535 static void ArrayConstructorStubAheadOfTimeHelper(Isolate* isolate) { |
4394 int to_index = GetSequenceIndexFromFastElementsKind( | 4536 int to_index = |
4395 TERMINAL_FAST_ELEMENTS_KIND); | 4537 GetSequenceIndexFromFastElementsKind(TERMINAL_FAST_ELEMENTS_KIND); |
4396 for (int i = 0; i <= to_index; ++i) { | 4538 for (int i = 0; i <= to_index; ++i) { |
4397 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); | 4539 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); |
4398 T stub(isolate, kind); | 4540 T stub(isolate, kind); |
4399 stub.GetCode(); | 4541 stub.GetCode(); |
4400 if (AllocationSite::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE) { | 4542 if (AllocationSite::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE) { |
4401 T stub1(isolate, kind, DISABLE_ALLOCATION_SITES); | 4543 T stub1(isolate, kind, DISABLE_ALLOCATION_SITES); |
4402 stub1.GetCode(); | 4544 stub1.GetCode(); |
4403 } | 4545 } |
4404 } | 4546 } |
4405 } | 4547 } |
4406 | 4548 |
4407 | 4549 |
4408 void ArrayConstructorStubBase::GenerateStubsAheadOfTime(Isolate* isolate) { | 4550 void ArrayConstructorStubBase::GenerateStubsAheadOfTime(Isolate* isolate) { |
4409 ArrayConstructorStubAheadOfTimeHelper<ArrayNoArgumentConstructorStub>( | 4551 ArrayConstructorStubAheadOfTimeHelper<ArrayNoArgumentConstructorStub>( |
4410 isolate); | 4552 isolate); |
4411 ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>( | 4553 ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>( |
4412 isolate); | 4554 isolate); |
4413 ArrayConstructorStubAheadOfTimeHelper<ArrayNArgumentsConstructorStub>( | 4555 ArrayConstructorStubAheadOfTimeHelper<ArrayNArgumentsConstructorStub>( |
4414 isolate); | 4556 isolate); |
4415 } | 4557 } |
4416 | 4558 |
4417 | 4559 |
4418 void InternalArrayConstructorStubBase::GenerateStubsAheadOfTime( | 4560 void InternalArrayConstructorStubBase::GenerateStubsAheadOfTime( |
4419 Isolate* isolate) { | 4561 Isolate* isolate) { |
4420 ElementsKind kinds[2] = { FAST_ELEMENTS, FAST_HOLEY_ELEMENTS }; | 4562 ElementsKind kinds[2] = {FAST_ELEMENTS, FAST_HOLEY_ELEMENTS}; |
4421 for (int i = 0; i < 2; i++) { | 4563 for (int i = 0; i < 2; i++) { |
4422 // For internal arrays we only need a few things | 4564 // For internal arrays we only need a few things |
4423 InternalArrayNoArgumentConstructorStub stubh1(isolate, kinds[i]); | 4565 InternalArrayNoArgumentConstructorStub stubh1(isolate, kinds[i]); |
4424 stubh1.GetCode(); | 4566 stubh1.GetCode(); |
4425 InternalArraySingleArgumentConstructorStub stubh2(isolate, kinds[i]); | 4567 InternalArraySingleArgumentConstructorStub stubh2(isolate, kinds[i]); |
4426 stubh2.GetCode(); | 4568 stubh2.GetCode(); |
4427 InternalArrayNArgumentsConstructorStub stubh3(isolate, kinds[i]); | 4569 InternalArrayNArgumentsConstructorStub stubh3(isolate, kinds[i]); |
4428 stubh3.GetCode(); | 4570 stubh3.GetCode(); |
4429 } | 4571 } |
4430 } | 4572 } |
4431 | 4573 |
4432 | 4574 |
4433 void ArrayConstructorStub::GenerateDispatchToArrayStub( | 4575 void ArrayConstructorStub::GenerateDispatchToArrayStub( |
4434 MacroAssembler* masm, | 4576 MacroAssembler* masm, AllocationSiteOverrideMode mode) { |
4435 AllocationSiteOverrideMode mode) { | |
4436 if (argument_count() == ANY) { | 4577 if (argument_count() == ANY) { |
4437 Label not_zero_case, not_one_case; | 4578 Label not_zero_case, not_one_case; |
4438 __ tst(r0, r0); | 4579 __ cmpi(r3, Operand::Zero()); |
4439 __ b(ne, ¬_zero_case); | 4580 __ bne(¬_zero_case); |
4440 CreateArrayDispatch<ArrayNoArgumentConstructorStub>(masm, mode); | 4581 CreateArrayDispatch<ArrayNoArgumentConstructorStub>(masm, mode); |
4441 | 4582 |
4442 __ bind(¬_zero_case); | 4583 __ bind(¬_zero_case); |
4443 __ cmp(r0, Operand(1)); | 4584 __ cmpi(r3, Operand(1)); |
4444 __ b(gt, ¬_one_case); | 4585 __ bgt(¬_one_case); |
4445 CreateArrayDispatchOneArgument(masm, mode); | 4586 CreateArrayDispatchOneArgument(masm, mode); |
4446 | 4587 |
4447 __ bind(¬_one_case); | 4588 __ bind(¬_one_case); |
4448 CreateArrayDispatch<ArrayNArgumentsConstructorStub>(masm, mode); | 4589 CreateArrayDispatch<ArrayNArgumentsConstructorStub>(masm, mode); |
4449 } else if (argument_count() == NONE) { | 4590 } else if (argument_count() == NONE) { |
4450 CreateArrayDispatch<ArrayNoArgumentConstructorStub>(masm, mode); | 4591 CreateArrayDispatch<ArrayNoArgumentConstructorStub>(masm, mode); |
4451 } else if (argument_count() == ONE) { | 4592 } else if (argument_count() == ONE) { |
4452 CreateArrayDispatchOneArgument(masm, mode); | 4593 CreateArrayDispatchOneArgument(masm, mode); |
4453 } else if (argument_count() == MORE_THAN_ONE) { | 4594 } else if (argument_count() == MORE_THAN_ONE) { |
4454 CreateArrayDispatch<ArrayNArgumentsConstructorStub>(masm, mode); | 4595 CreateArrayDispatch<ArrayNArgumentsConstructorStub>(masm, mode); |
4455 } else { | 4596 } else { |
4456 UNREACHABLE(); | 4597 UNREACHABLE(); |
4457 } | 4598 } |
4458 } | 4599 } |
4459 | 4600 |
4460 | 4601 |
4461 void ArrayConstructorStub::Generate(MacroAssembler* masm) { | 4602 void ArrayConstructorStub::Generate(MacroAssembler* masm) { |
4462 // ----------- S t a t e ------------- | 4603 // ----------- S t a t e ------------- |
4463 // -- r0 : argc (only if argument_count() == ANY) | 4604 // -- r3 : argc (only if argument_count() == ANY) |
4464 // -- r1 : constructor | 4605 // -- r4 : constructor |
4465 // -- r2 : AllocationSite or undefined | 4606 // -- r5 : AllocationSite or undefined |
4466 // -- sp[0] : return address | 4607 // -- sp[0] : return address |
4467 // -- sp[4] : last argument | 4608 // -- sp[4] : last argument |
4468 // ----------------------------------- | 4609 // ----------------------------------- |
4469 | 4610 |
4470 if (FLAG_debug_code) { | 4611 if (FLAG_debug_code) { |
4471 // The array construct code is only set for the global and natives | 4612 // The array construct code is only set for the global and natives |
4472 // builtin Array functions which always have maps. | 4613 // builtin Array functions which always have maps. |
4473 | 4614 |
4474 // Initial map for the builtin Array function should be a map. | 4615 // Initial map for the builtin Array function should be a map. |
4475 __ ldr(r4, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset)); | 4616 __ LoadP(r7, FieldMemOperand(r4, JSFunction::kPrototypeOrInitialMapOffset)); |
4476 // Will both indicate a NULL and a Smi. | 4617 // Will both indicate a NULL and a Smi. |
4477 __ tst(r4, Operand(kSmiTagMask)); | 4618 __ TestIfSmi(r7, r0); |
4478 __ Assert(ne, kUnexpectedInitialMapForArrayFunction); | 4619 __ Assert(ne, kUnexpectedInitialMapForArrayFunction, cr0); |
4479 __ CompareObjectType(r4, r4, r5, MAP_TYPE); | 4620 __ CompareObjectType(r7, r7, r8, MAP_TYPE); |
4480 __ Assert(eq, kUnexpectedInitialMapForArrayFunction); | 4621 __ Assert(eq, kUnexpectedInitialMapForArrayFunction); |
4481 | 4622 |
4482 // We should either have undefined in r2 or a valid AllocationSite | 4623 // We should either have undefined in r5 or a valid AllocationSite |
4483 __ AssertUndefinedOrAllocationSite(r2, r4); | 4624 __ AssertUndefinedOrAllocationSite(r5, r7); |
4484 } | 4625 } |
4485 | 4626 |
4486 Label no_info; | 4627 Label no_info; |
4487 // Get the elements kind and case on that. | 4628 // Get the elements kind and case on that. |
4488 __ CompareRoot(r2, Heap::kUndefinedValueRootIndex); | 4629 __ CompareRoot(r5, Heap::kUndefinedValueRootIndex); |
4489 __ b(eq, &no_info); | 4630 __ beq(&no_info); |
4490 | 4631 |
4491 __ ldr(r3, FieldMemOperand(r2, AllocationSite::kTransitionInfoOffset)); | 4632 __ LoadP(r6, FieldMemOperand(r5, AllocationSite::kTransitionInfoOffset)); |
4492 __ SmiUntag(r3); | 4633 __ SmiUntag(r6); |
4493 STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0); | 4634 STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0); |
4494 __ and_(r3, r3, Operand(AllocationSite::ElementsKindBits::kMask)); | 4635 __ And(r6, r6, Operand(AllocationSite::ElementsKindBits::kMask)); |
4495 GenerateDispatchToArrayStub(masm, DONT_OVERRIDE); | 4636 GenerateDispatchToArrayStub(masm, DONT_OVERRIDE); |
4496 | 4637 |
4497 __ bind(&no_info); | 4638 __ bind(&no_info); |
4498 GenerateDispatchToArrayStub(masm, DISABLE_ALLOCATION_SITES); | 4639 GenerateDispatchToArrayStub(masm, DISABLE_ALLOCATION_SITES); |
4499 } | 4640 } |
4500 | 4641 |
4501 | 4642 |
4502 void InternalArrayConstructorStub::GenerateCase( | 4643 void InternalArrayConstructorStub::GenerateCase(MacroAssembler* masm, |
4503 MacroAssembler* masm, ElementsKind kind) { | 4644 ElementsKind kind) { |
4504 __ cmp(r0, Operand(1)); | 4645 __ cmpli(r3, Operand(1)); |
4505 | 4646 |
4506 InternalArrayNoArgumentConstructorStub stub0(isolate(), kind); | 4647 InternalArrayNoArgumentConstructorStub stub0(isolate(), kind); |
4507 __ TailCallStub(&stub0, lo); | 4648 __ TailCallStub(&stub0, lt); |
4508 | 4649 |
4509 InternalArrayNArgumentsConstructorStub stubN(isolate(), kind); | 4650 InternalArrayNArgumentsConstructorStub stubN(isolate(), kind); |
4510 __ TailCallStub(&stubN, hi); | 4651 __ TailCallStub(&stubN, gt); |
4511 | 4652 |
4512 if (IsFastPackedElementsKind(kind)) { | 4653 if (IsFastPackedElementsKind(kind)) { |
4513 // We might need to create a holey array | 4654 // We might need to create a holey array |
4514 // look at the first argument | 4655 // look at the first argument |
4515 __ ldr(r3, MemOperand(sp, 0)); | 4656 __ LoadP(r6, MemOperand(sp, 0)); |
4516 __ cmp(r3, Operand::Zero()); | 4657 __ cmpi(r6, Operand::Zero()); |
4517 | 4658 |
4518 InternalArraySingleArgumentConstructorStub | 4659 InternalArraySingleArgumentConstructorStub stub1_holey( |
4519 stub1_holey(isolate(), GetHoleyElementsKind(kind)); | 4660 isolate(), GetHoleyElementsKind(kind)); |
4520 __ TailCallStub(&stub1_holey, ne); | 4661 __ TailCallStub(&stub1_holey, ne); |
4521 } | 4662 } |
4522 | 4663 |
4523 InternalArraySingleArgumentConstructorStub stub1(isolate(), kind); | 4664 InternalArraySingleArgumentConstructorStub stub1(isolate(), kind); |
4524 __ TailCallStub(&stub1); | 4665 __ TailCallStub(&stub1); |
4525 } | 4666 } |
4526 | 4667 |
4527 | 4668 |
4528 void InternalArrayConstructorStub::Generate(MacroAssembler* masm) { | 4669 void InternalArrayConstructorStub::Generate(MacroAssembler* masm) { |
4529 // ----------- S t a t e ------------- | 4670 // ----------- S t a t e ------------- |
4530 // -- r0 : argc | 4671 // -- r3 : argc |
4531 // -- r1 : constructor | 4672 // -- r4 : constructor |
4532 // -- sp[0] : return address | 4673 // -- sp[0] : return address |
4533 // -- sp[4] : last argument | 4674 // -- sp[4] : last argument |
4534 // ----------------------------------- | 4675 // ----------------------------------- |
4535 | 4676 |
4536 if (FLAG_debug_code) { | 4677 if (FLAG_debug_code) { |
4537 // The array construct code is only set for the global and natives | 4678 // The array construct code is only set for the global and natives |
4538 // builtin Array functions which always have maps. | 4679 // builtin Array functions which always have maps. |
4539 | 4680 |
4540 // Initial map for the builtin Array function should be a map. | 4681 // Initial map for the builtin Array function should be a map. |
4541 __ ldr(r3, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset)); | 4682 __ LoadP(r6, FieldMemOperand(r4, JSFunction::kPrototypeOrInitialMapOffset)); |
4542 // Will both indicate a NULL and a Smi. | 4683 // Will both indicate a NULL and a Smi. |
4543 __ tst(r3, Operand(kSmiTagMask)); | 4684 __ TestIfSmi(r6, r0); |
4544 __ Assert(ne, kUnexpectedInitialMapForArrayFunction); | 4685 __ Assert(ne, kUnexpectedInitialMapForArrayFunction, cr0); |
4545 __ CompareObjectType(r3, r3, r4, MAP_TYPE); | 4686 __ CompareObjectType(r6, r6, r7, MAP_TYPE); |
4546 __ Assert(eq, kUnexpectedInitialMapForArrayFunction); | 4687 __ Assert(eq, kUnexpectedInitialMapForArrayFunction); |
4547 } | 4688 } |
4548 | 4689 |
4549 // Figure out the right elements kind | 4690 // Figure out the right elements kind |
4550 __ ldr(r3, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset)); | 4691 __ LoadP(r6, FieldMemOperand(r4, JSFunction::kPrototypeOrInitialMapOffset)); |
4551 // Load the map's "bit field 2" into |result|. We only need the first byte, | 4692 // Load the map's "bit field 2" into |result|. |
4552 // but the following bit field extraction takes care of that anyway. | 4693 __ lbz(r6, FieldMemOperand(r6, Map::kBitField2Offset)); |
4553 __ ldr(r3, FieldMemOperand(r3, Map::kBitField2Offset)); | |
4554 // Retrieve elements_kind from bit field 2. | 4694 // Retrieve elements_kind from bit field 2. |
4555 __ DecodeField<Map::ElementsKindBits>(r3); | 4695 __ DecodeField<Map::ElementsKindBits>(r6); |
4556 | 4696 |
4557 if (FLAG_debug_code) { | 4697 if (FLAG_debug_code) { |
4558 Label done; | 4698 Label done; |
4559 __ cmp(r3, Operand(FAST_ELEMENTS)); | 4699 __ cmpi(r6, Operand(FAST_ELEMENTS)); |
4560 __ b(eq, &done); | 4700 __ beq(&done); |
4561 __ cmp(r3, Operand(FAST_HOLEY_ELEMENTS)); | 4701 __ cmpi(r6, Operand(FAST_HOLEY_ELEMENTS)); |
4562 __ Assert(eq, | 4702 __ Assert(eq, kInvalidElementsKindForInternalArrayOrInternalPackedArray); |
4563 kInvalidElementsKindForInternalArrayOrInternalPackedArray); | |
4564 __ bind(&done); | 4703 __ bind(&done); |
4565 } | 4704 } |
4566 | 4705 |
4567 Label fast_elements_case; | 4706 Label fast_elements_case; |
4568 __ cmp(r3, Operand(FAST_ELEMENTS)); | 4707 __ cmpi(r6, Operand(FAST_ELEMENTS)); |
4569 __ b(eq, &fast_elements_case); | 4708 __ beq(&fast_elements_case); |
4570 GenerateCase(masm, FAST_HOLEY_ELEMENTS); | 4709 GenerateCase(masm, FAST_HOLEY_ELEMENTS); |
4571 | 4710 |
4572 __ bind(&fast_elements_case); | 4711 __ bind(&fast_elements_case); |
4573 GenerateCase(masm, FAST_ELEMENTS); | 4712 GenerateCase(masm, FAST_ELEMENTS); |
4574 } | 4713 } |
4575 | 4714 |
4576 | 4715 |
4577 void CallApiFunctionStub::Generate(MacroAssembler* masm) { | 4716 void CallApiFunctionStub::Generate(MacroAssembler* masm) { |
4578 // ----------- S t a t e ------------- | 4717 // ----------- S t a t e ------------- |
4579 // -- r0 : callee | 4718 // -- r3 : callee |
4580 // -- r4 : call_data | 4719 // -- r7 : call_data |
4581 // -- r2 : holder | 4720 // -- r5 : holder |
4582 // -- r1 : api_function_address | 4721 // -- r4 : api_function_address |
4583 // -- cp : context | 4722 // -- cp : context |
4584 // -- | 4723 // -- |
4585 // -- sp[0] : last argument | 4724 // -- sp[0] : last argument |
4586 // -- ... | 4725 // -- ... |
4587 // -- sp[(argc - 1)* 4] : first argument | 4726 // -- sp[(argc - 1)* 4] : first argument |
4588 // -- sp[argc * 4] : receiver | 4727 // -- sp[argc * 4] : receiver |
4589 // ----------------------------------- | 4728 // ----------------------------------- |
4590 | 4729 |
4591 Register callee = r0; | 4730 Register callee = r3; |
4592 Register call_data = r4; | 4731 Register call_data = r7; |
4593 Register holder = r2; | 4732 Register holder = r5; |
4594 Register api_function_address = r1; | 4733 Register api_function_address = r4; |
4595 Register context = cp; | 4734 Register context = cp; |
4596 | 4735 |
4597 int argc = this->argc(); | 4736 int argc = this->argc(); |
4598 bool is_store = this->is_store(); | 4737 bool is_store = this->is_store(); |
4599 bool call_data_undefined = this->call_data_undefined(); | 4738 bool call_data_undefined = this->call_data_undefined(); |
4600 | 4739 |
4601 typedef FunctionCallbackArguments FCA; | 4740 typedef FunctionCallbackArguments FCA; |
4602 | 4741 |
4603 STATIC_ASSERT(FCA::kContextSaveIndex == 6); | 4742 STATIC_ASSERT(FCA::kContextSaveIndex == 6); |
4604 STATIC_ASSERT(FCA::kCalleeIndex == 5); | 4743 STATIC_ASSERT(FCA::kCalleeIndex == 5); |
4605 STATIC_ASSERT(FCA::kDataIndex == 4); | 4744 STATIC_ASSERT(FCA::kDataIndex == 4); |
4606 STATIC_ASSERT(FCA::kReturnValueOffset == 3); | 4745 STATIC_ASSERT(FCA::kReturnValueOffset == 3); |
4607 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); | 4746 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); |
4608 STATIC_ASSERT(FCA::kIsolateIndex == 1); | 4747 STATIC_ASSERT(FCA::kIsolateIndex == 1); |
4609 STATIC_ASSERT(FCA::kHolderIndex == 0); | 4748 STATIC_ASSERT(FCA::kHolderIndex == 0); |
4610 STATIC_ASSERT(FCA::kArgsLength == 7); | 4749 STATIC_ASSERT(FCA::kArgsLength == 7); |
4611 | 4750 |
4612 // context save | 4751 // context save |
4613 __ push(context); | 4752 __ push(context); |
4614 // load context from callee | 4753 // load context from callee |
4615 __ ldr(context, FieldMemOperand(callee, JSFunction::kContextOffset)); | 4754 __ LoadP(context, FieldMemOperand(callee, JSFunction::kContextOffset)); |
4616 | 4755 |
4617 // callee | 4756 // callee |
4618 __ push(callee); | 4757 __ push(callee); |
4619 | 4758 |
4620 // call data | 4759 // call data |
4621 __ push(call_data); | 4760 __ push(call_data); |
4622 | 4761 |
4623 Register scratch = call_data; | 4762 Register scratch = call_data; |
4624 if (!call_data_undefined) { | 4763 if (!call_data_undefined) { |
4625 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); | 4764 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); |
4626 } | 4765 } |
4627 // return value | 4766 // return value |
4628 __ push(scratch); | 4767 __ push(scratch); |
4629 // return value default | 4768 // return value default |
4630 __ push(scratch); | 4769 __ push(scratch); |
4631 // isolate | 4770 // isolate |
4632 __ mov(scratch, | 4771 __ mov(scratch, Operand(ExternalReference::isolate_address(isolate()))); |
4633 Operand(ExternalReference::isolate_address(isolate()))); | |
4634 __ push(scratch); | 4772 __ push(scratch); |
4635 // holder | 4773 // holder |
4636 __ push(holder); | 4774 __ push(holder); |
4637 | 4775 |
4638 // Prepare arguments. | 4776 // Prepare arguments. |
4639 __ mov(scratch, sp); | 4777 __ mr(scratch, sp); |
4640 | 4778 |
4641 // Allocate the v8::Arguments structure in the arguments' space since | 4779 // Allocate the v8::Arguments structure in the arguments' space since |
4642 // it's not controlled by GC. | 4780 // it's not controlled by GC. |
4643 const int kApiStackSpace = 4; | 4781 // PPC LINUX ABI: |
| 4782 // |
| 4783 // Create 5 extra slots on stack: |
| 4784 // [0] space for DirectCEntryStub's LR save |
| 4785 // [1-4] FunctionCallbackInfo |
| 4786 const int kApiStackSpace = 5; |
4644 | 4787 |
4645 FrameScope frame_scope(masm, StackFrame::MANUAL); | 4788 FrameScope frame_scope(masm, StackFrame::MANUAL); |
4646 __ EnterExitFrame(false, kApiStackSpace); | 4789 __ EnterExitFrame(false, kApiStackSpace); |
4647 | 4790 |
4648 DCHECK(!api_function_address.is(r0) && !scratch.is(r0)); | 4791 DCHECK(!api_function_address.is(r3) && !scratch.is(r3)); |
4649 // r0 = FunctionCallbackInfo& | 4792 // r3 = FunctionCallbackInfo& |
4650 // Arguments is after the return address. | 4793 // Arguments is after the return address. |
4651 __ add(r0, sp, Operand(1 * kPointerSize)); | 4794 __ addi(r3, sp, Operand((kStackFrameExtraParamSlot + 1) * kPointerSize)); |
4652 // FunctionCallbackInfo::implicit_args_ | 4795 // FunctionCallbackInfo::implicit_args_ |
4653 __ str(scratch, MemOperand(r0, 0 * kPointerSize)); | 4796 __ StoreP(scratch, MemOperand(r3, 0 * kPointerSize)); |
4654 // FunctionCallbackInfo::values_ | 4797 // FunctionCallbackInfo::values_ |
4655 __ add(ip, scratch, Operand((FCA::kArgsLength - 1 + argc) * kPointerSize)); | 4798 __ addi(ip, scratch, Operand((FCA::kArgsLength - 1 + argc) * kPointerSize)); |
4656 __ str(ip, MemOperand(r0, 1 * kPointerSize)); | 4799 __ StoreP(ip, MemOperand(r3, 1 * kPointerSize)); |
4657 // FunctionCallbackInfo::length_ = argc | 4800 // FunctionCallbackInfo::length_ = argc |
4658 __ mov(ip, Operand(argc)); | 4801 __ li(ip, Operand(argc)); |
4659 __ str(ip, MemOperand(r0, 2 * kPointerSize)); | 4802 __ stw(ip, MemOperand(r3, 2 * kPointerSize)); |
4660 // FunctionCallbackInfo::is_construct_call = 0 | 4803 // FunctionCallbackInfo::is_construct_call = 0 |
4661 __ mov(ip, Operand::Zero()); | 4804 __ li(ip, Operand::Zero()); |
4662 __ str(ip, MemOperand(r0, 3 * kPointerSize)); | 4805 __ stw(ip, MemOperand(r3, 2 * kPointerSize + kIntSize)); |
4663 | 4806 |
4664 const int kStackUnwindSpace = argc + FCA::kArgsLength + 1; | 4807 const int kStackUnwindSpace = argc + FCA::kArgsLength + 1; |
4665 ExternalReference thunk_ref = | 4808 ExternalReference thunk_ref = |
4666 ExternalReference::invoke_function_callback(isolate()); | 4809 ExternalReference::invoke_function_callback(isolate()); |
4667 | 4810 |
4668 AllowExternalCallThatCantCauseGC scope(masm); | 4811 AllowExternalCallThatCantCauseGC scope(masm); |
4669 MemOperand context_restore_operand( | 4812 MemOperand context_restore_operand( |
4670 fp, (2 + FCA::kContextSaveIndex) * kPointerSize); | 4813 fp, (2 + FCA::kContextSaveIndex) * kPointerSize); |
4671 // Stores return the first js argument | 4814 // Stores return the first js argument |
4672 int return_value_offset = 0; | 4815 int return_value_offset = 0; |
4673 if (is_store) { | 4816 if (is_store) { |
4674 return_value_offset = 2 + FCA::kArgsLength; | 4817 return_value_offset = 2 + FCA::kArgsLength; |
4675 } else { | 4818 } else { |
4676 return_value_offset = 2 + FCA::kReturnValueOffset; | 4819 return_value_offset = 2 + FCA::kReturnValueOffset; |
4677 } | 4820 } |
4678 MemOperand return_value_operand(fp, return_value_offset * kPointerSize); | 4821 MemOperand return_value_operand(fp, return_value_offset * kPointerSize); |
4679 | 4822 |
4680 __ CallApiFunctionAndReturn(api_function_address, | 4823 __ CallApiFunctionAndReturn(api_function_address, thunk_ref, |
4681 thunk_ref, | 4824 kStackUnwindSpace, return_value_operand, |
4682 kStackUnwindSpace, | |
4683 return_value_operand, | |
4684 &context_restore_operand); | 4825 &context_restore_operand); |
4685 } | 4826 } |
4686 | 4827 |
4687 | 4828 |
4688 void CallApiGetterStub::Generate(MacroAssembler* masm) { | 4829 void CallApiGetterStub::Generate(MacroAssembler* masm) { |
4689 // ----------- S t a t e ------------- | 4830 // ----------- S t a t e ------------- |
4690 // -- sp[0] : name | 4831 // -- sp[0] : name |
4691 // -- sp[4 - kArgsLength*4] : PropertyCallbackArguments object | 4832 // -- sp[4 - kArgsLength*4] : PropertyCallbackArguments object |
4692 // -- ... | 4833 // -- ... |
4693 // -- r2 : api_function_address | 4834 // -- r5 : api_function_address |
4694 // ----------------------------------- | 4835 // ----------------------------------- |
4695 | 4836 |
4696 Register api_function_address = ApiGetterDescriptor::function_address(); | 4837 Register api_function_address = ApiGetterDescriptor::function_address(); |
4697 DCHECK(api_function_address.is(r2)); | 4838 DCHECK(api_function_address.is(r5)); |
4698 | 4839 |
4699 __ mov(r0, sp); // r0 = Handle<Name> | 4840 __ mr(r3, sp); // r0 = Handle<Name> |
4700 __ add(r1, r0, Operand(1 * kPointerSize)); // r1 = PCA | 4841 __ addi(r4, r3, Operand(1 * kPointerSize)); // r4 = PCA |
4701 | 4842 |
4702 const int kApiStackSpace = 1; | 4843 // If ABI passes Handles (pointer-sized struct) in a register: |
| 4844 // |
| 4845 // Create 2 extra slots on stack: |
| 4846 // [0] space for DirectCEntryStub's LR save |
| 4847 // [1] AccessorInfo& |
| 4848 // |
| 4849 // Otherwise: |
| 4850 // |
| 4851 // Create 3 extra slots on stack: |
| 4852 // [0] space for DirectCEntryStub's LR save |
| 4853 // [1] copy of Handle (first arg) |
| 4854 // [2] AccessorInfo& |
| 4855 #if ABI_PASSES_HANDLES_IN_REGS |
| 4856 const int kAccessorInfoSlot = kStackFrameExtraParamSlot + 1; |
| 4857 const int kApiStackSpace = 2; |
| 4858 #else |
| 4859 const int kArg0Slot = kStackFrameExtraParamSlot + 1; |
| 4860 const int kAccessorInfoSlot = kArg0Slot + 1; |
| 4861 const int kApiStackSpace = 3; |
| 4862 #endif |
| 4863 |
4703 FrameScope frame_scope(masm, StackFrame::MANUAL); | 4864 FrameScope frame_scope(masm, StackFrame::MANUAL); |
4704 __ EnterExitFrame(false, kApiStackSpace); | 4865 __ EnterExitFrame(false, kApiStackSpace); |
4705 | 4866 |
| 4867 #if !ABI_PASSES_HANDLES_IN_REGS |
| 4868 // pass 1st arg by reference |
| 4869 __ StoreP(r3, MemOperand(sp, kArg0Slot * kPointerSize)); |
| 4870 __ addi(r3, sp, Operand(kArg0Slot * kPointerSize)); |
| 4871 #endif |
| 4872 |
4706 // Create PropertyAccessorInfo instance on the stack above the exit frame with | 4873 // Create PropertyAccessorInfo instance on the stack above the exit frame with |
4707 // r1 (internal::Object** args_) as the data. | 4874 // r4 (internal::Object** args_) as the data. |
4708 __ str(r1, MemOperand(sp, 1 * kPointerSize)); | 4875 __ StoreP(r4, MemOperand(sp, kAccessorInfoSlot * kPointerSize)); |
4709 __ add(r1, sp, Operand(1 * kPointerSize)); // r1 = AccessorInfo& | 4876 // r4 = AccessorInfo& |
| 4877 __ addi(r4, sp, Operand(kAccessorInfoSlot * kPointerSize)); |
4710 | 4878 |
4711 const int kStackUnwindSpace = PropertyCallbackArguments::kArgsLength + 1; | 4879 const int kStackUnwindSpace = PropertyCallbackArguments::kArgsLength + 1; |
4712 | 4880 |
4713 ExternalReference thunk_ref = | 4881 ExternalReference thunk_ref = |
4714 ExternalReference::invoke_accessor_getter_callback(isolate()); | 4882 ExternalReference::invoke_accessor_getter_callback(isolate()); |
4715 __ CallApiFunctionAndReturn(api_function_address, | 4883 __ CallApiFunctionAndReturn(api_function_address, thunk_ref, |
4716 thunk_ref, | |
4717 kStackUnwindSpace, | 4884 kStackUnwindSpace, |
4718 MemOperand(fp, 6 * kPointerSize), | 4885 MemOperand(fp, 6 * kPointerSize), NULL); |
4719 NULL); | |
4720 } | 4886 } |
4721 | 4887 |
4722 | 4888 |
4723 #undef __ | 4889 #undef __ |
| 4890 } |
| 4891 } // namespace v8::internal |
4724 | 4892 |
4725 } } // namespace v8::internal | 4893 #endif // V8_TARGET_ARCH_PPC |
4726 | |
4727 #endif // V8_TARGET_ARCH_ARM | |
OLD | NEW |