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

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

Powered by Google App Engine
This is Rietveld 408576698