Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: src/ppc/code-stubs-ppc.cc

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

Powered by Google App Engine
This is Rietveld 408576698