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

Side by Side Diff: src/ic/ppc/ic-ppc.cc

Issue 714093002: PowerPC specific sub-directories. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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/ic/ppc/ic-compiler-ppc.cc ('k') | src/ic/ppc/stub-cache-ppc.cc » ('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/codegen.h" 9 #include "src/codegen.h"
10 #include "src/ic/ic.h" 10 #include "src/ic/ic.h"
11 #include "src/ic/ic-compiler.h" 11 #include "src/ic/ic-compiler.h"
12 #include "src/ic/stub-cache.h" 12 #include "src/ic/stub-cache.h"
13 13
14 namespace v8 { 14 namespace v8 {
15 namespace internal { 15 namespace internal {
16 16
17 17
18 // ---------------------------------------------------------------------------- 18 // ----------------------------------------------------------------------------
19 // Static IC stub generators. 19 // Static IC stub generators.
20 // 20 //
21 21
22 #define __ ACCESS_MASM(masm) 22 #define __ ACCESS_MASM(masm)
23 23
24 24
25 static void GenerateGlobalInstanceTypeCheck(MacroAssembler* masm, Register type, 25 static void GenerateGlobalInstanceTypeCheck(MacroAssembler* masm, Register type,
26 Label* global_object) { 26 Label* global_object) {
27 // Register usage: 27 // Register usage:
28 // type: holds the receiver instance type on entry. 28 // type: holds the receiver instance type on entry.
29 __ cmp(type, Operand(JS_GLOBAL_OBJECT_TYPE)); 29 __ cmpi(type, Operand(JS_GLOBAL_OBJECT_TYPE));
30 __ b(eq, global_object); 30 __ beq(global_object);
31 __ cmp(type, Operand(JS_BUILTINS_OBJECT_TYPE)); 31 __ cmpi(type, Operand(JS_BUILTINS_OBJECT_TYPE));
32 __ b(eq, global_object); 32 __ beq(global_object);
33 __ cmp(type, Operand(JS_GLOBAL_PROXY_TYPE)); 33 __ cmpi(type, Operand(JS_GLOBAL_PROXY_TYPE));
34 __ b(eq, global_object); 34 __ beq(global_object);
35 } 35 }
36 36
37 37
38 // Helper function used from LoadIC GenerateNormal. 38 // Helper function used from LoadIC GenerateNormal.
39 // 39 //
40 // elements: Property dictionary. It is not clobbered if a jump to the miss 40 // elements: Property dictionary. It is not clobbered if a jump to the miss
41 // label is done. 41 // label is done.
42 // name: Property name. It is not clobbered if a jump to the miss label is 42 // name: Property name. It is not clobbered if a jump to the miss label is
43 // done 43 // done
44 // result: Register for the result. It is only updated if a jump to the miss 44 // result: Register for the result. It is only updated if a jump to the miss
(...skipping 17 matching lines...) Expand all
62 NameDictionaryLookupStub::GeneratePositiveLookup(masm, miss, &done, elements, 62 NameDictionaryLookupStub::GeneratePositiveLookup(masm, miss, &done, elements,
63 name, scratch1, scratch2); 63 name, scratch1, scratch2);
64 64
65 // If probing finds an entry check that the value is a normal 65 // If probing finds an entry check that the value is a normal
66 // property. 66 // property.
67 __ bind(&done); // scratch2 == elements + 4 * index 67 __ bind(&done); // scratch2 == elements + 4 * index
68 const int kElementsStartOffset = 68 const int kElementsStartOffset =
69 NameDictionary::kHeaderSize + 69 NameDictionary::kHeaderSize +
70 NameDictionary::kElementsStartIndex * kPointerSize; 70 NameDictionary::kElementsStartIndex * kPointerSize;
71 const int kDetailsOffset = kElementsStartOffset + 2 * kPointerSize; 71 const int kDetailsOffset = kElementsStartOffset + 2 * kPointerSize;
72 __ ldr(scratch1, FieldMemOperand(scratch2, kDetailsOffset)); 72 __ LoadP(scratch1, FieldMemOperand(scratch2, kDetailsOffset));
73 __ tst(scratch1, Operand(PropertyDetails::TypeField::kMask << kSmiTagSize)); 73 __ mr(r0, scratch2);
74 __ b(ne, miss); 74 __ LoadSmiLiteral(scratch2, Smi::FromInt(PropertyDetails::TypeField::kMask));
75 __ and_(scratch2, scratch1, scratch2, SetRC);
76 __ bne(miss, cr0);
77 __ mr(scratch2, r0);
75 78
76 // Get the value at the masked, scaled index and return. 79 // Get the value at the masked, scaled index and return.
77 __ ldr(result, 80 __ LoadP(result,
78 FieldMemOperand(scratch2, kElementsStartOffset + 1 * kPointerSize)); 81 FieldMemOperand(scratch2, kElementsStartOffset + 1 * kPointerSize));
79 } 82 }
80 83
81 84
82 // Helper function used from StoreIC::GenerateNormal. 85 // Helper function used from StoreIC::GenerateNormal.
83 // 86 //
84 // elements: Property dictionary. It is not clobbered if a jump to the miss 87 // elements: Property dictionary. It is not clobbered if a jump to the miss
85 // label is done. 88 // label is done.
86 // name: Property name. It is not clobbered if a jump to the miss label is 89 // name: Property name. It is not clobbered if a jump to the miss label is
87 // done 90 // done
88 // value: The value to store. 91 // value: The value to store.
(...skipping 15 matching lines...) Expand all
104 NameDictionaryLookupStub::GeneratePositiveLookup(masm, miss, &done, elements, 107 NameDictionaryLookupStub::GeneratePositiveLookup(masm, miss, &done, elements,
105 name, scratch1, scratch2); 108 name, scratch1, scratch2);
106 109
107 // If probing finds an entry in the dictionary check that the value 110 // If probing finds an entry in the dictionary check that the value
108 // is a normal property that is not read only. 111 // is a normal property that is not read only.
109 __ bind(&done); // scratch2 == elements + 4 * index 112 __ bind(&done); // scratch2 == elements + 4 * index
110 const int kElementsStartOffset = 113 const int kElementsStartOffset =
111 NameDictionary::kHeaderSize + 114 NameDictionary::kHeaderSize +
112 NameDictionary::kElementsStartIndex * kPointerSize; 115 NameDictionary::kElementsStartIndex * kPointerSize;
113 const int kDetailsOffset = kElementsStartOffset + 2 * kPointerSize; 116 const int kDetailsOffset = kElementsStartOffset + 2 * kPointerSize;
114 const int kTypeAndReadOnlyMask = 117 int kTypeAndReadOnlyMask =
115 (PropertyDetails::TypeField::kMask | 118 PropertyDetails::TypeField::kMask |
116 PropertyDetails::AttributesField::encode(READ_ONLY)) 119 PropertyDetails::AttributesField::encode(READ_ONLY);
117 << kSmiTagSize; 120 __ LoadP(scratch1, FieldMemOperand(scratch2, kDetailsOffset));
118 __ ldr(scratch1, FieldMemOperand(scratch2, kDetailsOffset)); 121 __ mr(r0, scratch2);
119 __ tst(scratch1, Operand(kTypeAndReadOnlyMask)); 122 __ LoadSmiLiteral(scratch2, Smi::FromInt(kTypeAndReadOnlyMask));
120 __ b(ne, miss); 123 __ and_(scratch2, scratch1, scratch2, SetRC);
124 __ bne(miss, cr0);
125 __ mr(scratch2, r0);
121 126
122 // Store the value at the masked, scaled index and return. 127 // Store the value at the masked, scaled index and return.
123 const int kValueOffset = kElementsStartOffset + kPointerSize; 128 const int kValueOffset = kElementsStartOffset + kPointerSize;
124 __ add(scratch2, scratch2, Operand(kValueOffset - kHeapObjectTag)); 129 __ addi(scratch2, scratch2, Operand(kValueOffset - kHeapObjectTag));
125 __ str(value, MemOperand(scratch2)); 130 __ StoreP(value, MemOperand(scratch2));
126 131
127 // Update the write barrier. Make sure not to clobber the value. 132 // Update the write barrier. Make sure not to clobber the value.
128 __ mov(scratch1, value); 133 __ mr(scratch1, value);
129 __ RecordWrite(elements, scratch2, scratch1, kLRHasNotBeenSaved, 134 __ RecordWrite(elements, scratch2, scratch1, kLRHasNotBeenSaved,
130 kDontSaveFPRegs); 135 kDontSaveFPRegs);
131 } 136 }
132 137
133 138
134 // Checks the receiver for special cases (value type, slow case bits). 139 // Checks the receiver for special cases (value type, slow case bits).
135 // Falls through for regular JS object. 140 // Falls through for regular JS object.
136 static void GenerateKeyedLoadReceiverCheck(MacroAssembler* masm, 141 static void GenerateKeyedLoadReceiverCheck(MacroAssembler* masm,
137 Register receiver, Register map, 142 Register receiver, Register map,
138 Register scratch, 143 Register scratch,
139 int interceptor_bit, Label* slow) { 144 int interceptor_bit, Label* slow) {
140 // Check that the object isn't a smi. 145 // Check that the object isn't a smi.
141 __ JumpIfSmi(receiver, slow); 146 __ JumpIfSmi(receiver, slow);
142 // Get the map of the receiver. 147 // Get the map of the receiver.
143 __ ldr(map, FieldMemOperand(receiver, HeapObject::kMapOffset)); 148 __ LoadP(map, FieldMemOperand(receiver, HeapObject::kMapOffset));
144 // Check bit field. 149 // Check bit field.
145 __ ldrb(scratch, FieldMemOperand(map, Map::kBitFieldOffset)); 150 __ lbz(scratch, FieldMemOperand(map, Map::kBitFieldOffset));
146 __ tst(scratch, 151 DCHECK(((1 << Map::kIsAccessCheckNeeded) | (1 << interceptor_bit)) < 0x8000);
147 Operand((1 << Map::kIsAccessCheckNeeded) | (1 << interceptor_bit))); 152 __ andi(r0, scratch,
148 __ b(ne, slow); 153 Operand((1 << Map::kIsAccessCheckNeeded) | (1 << interceptor_bit)));
154 __ bne(slow, cr0);
149 // Check that the object is some kind of JS object EXCEPT JS Value type. 155 // Check that the object is some kind of JS object EXCEPT JS Value type.
150 // In the case that the object is a value-wrapper object, 156 // In the case that the object is a value-wrapper object,
151 // we enter the runtime system to make sure that indexing into string 157 // we enter the runtime system to make sure that indexing into string
152 // objects work as intended. 158 // objects work as intended.
153 DCHECK(JS_OBJECT_TYPE > JS_VALUE_TYPE); 159 DCHECK(JS_OBJECT_TYPE > JS_VALUE_TYPE);
154 __ ldrb(scratch, FieldMemOperand(map, Map::kInstanceTypeOffset)); 160 __ lbz(scratch, FieldMemOperand(map, Map::kInstanceTypeOffset));
155 __ cmp(scratch, Operand(JS_OBJECT_TYPE)); 161 __ cmpi(scratch, Operand(JS_OBJECT_TYPE));
156 __ b(lt, slow); 162 __ blt(slow);
157 } 163 }
158 164
159 165
160 // Loads an indexed element from a fast case array. 166 // Loads an indexed element from a fast case array.
161 // If not_fast_array is NULL, doesn't perform the elements map check. 167 // If not_fast_array is NULL, doesn't perform the elements map check.
162 static void GenerateFastArrayLoad(MacroAssembler* masm, Register receiver, 168 static void GenerateFastArrayLoad(MacroAssembler* masm, Register receiver,
163 Register key, Register elements, 169 Register key, Register elements,
164 Register scratch1, Register scratch2, 170 Register scratch1, Register scratch2,
165 Register result, Label* not_fast_array, 171 Register result, Label* not_fast_array,
166 Label* out_of_range) { 172 Label* out_of_range) {
(...skipping 12 matching lines...) Expand all
179 // Unchanged on bailout so 'receiver' and 'key' can be safely 185 // Unchanged on bailout so 'receiver' and 'key' can be safely
180 // used by further computation. 186 // used by further computation.
181 // 187 //
182 // Scratch registers: 188 // Scratch registers:
183 // 189 //
184 // scratch1 - used to hold elements map and elements length. 190 // scratch1 - used to hold elements map and elements length.
185 // Holds the elements map if not_fast_array branch is taken. 191 // Holds the elements map if not_fast_array branch is taken.
186 // 192 //
187 // scratch2 - used to hold the loaded value. 193 // scratch2 - used to hold the loaded value.
188 194
189 __ ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset)); 195 __ LoadP(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
190 if (not_fast_array != NULL) { 196 if (not_fast_array != NULL) {
191 // Check that the object is in fast mode and writable. 197 // Check that the object is in fast mode and writable.
192 __ ldr(scratch1, FieldMemOperand(elements, HeapObject::kMapOffset)); 198 __ LoadP(scratch1, FieldMemOperand(elements, HeapObject::kMapOffset));
193 __ LoadRoot(ip, Heap::kFixedArrayMapRootIndex); 199 __ LoadRoot(ip, Heap::kFixedArrayMapRootIndex);
194 __ cmp(scratch1, ip); 200 __ cmp(scratch1, ip);
195 __ b(ne, not_fast_array); 201 __ bne(not_fast_array);
196 } else { 202 } else {
197 __ AssertFastElements(elements); 203 __ AssertFastElements(elements);
198 } 204 }
199 // Check that the key (index) is within bounds. 205 // Check that the key (index) is within bounds.
200 __ ldr(scratch1, FieldMemOperand(elements, FixedArray::kLengthOffset)); 206 __ LoadP(scratch1, FieldMemOperand(elements, FixedArray::kLengthOffset));
201 __ cmp(key, Operand(scratch1)); 207 __ cmpl(key, scratch1);
202 __ b(hs, out_of_range); 208 __ bge(out_of_range);
203 // Fast case: Do the load. 209 // Fast case: Do the load.
204 __ add(scratch1, elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); 210 __ addi(scratch1, elements,
205 __ ldr(scratch2, MemOperand::PointerAddressFromSmiKey(scratch1, key)); 211 Operand(FixedArray::kHeaderSize - kHeapObjectTag));
212 // The key is a smi.
213 __ SmiToPtrArrayOffset(scratch2, key);
214 __ LoadPX(scratch2, MemOperand(scratch2, scratch1));
206 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); 215 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex);
207 __ cmp(scratch2, ip); 216 __ cmp(scratch2, ip);
208 // In case the loaded value is the_hole we have to consult GetProperty 217 // In case the loaded value is the_hole we have to consult GetProperty
209 // to ensure the prototype chain is searched. 218 // to ensure the prototype chain is searched.
210 __ b(eq, out_of_range); 219 __ beq(out_of_range);
211 __ mov(result, scratch2); 220 __ mr(result, scratch2);
212 } 221 }
213 222
214 223
215 // Checks whether a key is an array index string or a unique name. 224 // Checks whether a key is an array index string or a unique name.
216 // Falls through if a key is a unique name. 225 // Falls through if a key is a unique name.
217 static void GenerateKeyNameCheck(MacroAssembler* masm, Register key, 226 static void GenerateKeyNameCheck(MacroAssembler* masm, Register key,
218 Register map, Register hash, 227 Register map, Register hash,
219 Label* index_string, Label* not_unique) { 228 Label* index_string, Label* not_unique) {
220 // The key is not a smi. 229 // The key is not a smi.
221 Label unique; 230 Label unique;
222 // Is it a name? 231 // Is it a name?
223 __ CompareObjectType(key, map, hash, LAST_UNIQUE_NAME_TYPE); 232 __ CompareObjectType(key, map, hash, LAST_UNIQUE_NAME_TYPE);
224 __ b(hi, not_unique); 233 __ bgt(not_unique);
225 STATIC_ASSERT(LAST_UNIQUE_NAME_TYPE == FIRST_NONSTRING_TYPE); 234 STATIC_ASSERT(LAST_UNIQUE_NAME_TYPE == FIRST_NONSTRING_TYPE);
226 __ b(eq, &unique); 235 __ beq(&unique);
227 236
228 // Is the string an array index, with cached numeric value? 237 // Is the string an array index, with cached numeric value?
229 __ ldr(hash, FieldMemOperand(key, Name::kHashFieldOffset)); 238 __ lwz(hash, FieldMemOperand(key, Name::kHashFieldOffset));
230 __ tst(hash, Operand(Name::kContainsCachedArrayIndexMask)); 239 __ mov(r8, Operand(Name::kContainsCachedArrayIndexMask));
231 __ b(eq, index_string); 240 __ and_(r0, hash, r8, SetRC);
241 __ beq(index_string, cr0);
232 242
233 // Is the string internalized? We know it's a string, so a single 243 // Is the string internalized? We know it's a string, so a single
234 // bit test is enough. 244 // bit test is enough.
235 // map: key map 245 // map: key map
236 __ ldrb(hash, FieldMemOperand(map, Map::kInstanceTypeOffset)); 246 __ lbz(hash, FieldMemOperand(map, Map::kInstanceTypeOffset));
237 STATIC_ASSERT(kInternalizedTag == 0); 247 STATIC_ASSERT(kInternalizedTag == 0);
238 __ tst(hash, Operand(kIsNotInternalizedMask)); 248 __ andi(r0, hash, Operand(kIsNotInternalizedMask));
239 __ b(ne, not_unique); 249 __ bne(not_unique, cr0);
240 250
241 __ bind(&unique); 251 __ bind(&unique);
242 } 252 }
243 253
244 254
245 void LoadIC::GenerateNormal(MacroAssembler* masm) { 255 void LoadIC::GenerateNormal(MacroAssembler* masm) {
246 Register dictionary = r0; 256 Register dictionary = r3;
247 DCHECK(!dictionary.is(LoadDescriptor::ReceiverRegister())); 257 DCHECK(!dictionary.is(LoadDescriptor::ReceiverRegister()));
248 DCHECK(!dictionary.is(LoadDescriptor::NameRegister())); 258 DCHECK(!dictionary.is(LoadDescriptor::NameRegister()));
249 259
250 Label slow; 260 Label slow;
251 261
252 __ ldr(dictionary, FieldMemOperand(LoadDescriptor::ReceiverRegister(), 262 __ LoadP(dictionary, FieldMemOperand(LoadDescriptor::ReceiverRegister(),
253 JSObject::kPropertiesOffset)); 263 JSObject::kPropertiesOffset));
254 GenerateDictionaryLoad(masm, &slow, dictionary, 264 GenerateDictionaryLoad(masm, &slow, dictionary,
255 LoadDescriptor::NameRegister(), r0, r3, r4); 265 LoadDescriptor::NameRegister(), r3, r6, r7);
256 __ Ret(); 266 __ Ret();
257 267
258 // Dictionary load failed, go slow (but don't miss). 268 // Dictionary load failed, go slow (but don't miss).
259 __ bind(&slow); 269 __ bind(&slow);
260 GenerateRuntimeGetProperty(masm); 270 GenerateRuntimeGetProperty(masm);
261 } 271 }
262 272
263 273
264 // A register that isn't one of the parameters to the load ic. 274 // A register that isn't one of the parameters to the load ic.
265 static const Register LoadIC_TempRegister() { return r3; } 275 static const Register LoadIC_TempRegister() { return r6; }
266 276
267 277
268 void LoadIC::GenerateMiss(MacroAssembler* masm) { 278 void LoadIC::GenerateMiss(MacroAssembler* masm) {
269 // The return address is in lr. 279 // The return address is in lr.
270 Isolate* isolate = masm->isolate(); 280 Isolate* isolate = masm->isolate();
271 281
272 __ IncrementCounter(isolate->counters()->load_miss(), 1, r3, r4); 282 __ IncrementCounter(isolate->counters()->load_miss(), 1, r6, r7);
273 283
274 __ mov(LoadIC_TempRegister(), LoadDescriptor::ReceiverRegister()); 284 __ mr(LoadIC_TempRegister(), LoadDescriptor::ReceiverRegister());
275 __ Push(LoadIC_TempRegister(), LoadDescriptor::NameRegister()); 285 __ Push(LoadIC_TempRegister(), LoadDescriptor::NameRegister());
276 286
277 // Perform tail call to the entry. 287 // Perform tail call to the entry.
278 ExternalReference ref = ExternalReference(IC_Utility(kLoadIC_Miss), isolate); 288 ExternalReference ref = ExternalReference(IC_Utility(kLoadIC_Miss), isolate);
279 __ TailCallExternalReference(ref, 2, 1); 289 __ TailCallExternalReference(ref, 2, 1);
280 } 290 }
281 291
282 292
283 void LoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { 293 void LoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) {
284 // The return address is in lr. 294 // The return address is in lr.
285 295
286 __ mov(LoadIC_TempRegister(), LoadDescriptor::ReceiverRegister()); 296 __ mr(LoadIC_TempRegister(), LoadDescriptor::ReceiverRegister());
287 __ Push(LoadIC_TempRegister(), LoadDescriptor::NameRegister()); 297 __ Push(LoadIC_TempRegister(), LoadDescriptor::NameRegister());
288 298
289 __ TailCallRuntime(Runtime::kGetProperty, 2, 1); 299 __ TailCallRuntime(Runtime::kGetProperty, 2, 1);
290 } 300 }
291 301
292 302
293 static MemOperand GenerateMappedArgumentsLookup( 303 static MemOperand GenerateMappedArgumentsLookup(
294 MacroAssembler* masm, Register object, Register key, Register scratch1, 304 MacroAssembler* masm, Register object, Register key, Register scratch1,
295 Register scratch2, Register scratch3, Label* unmapped_case, 305 Register scratch2, Register scratch3, Label* unmapped_case,
296 Label* slow_case) { 306 Label* slow_case) {
297 Heap* heap = masm->isolate()->heap(); 307 Heap* heap = masm->isolate()->heap();
298 308
299 // Check that the receiver is a JSObject. Because of the map check 309 // Check that the receiver is a JSObject. Because of the map check
300 // later, we do not need to check for interceptors or whether it 310 // later, we do not need to check for interceptors or whether it
301 // requires access checks. 311 // requires access checks.
302 __ JumpIfSmi(object, slow_case); 312 __ JumpIfSmi(object, slow_case);
303 // Check that the object is some kind of JSObject. 313 // Check that the object is some kind of JSObject.
304 __ CompareObjectType(object, scratch1, scratch2, FIRST_JS_RECEIVER_TYPE); 314 __ CompareObjectType(object, scratch1, scratch2, FIRST_JS_RECEIVER_TYPE);
305 __ b(lt, slow_case); 315 __ blt(slow_case);
306 316
307 // Check that the key is a positive smi. 317 // Check that the key is a positive smi.
308 __ tst(key, Operand(0x80000001)); 318 __ mov(scratch1, Operand(0x80000001));
309 __ b(ne, slow_case); 319 __ and_(r0, key, scratch1, SetRC);
320 __ bne(slow_case, cr0);
310 321
311 // Load the elements into scratch1 and check its map. 322 // Load the elements into scratch1 and check its map.
312 Handle<Map> arguments_map(heap->sloppy_arguments_elements_map()); 323 Handle<Map> arguments_map(heap->sloppy_arguments_elements_map());
313 __ ldr(scratch1, FieldMemOperand(object, JSObject::kElementsOffset)); 324 __ LoadP(scratch1, FieldMemOperand(object, JSObject::kElementsOffset));
314 __ CheckMap(scratch1, scratch2, arguments_map, slow_case, DONT_DO_SMI_CHECK); 325 __ CheckMap(scratch1, scratch2, arguments_map, slow_case, DONT_DO_SMI_CHECK);
315 326
316 // Check if element is in the range of mapped arguments. If not, jump 327 // Check if element is in the range of mapped arguments. If not, jump
317 // to the unmapped lookup with the parameter map in scratch1. 328 // to the unmapped lookup with the parameter map in scratch1.
318 __ ldr(scratch2, FieldMemOperand(scratch1, FixedArray::kLengthOffset)); 329 __ LoadP(scratch2, FieldMemOperand(scratch1, FixedArray::kLengthOffset));
319 __ sub(scratch2, scratch2, Operand(Smi::FromInt(2))); 330 __ SubSmiLiteral(scratch2, scratch2, Smi::FromInt(2), r0);
320 __ cmp(key, Operand(scratch2)); 331 __ cmpl(key, scratch2);
321 __ b(cs, unmapped_case); 332 __ bge(unmapped_case);
322 333
323 // Load element index and check whether it is the hole. 334 // Load element index and check whether it is the hole.
324 const int kOffset = 335 const int kOffset =
325 FixedArray::kHeaderSize + 2 * kPointerSize - kHeapObjectTag; 336 FixedArray::kHeaderSize + 2 * kPointerSize - kHeapObjectTag;
326 337
327 __ mov(scratch3, Operand(kPointerSize >> 1)); 338 __ SmiToPtrArrayOffset(scratch3, key);
328 __ mul(scratch3, key, scratch3); 339 __ addi(scratch3, scratch3, Operand(kOffset));
329 __ add(scratch3, scratch3, Operand(kOffset));
330 340
331 __ ldr(scratch2, MemOperand(scratch1, scratch3)); 341 __ LoadPX(scratch2, MemOperand(scratch1, scratch3));
332 __ LoadRoot(scratch3, Heap::kTheHoleValueRootIndex); 342 __ LoadRoot(scratch3, Heap::kTheHoleValueRootIndex);
333 __ cmp(scratch2, scratch3); 343 __ cmp(scratch2, scratch3);
334 __ b(eq, unmapped_case); 344 __ beq(unmapped_case);
335 345
336 // Load value from context and return it. We can reuse scratch1 because 346 // Load value from context and return it. We can reuse scratch1 because
337 // we do not jump to the unmapped lookup (which requires the parameter 347 // we do not jump to the unmapped lookup (which requires the parameter
338 // map in scratch1). 348 // map in scratch1).
339 __ ldr(scratch1, FieldMemOperand(scratch1, FixedArray::kHeaderSize)); 349 __ LoadP(scratch1, FieldMemOperand(scratch1, FixedArray::kHeaderSize));
340 __ mov(scratch3, Operand(kPointerSize >> 1)); 350 __ SmiToPtrArrayOffset(scratch3, scratch2);
341 __ mul(scratch3, scratch2, scratch3); 351 __ addi(scratch3, scratch3, Operand(Context::kHeaderSize - kHeapObjectTag));
342 __ add(scratch3, scratch3, Operand(Context::kHeaderSize - kHeapObjectTag));
343 return MemOperand(scratch1, scratch3); 352 return MemOperand(scratch1, scratch3);
344 } 353 }
345 354
346 355
347 static MemOperand GenerateUnmappedArgumentsLookup(MacroAssembler* masm, 356 static MemOperand GenerateUnmappedArgumentsLookup(MacroAssembler* masm,
348 Register key, 357 Register key,
349 Register parameter_map, 358 Register parameter_map,
350 Register scratch, 359 Register scratch,
351 Label* slow_case) { 360 Label* slow_case) {
352 // Element is in arguments backing store, which is referenced by the 361 // Element is in arguments backing store, which is referenced by the
353 // second element of the parameter_map. The parameter_map register 362 // second element of the parameter_map. The parameter_map register
354 // must be loaded with the parameter map of the arguments object and is 363 // must be loaded with the parameter map of the arguments object and is
355 // overwritten. 364 // overwritten.
356 const int kBackingStoreOffset = FixedArray::kHeaderSize + kPointerSize; 365 const int kBackingStoreOffset = FixedArray::kHeaderSize + kPointerSize;
357 Register backing_store = parameter_map; 366 Register backing_store = parameter_map;
358 __ ldr(backing_store, FieldMemOperand(parameter_map, kBackingStoreOffset)); 367 __ LoadP(backing_store, FieldMemOperand(parameter_map, kBackingStoreOffset));
359 Handle<Map> fixed_array_map(masm->isolate()->heap()->fixed_array_map()); 368 Handle<Map> fixed_array_map(masm->isolate()->heap()->fixed_array_map());
360 __ CheckMap(backing_store, scratch, fixed_array_map, slow_case, 369 __ CheckMap(backing_store, scratch, fixed_array_map, slow_case,
361 DONT_DO_SMI_CHECK); 370 DONT_DO_SMI_CHECK);
362 __ ldr(scratch, FieldMemOperand(backing_store, FixedArray::kLengthOffset)); 371 __ LoadP(scratch, FieldMemOperand(backing_store, FixedArray::kLengthOffset));
363 __ cmp(key, Operand(scratch)); 372 __ cmpl(key, scratch);
364 __ b(cs, slow_case); 373 __ bge(slow_case);
365 __ mov(scratch, Operand(kPointerSize >> 1)); 374 __ SmiToPtrArrayOffset(scratch, key);
366 __ mul(scratch, key, scratch); 375 __ addi(scratch, scratch, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
367 __ add(scratch, scratch, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
368 return MemOperand(backing_store, scratch); 376 return MemOperand(backing_store, scratch);
369 } 377 }
370 378
371 379
372 void KeyedStoreIC::GenerateSloppyArguments(MacroAssembler* masm) { 380 void KeyedStoreIC::GenerateSloppyArguments(MacroAssembler* masm) {
373 Register receiver = StoreDescriptor::ReceiverRegister(); 381 Register receiver = StoreDescriptor::ReceiverRegister();
374 Register key = StoreDescriptor::NameRegister(); 382 Register key = StoreDescriptor::NameRegister();
375 Register value = StoreDescriptor::ValueRegister(); 383 Register value = StoreDescriptor::ValueRegister();
376 DCHECK(receiver.is(r1)); 384 DCHECK(receiver.is(r4));
377 DCHECK(key.is(r2)); 385 DCHECK(key.is(r5));
378 DCHECK(value.is(r0)); 386 DCHECK(value.is(r3));
379 387
380 Label slow, notin; 388 Label slow, notin;
381 MemOperand mapped_location = GenerateMappedArgumentsLookup( 389 MemOperand mapped_location = GenerateMappedArgumentsLookup(
382 masm, receiver, key, r3, r4, r5, &notin, &slow); 390 masm, receiver, key, r6, r7, r8, &notin, &slow);
383 __ str(value, mapped_location); 391 Register mapped_base = mapped_location.ra();
384 __ add(r6, r3, r5); 392 Register mapped_offset = mapped_location.rb();
385 __ mov(r9, value); 393 __ StorePX(value, mapped_location);
386 __ RecordWrite(r3, r6, r9, kLRHasNotBeenSaved, kDontSaveFPRegs); 394 __ add(r9, mapped_base, mapped_offset);
395 __ mr(r11, value);
396 __ RecordWrite(mapped_base, r9, r11, kLRHasNotBeenSaved, kDontSaveFPRegs);
387 __ Ret(); 397 __ Ret();
388 __ bind(&notin); 398 __ bind(&notin);
389 // The unmapped lookup expects that the parameter map is in r3. 399 // The unmapped lookup expects that the parameter map is in r6.
390 MemOperand unmapped_location = 400 MemOperand unmapped_location =
391 GenerateUnmappedArgumentsLookup(masm, key, r3, r4, &slow); 401 GenerateUnmappedArgumentsLookup(masm, key, r6, r7, &slow);
392 __ str(value, unmapped_location); 402 Register unmapped_base = unmapped_location.ra();
393 __ add(r6, r3, r4); 403 Register unmapped_offset = unmapped_location.rb();
394 __ mov(r9, value); 404 __ StorePX(value, unmapped_location);
395 __ RecordWrite(r3, r6, r9, kLRHasNotBeenSaved, kDontSaveFPRegs); 405 __ add(r9, unmapped_base, unmapped_offset);
406 __ mr(r11, value);
407 __ RecordWrite(unmapped_base, r9, r11, kLRHasNotBeenSaved, kDontSaveFPRegs);
396 __ Ret(); 408 __ Ret();
397 __ bind(&slow); 409 __ bind(&slow);
398 GenerateMiss(masm); 410 GenerateMiss(masm);
399 } 411 }
400 412
401 413
402 void KeyedLoadIC::GenerateMiss(MacroAssembler* masm) { 414 void KeyedLoadIC::GenerateMiss(MacroAssembler* masm) {
403 // The return address is in lr. 415 // The return address is in lr.
404 Isolate* isolate = masm->isolate(); 416 Isolate* isolate = masm->isolate();
405 417
406 __ IncrementCounter(isolate->counters()->keyed_load_miss(), 1, r3, r4); 418 __ IncrementCounter(isolate->counters()->keyed_load_miss(), 1, r6, r7);
407 419
408 __ Push(LoadDescriptor::ReceiverRegister(), LoadDescriptor::NameRegister()); 420 __ Push(LoadDescriptor::ReceiverRegister(), LoadDescriptor::NameRegister());
409 421
410 // Perform tail call to the entry. 422 // Perform tail call to the entry.
411 ExternalReference ref = 423 ExternalReference ref =
412 ExternalReference(IC_Utility(kKeyedLoadIC_Miss), isolate); 424 ExternalReference(IC_Utility(kKeyedLoadIC_Miss), isolate);
413 425
414 __ TailCallExternalReference(ref, 2, 1); 426 __ TailCallExternalReference(ref, 2, 1);
415 } 427 }
416 428
417 429
418 void KeyedLoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { 430 void KeyedLoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) {
419 // The return address is in lr. 431 // The return address is in lr.
420 432
421 __ Push(LoadDescriptor::ReceiverRegister(), LoadDescriptor::NameRegister()); 433 __ Push(LoadDescriptor::ReceiverRegister(), LoadDescriptor::NameRegister());
422 434
423 __ TailCallRuntime(Runtime::kKeyedGetProperty, 2, 1); 435 __ TailCallRuntime(Runtime::kKeyedGetProperty, 2, 1);
424 } 436 }
425 437
426 438
427 void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) { 439 void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) {
428 // The return address is in lr. 440 // The return address is in lr.
429 Label slow, check_name, index_smi, index_name, property_array_property; 441 Label slow, check_name, index_smi, index_name, property_array_property;
430 Label probe_dictionary, check_number_dictionary; 442 Label probe_dictionary, check_number_dictionary;
431 443
432 Register key = LoadDescriptor::NameRegister(); 444 Register key = LoadDescriptor::NameRegister();
433 Register receiver = LoadDescriptor::ReceiverRegister(); 445 Register receiver = LoadDescriptor::ReceiverRegister();
434 DCHECK(key.is(r2)); 446 DCHECK(key.is(r5));
435 DCHECK(receiver.is(r1)); 447 DCHECK(receiver.is(r4));
436 448
437 Isolate* isolate = masm->isolate(); 449 Isolate* isolate = masm->isolate();
438 450
439 // Check that the key is a smi. 451 // Check that the key is a smi.
440 __ JumpIfNotSmi(key, &check_name); 452 __ JumpIfNotSmi(key, &check_name);
441 __ bind(&index_smi); 453 __ bind(&index_smi);
442 // Now the key is known to be a smi. This place is also jumped to from below 454 // Now the key is known to be a smi. This place is also jumped to from below
443 // where a numeric string is converted to a smi. 455 // where a numeric string is converted to a smi.
444 456
445 GenerateKeyedLoadReceiverCheck(masm, receiver, r0, r3, 457 GenerateKeyedLoadReceiverCheck(masm, receiver, r3, r6,
446 Map::kHasIndexedInterceptor, &slow); 458 Map::kHasIndexedInterceptor, &slow);
447 459
448 // Check the receiver's map to see if it has fast elements. 460 // Check the receiver's map to see if it has fast elements.
449 __ CheckFastElements(r0, r3, &check_number_dictionary); 461 __ CheckFastElements(r3, r6, &check_number_dictionary);
450 462
451 GenerateFastArrayLoad(masm, receiver, key, r0, r3, r4, r0, NULL, &slow); 463 GenerateFastArrayLoad(masm, receiver, key, r3, r6, r7, r3, NULL, &slow);
452 __ IncrementCounter(isolate->counters()->keyed_load_generic_smi(), 1, r4, r3); 464 __ IncrementCounter(isolate->counters()->keyed_load_generic_smi(), 1, r7, r6);
453 __ Ret(); 465 __ Ret();
454 466
455 __ bind(&check_number_dictionary); 467 __ bind(&check_number_dictionary);
456 __ ldr(r4, FieldMemOperand(receiver, JSObject::kElementsOffset)); 468 __ LoadP(r7, FieldMemOperand(receiver, JSObject::kElementsOffset));
457 __ ldr(r3, FieldMemOperand(r4, JSObject::kMapOffset)); 469 __ LoadP(r6, FieldMemOperand(r7, JSObject::kMapOffset));
458 470
459 // Check whether the elements is a number dictionary. 471 // Check whether the elements is a number dictionary.
460 // r3: elements map 472 // r6: elements map
461 // r4: elements 473 // r7: elements
462 __ LoadRoot(ip, Heap::kHashTableMapRootIndex); 474 __ LoadRoot(ip, Heap::kHashTableMapRootIndex);
463 __ cmp(r3, ip); 475 __ cmp(r6, ip);
464 __ b(ne, &slow); 476 __ bne(&slow);
465 __ SmiUntag(r0, key); 477 __ SmiUntag(r3, key);
466 __ LoadFromNumberDictionary(&slow, r4, key, r0, r0, r3, r5); 478 __ LoadFromNumberDictionary(&slow, r7, key, r3, r3, r6, r8);
467 __ Ret(); 479 __ Ret();
468 480
469 // Slow case, key and receiver still in r2 and r1. 481 // Slow case, key and receiver still in r3 and r4.
470 __ bind(&slow); 482 __ bind(&slow);
471 __ IncrementCounter(isolate->counters()->keyed_load_generic_slow(), 1, r4, 483 __ IncrementCounter(isolate->counters()->keyed_load_generic_slow(), 1, r7,
472 r3); 484 r6);
473 GenerateRuntimeGetProperty(masm); 485 GenerateRuntimeGetProperty(masm);
474 486
475 __ bind(&check_name); 487 __ bind(&check_name);
476 GenerateKeyNameCheck(masm, key, r0, r3, &index_name, &slow); 488 GenerateKeyNameCheck(masm, key, r3, r6, &index_name, &slow);
477 489
478 GenerateKeyedLoadReceiverCheck(masm, receiver, r0, r3, 490 GenerateKeyedLoadReceiverCheck(masm, receiver, r3, r6,
479 Map::kHasNamedInterceptor, &slow); 491 Map::kHasNamedInterceptor, &slow);
480 492
481 // If the receiver is a fast-case object, check the keyed lookup 493 // If the receiver is a fast-case object, check the keyed lookup
482 // cache. Otherwise probe the dictionary. 494 // cache. Otherwise probe the dictionary.
483 __ ldr(r3, FieldMemOperand(receiver, JSObject::kPropertiesOffset)); 495 __ LoadP(r6, FieldMemOperand(receiver, JSObject::kPropertiesOffset));
484 __ ldr(r4, FieldMemOperand(r3, HeapObject::kMapOffset)); 496 __ LoadP(r7, FieldMemOperand(r6, HeapObject::kMapOffset));
485 __ LoadRoot(ip, Heap::kHashTableMapRootIndex); 497 __ LoadRoot(ip, Heap::kHashTableMapRootIndex);
486 __ cmp(r4, ip); 498 __ cmp(r7, ip);
487 __ b(eq, &probe_dictionary); 499 __ beq(&probe_dictionary);
488 500
489 // Load the map of the receiver, compute the keyed lookup cache hash 501 // Load the map of the receiver, compute the keyed lookup cache hash
490 // based on 32 bits of the map pointer and the name hash. 502 // based on 32 bits of the map pointer and the name hash.
491 __ ldr(r0, FieldMemOperand(receiver, HeapObject::kMapOffset)); 503 __ LoadP(r3, FieldMemOperand(receiver, HeapObject::kMapOffset));
492 __ mov(r3, Operand(r0, ASR, KeyedLookupCache::kMapHashShift)); 504 __ srawi(r6, r3, KeyedLookupCache::kMapHashShift);
493 __ ldr(r4, FieldMemOperand(key, Name::kHashFieldOffset)); 505 __ lwz(r7, FieldMemOperand(key, Name::kHashFieldOffset));
494 __ eor(r3, r3, Operand(r4, ASR, Name::kHashShift)); 506 __ srawi(r7, r7, Name::kHashShift);
507 __ xor_(r6, r6, r7);
495 int mask = KeyedLookupCache::kCapacityMask & KeyedLookupCache::kHashMask; 508 int mask = KeyedLookupCache::kCapacityMask & KeyedLookupCache::kHashMask;
496 __ And(r3, r3, Operand(mask)); 509 __ mov(r7, Operand(mask));
510 __ and_(r6, r6, r7, LeaveRC);
497 511
498 // Load the key (consisting of map and unique name) from the cache and 512 // Load the key (consisting of map and unique name) from the cache and
499 // check for match. 513 // check for match.
500 Label load_in_object_property; 514 Label load_in_object_property;
501 static const int kEntriesPerBucket = KeyedLookupCache::kEntriesPerBucket; 515 static const int kEntriesPerBucket = KeyedLookupCache::kEntriesPerBucket;
502 Label hit_on_nth_entry[kEntriesPerBucket]; 516 Label hit_on_nth_entry[kEntriesPerBucket];
503 ExternalReference cache_keys = 517 ExternalReference cache_keys =
504 ExternalReference::keyed_lookup_cache_keys(isolate); 518 ExternalReference::keyed_lookup_cache_keys(isolate);
505 519
506 __ mov(r4, Operand(cache_keys)); 520 __ mov(r7, Operand(cache_keys));
507 __ add(r4, r4, Operand(r3, LSL, kPointerSizeLog2 + 1)); 521 __ mr(r0, r5);
522 __ ShiftLeftImm(r5, r6, Operand(kPointerSizeLog2 + 1));
523 __ add(r7, r7, r5);
524 __ mr(r5, r0);
508 525
509 for (int i = 0; i < kEntriesPerBucket - 1; i++) { 526 for (int i = 0; i < kEntriesPerBucket - 1; i++) {
510 Label try_next_entry; 527 Label try_next_entry;
511 // Load map and move r4 to next entry. 528 // Load map and move r7 to next entry.
512 __ ldr(r5, MemOperand(r4, kPointerSize * 2, PostIndex)); 529 __ LoadP(r8, MemOperand(r7));
513 __ cmp(r0, r5); 530 __ addi(r7, r7, Operand(kPointerSize * 2));
514 __ b(ne, &try_next_entry); 531 __ cmp(r3, r8);
515 __ ldr(r5, MemOperand(r4, -kPointerSize)); // Load name 532 __ bne(&try_next_entry);
516 __ cmp(key, r5); 533 __ LoadP(r8, MemOperand(r7, -kPointerSize)); // Load name
517 __ b(eq, &hit_on_nth_entry[i]); 534 __ cmp(key, r8);
535 __ beq(&hit_on_nth_entry[i]);
518 __ bind(&try_next_entry); 536 __ bind(&try_next_entry);
519 } 537 }
520 538
521 // Last entry: Load map and move r4 to name. 539 // Last entry: Load map and move r7 to name.
522 __ ldr(r5, MemOperand(r4, kPointerSize, PostIndex)); 540 __ LoadP(r8, MemOperand(r7));
523 __ cmp(r0, r5); 541 __ addi(r7, r7, Operand(kPointerSize));
524 __ b(ne, &slow); 542 __ cmp(r3, r8);
525 __ ldr(r5, MemOperand(r4)); 543 __ bne(&slow);
526 __ cmp(key, r5); 544 __ LoadP(r8, MemOperand(r7));
527 __ b(ne, &slow); 545 __ cmp(key, r8);
546 __ bne(&slow);
528 547
529 // Get field offset. 548 // Get field offset.
530 // r0 : receiver's map 549 // r3 : receiver's map
531 // r3 : lookup cache index 550 // r6 : lookup cache index
532 ExternalReference cache_field_offsets = 551 ExternalReference cache_field_offsets =
533 ExternalReference::keyed_lookup_cache_field_offsets(isolate); 552 ExternalReference::keyed_lookup_cache_field_offsets(isolate);
534 553
535 // Hit on nth entry. 554 // Hit on nth entry.
536 for (int i = kEntriesPerBucket - 1; i >= 0; i--) { 555 for (int i = kEntriesPerBucket - 1; i >= 0; i--) {
537 __ bind(&hit_on_nth_entry[i]); 556 __ bind(&hit_on_nth_entry[i]);
538 __ mov(r4, Operand(cache_field_offsets)); 557 __ mov(r7, Operand(cache_field_offsets));
539 if (i != 0) { 558 if (i != 0) {
540 __ add(r3, r3, Operand(i)); 559 __ addi(r6, r6, Operand(i));
541 } 560 }
542 __ ldr(r5, MemOperand(r4, r3, LSL, kPointerSizeLog2)); 561 __ ShiftLeftImm(r8, r6, Operand(2));
543 __ ldrb(r6, FieldMemOperand(r0, Map::kInObjectPropertiesOffset)); 562 __ lwzx(r8, MemOperand(r8, r7));
544 __ sub(r5, r5, r6, SetCC); 563 __ lbz(r9, FieldMemOperand(r3, Map::kInObjectPropertiesOffset));
545 __ b(ge, &property_array_property); 564 __ sub(r8, r8, r9);
565 __ cmpi(r8, Operand::Zero());
566 __ bge(&property_array_property);
546 if (i != 0) { 567 if (i != 0) {
547 __ jmp(&load_in_object_property); 568 __ b(&load_in_object_property);
548 } 569 }
549 } 570 }
550 571
551 // Load in-object property. 572 // Load in-object property.
552 __ bind(&load_in_object_property); 573 __ bind(&load_in_object_property);
553 __ ldrb(r6, FieldMemOperand(r0, Map::kInstanceSizeOffset)); 574 __ lbz(r9, FieldMemOperand(r3, Map::kInstanceSizeOffset));
554 __ add(r6, r6, r5); // Index from start of object. 575 __ add(r9, r9, r8); // Index from start of object.
555 __ sub(receiver, receiver, Operand(kHeapObjectTag)); // Remove the heap tag. 576 __ subi(receiver, receiver, Operand(kHeapObjectTag)); // Remove the heap tag.
556 __ ldr(r0, MemOperand(receiver, r6, LSL, kPointerSizeLog2)); 577 __ ShiftLeftImm(r3, r9, Operand(kPointerSizeLog2));
578 __ LoadPX(r3, MemOperand(r3, receiver));
557 __ IncrementCounter(isolate->counters()->keyed_load_generic_lookup_cache(), 1, 579 __ IncrementCounter(isolate->counters()->keyed_load_generic_lookup_cache(), 1,
558 r4, r3); 580 r7, r6);
559 __ Ret(); 581 __ Ret();
560 582
561 // Load property array property. 583 // Load property array property.
562 __ bind(&property_array_property); 584 __ bind(&property_array_property);
563 __ ldr(receiver, FieldMemOperand(receiver, JSObject::kPropertiesOffset)); 585 __ LoadP(receiver, FieldMemOperand(receiver, JSObject::kPropertiesOffset));
564 __ add(receiver, receiver, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); 586 __ addi(receiver, receiver,
565 __ ldr(r0, MemOperand(receiver, r5, LSL, kPointerSizeLog2)); 587 Operand(FixedArray::kHeaderSize - kHeapObjectTag));
588 __ ShiftLeftImm(r3, r8, Operand(kPointerSizeLog2));
589 __ LoadPX(r3, MemOperand(r3, receiver));
566 __ IncrementCounter(isolate->counters()->keyed_load_generic_lookup_cache(), 1, 590 __ IncrementCounter(isolate->counters()->keyed_load_generic_lookup_cache(), 1,
567 r4, r3); 591 r7, r6);
568 __ Ret(); 592 __ Ret();
569 593
570 // Do a quick inline probe of the receiver's dictionary, if it 594 // Do a quick inline probe of the receiver's dictionary, if it
571 // exists. 595 // exists.
572 __ bind(&probe_dictionary); 596 __ bind(&probe_dictionary);
573 // r3: elements 597 // r6: elements
574 __ ldr(r0, FieldMemOperand(receiver, HeapObject::kMapOffset)); 598 __ LoadP(r3, FieldMemOperand(receiver, HeapObject::kMapOffset));
575 __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset)); 599 __ lbz(r3, FieldMemOperand(r3, Map::kInstanceTypeOffset));
576 GenerateGlobalInstanceTypeCheck(masm, r0, &slow); 600 GenerateGlobalInstanceTypeCheck(masm, r3, &slow);
577 // Load the property to r0. 601 // Load the property to r3.
578 GenerateDictionaryLoad(masm, &slow, r3, key, r0, r5, r4); 602 GenerateDictionaryLoad(masm, &slow, r6, key, r3, r8, r7);
579 __ IncrementCounter(isolate->counters()->keyed_load_generic_symbol(), 1, r4, 603 __ IncrementCounter(isolate->counters()->keyed_load_generic_symbol(), 1, r7,
580 r3); 604 r6);
581 __ Ret(); 605 __ Ret();
582 606
583 __ bind(&index_name); 607 __ bind(&index_name);
584 __ IndexFromHash(r3, key); 608 __ IndexFromHash(r6, key);
585 // Now jump to the place where smi keys are handled. 609 // Now jump to the place where smi keys are handled.
586 __ jmp(&index_smi); 610 __ b(&index_smi);
587 } 611 }
588 612
589 613
590 void KeyedStoreIC::GenerateMiss(MacroAssembler* masm) { 614 void KeyedStoreIC::GenerateMiss(MacroAssembler* masm) {
591 // Push receiver, key and value for runtime call. 615 // Push receiver, key and value for runtime call.
592 __ Push(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister(), 616 __ Push(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister(),
593 StoreDescriptor::ValueRegister()); 617 StoreDescriptor::ValueRegister());
594 618
595 ExternalReference ref = 619 ExternalReference ref =
596 ExternalReference(IC_Utility(kKeyedStoreIC_Miss), masm->isolate()); 620 ExternalReference(IC_Utility(kKeyedStoreIC_Miss), masm->isolate());
597 __ TailCallExternalReference(ref, 3, 1); 621 __ TailCallExternalReference(ref, 3, 1);
598 } 622 }
599 623
600 624
601 static void KeyedStoreGenerateMegamorphicHelper( 625 static void KeyedStoreGenerateMegamorphicHelper(
602 MacroAssembler* masm, Label* fast_object, Label* fast_double, Label* slow, 626 MacroAssembler* masm, Label* fast_object, Label* fast_double, Label* slow,
603 KeyedStoreCheckMap check_map, KeyedStoreIncrementLength increment_length, 627 KeyedStoreCheckMap check_map, KeyedStoreIncrementLength increment_length,
604 Register value, Register key, Register receiver, Register receiver_map, 628 Register value, Register key, Register receiver, Register receiver_map,
605 Register elements_map, Register elements) { 629 Register elements_map, Register elements) {
606 Label transition_smi_elements; 630 Label transition_smi_elements;
607 Label finish_object_store, non_double_value, transition_double_elements; 631 Label finish_object_store, non_double_value, transition_double_elements;
608 Label fast_double_without_map_check; 632 Label fast_double_without_map_check;
609 633
610 // Fast case: Do the store, could be either Object or double. 634 // Fast case: Do the store, could be either Object or double.
611 __ bind(fast_object); 635 __ bind(fast_object);
612 Register scratch_value = r4; 636 Register scratch_value = r7;
613 Register address = r5; 637 Register address = r8;
614 if (check_map == kCheckMap) { 638 if (check_map == kCheckMap) {
615 __ ldr(elements_map, FieldMemOperand(elements, HeapObject::kMapOffset)); 639 __ LoadP(elements_map, FieldMemOperand(elements, HeapObject::kMapOffset));
616 __ cmp(elements_map, 640 __ mov(scratch_value,
617 Operand(masm->isolate()->factory()->fixed_array_map())); 641 Operand(masm->isolate()->factory()->fixed_array_map()));
618 __ b(ne, fast_double); 642 __ cmp(elements_map, scratch_value);
643 __ bne(fast_double);
619 } 644 }
620 645
621 // HOLECHECK: guards "A[i] = V" 646 // HOLECHECK: guards "A[i] = V"
622 // We have to go to the runtime if the current value is the hole because 647 // We have to go to the runtime if the current value is the hole because
623 // there may be a callback on the element 648 // there may be a callback on the element
624 Label holecheck_passed1; 649 Label holecheck_passed1;
625 __ add(address, elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); 650 __ addi(address, elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
626 __ ldr(scratch_value, 651 __ SmiToPtrArrayOffset(scratch_value, key);
627 MemOperand::PointerAddressFromSmiKey(address, key, PreIndex)); 652 __ LoadPX(scratch_value, MemOperand(address, scratch_value));
628 __ cmp(scratch_value, Operand(masm->isolate()->factory()->the_hole_value())); 653 __ Cmpi(scratch_value, Operand(masm->isolate()->factory()->the_hole_value()),
629 __ b(ne, &holecheck_passed1); 654 r0);
655 __ bne(&holecheck_passed1);
630 __ JumpIfDictionaryInPrototypeChain(receiver, elements_map, scratch_value, 656 __ JumpIfDictionaryInPrototypeChain(receiver, elements_map, scratch_value,
631 slow); 657 slow);
632 658
633 __ bind(&holecheck_passed1); 659 __ bind(&holecheck_passed1);
634 660
635 // Smi stores don't require further checks. 661 // Smi stores don't require further checks.
636 Label non_smi_value; 662 Label non_smi_value;
637 __ JumpIfNotSmi(value, &non_smi_value); 663 __ JumpIfNotSmi(value, &non_smi_value);
638 664
639 if (increment_length == kIncrementLength) { 665 if (increment_length == kIncrementLength) {
640 // Add 1 to receiver->length. 666 // Add 1 to receiver->length.
641 __ add(scratch_value, key, Operand(Smi::FromInt(1))); 667 __ AddSmiLiteral(scratch_value, key, Smi::FromInt(1), r0);
642 __ str(scratch_value, FieldMemOperand(receiver, JSArray::kLengthOffset)); 668 __ StoreP(scratch_value, FieldMemOperand(receiver, JSArray::kLengthOffset),
669 r0);
643 } 670 }
644 // It's irrelevant whether array is smi-only or not when writing a smi. 671 // It's irrelevant whether array is smi-only or not when writing a smi.
645 __ add(address, elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); 672 __ addi(address, elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
646 __ str(value, MemOperand::PointerAddressFromSmiKey(address, key)); 673 __ SmiToPtrArrayOffset(scratch_value, key);
674 __ StorePX(value, MemOperand(address, scratch_value));
647 __ Ret(); 675 __ Ret();
648 676
649 __ bind(&non_smi_value); 677 __ bind(&non_smi_value);
650 // Escape to elements kind transition case. 678 // Escape to elements kind transition case.
651 __ CheckFastObjectElements(receiver_map, scratch_value, 679 __ CheckFastObjectElements(receiver_map, scratch_value,
652 &transition_smi_elements); 680 &transition_smi_elements);
653 681
654 // Fast elements array, store the value to the elements backing store. 682 // Fast elements array, store the value to the elements backing store.
655 __ bind(&finish_object_store); 683 __ bind(&finish_object_store);
656 if (increment_length == kIncrementLength) { 684 if (increment_length == kIncrementLength) {
657 // Add 1 to receiver->length. 685 // Add 1 to receiver->length.
658 __ add(scratch_value, key, Operand(Smi::FromInt(1))); 686 __ AddSmiLiteral(scratch_value, key, Smi::FromInt(1), r0);
659 __ str(scratch_value, FieldMemOperand(receiver, JSArray::kLengthOffset)); 687 __ StoreP(scratch_value, FieldMemOperand(receiver, JSArray::kLengthOffset),
688 r0);
660 } 689 }
661 __ add(address, elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); 690 __ addi(address, elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
662 __ add(address, address, Operand::PointerOffsetFromSmiKey(key)); 691 __ SmiToPtrArrayOffset(scratch_value, key);
663 __ str(value, MemOperand(address)); 692 __ StorePUX(value, MemOperand(address, scratch_value));
664 // Update write barrier for the elements array address. 693 // Update write barrier for the elements array address.
665 __ mov(scratch_value, value); // Preserve the value which is returned. 694 __ mr(scratch_value, value); // Preserve the value which is returned.
666 __ RecordWrite(elements, address, scratch_value, kLRHasNotBeenSaved, 695 __ RecordWrite(elements, address, scratch_value, kLRHasNotBeenSaved,
667 kDontSaveFPRegs, EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); 696 kDontSaveFPRegs, EMIT_REMEMBERED_SET, OMIT_SMI_CHECK);
668 __ Ret(); 697 __ Ret();
669 698
670 __ bind(fast_double); 699 __ bind(fast_double);
671 if (check_map == kCheckMap) { 700 if (check_map == kCheckMap) {
672 // Check for fast double array case. If this fails, call through to the 701 // Check for fast double array case. If this fails, call through to the
673 // runtime. 702 // runtime.
674 __ CompareRoot(elements_map, Heap::kFixedDoubleArrayMapRootIndex); 703 __ CompareRoot(elements_map, Heap::kFixedDoubleArrayMapRootIndex);
675 __ b(ne, slow); 704 __ bne(slow);
676 } 705 }
677 706
678 // HOLECHECK: guards "A[i] double hole?" 707 // HOLECHECK: guards "A[i] double hole?"
679 // We have to see if the double version of the hole is present. If so 708 // We have to see if the double version of the hole is present. If so
680 // go to the runtime. 709 // go to the runtime.
681 __ add(address, elements, 710 __ addi(address, elements,
682 Operand((FixedDoubleArray::kHeaderSize + sizeof(kHoleNanLower32)) - 711 Operand((FixedDoubleArray::kHeaderSize + Register::kExponentOffset -
683 kHeapObjectTag)); 712 kHeapObjectTag)));
684 __ ldr(scratch_value, 713 __ SmiToDoubleArrayOffset(scratch_value, key);
685 MemOperand(address, key, LSL, kPointerSizeLog2, PreIndex)); 714 __ lwzx(scratch_value, MemOperand(address, scratch_value));
686 __ cmp(scratch_value, Operand(kHoleNanUpper32)); 715 __ Cmpi(scratch_value, Operand(kHoleNanUpper32), r0);
687 __ b(ne, &fast_double_without_map_check); 716 __ bne(&fast_double_without_map_check);
688 __ JumpIfDictionaryInPrototypeChain(receiver, elements_map, scratch_value, 717 __ JumpIfDictionaryInPrototypeChain(receiver, elements_map, scratch_value,
689 slow); 718 slow);
690 719
691 __ bind(&fast_double_without_map_check); 720 __ bind(&fast_double_without_map_check);
692 __ StoreNumberToDoubleElements(value, key, elements, r3, d0, 721 __ StoreNumberToDoubleElements(value, key, elements, r6, d0,
693 &transition_double_elements); 722 &transition_double_elements);
694 if (increment_length == kIncrementLength) { 723 if (increment_length == kIncrementLength) {
695 // Add 1 to receiver->length. 724 // Add 1 to receiver->length.
696 __ add(scratch_value, key, Operand(Smi::FromInt(1))); 725 __ AddSmiLiteral(scratch_value, key, Smi::FromInt(1), r0);
697 __ str(scratch_value, FieldMemOperand(receiver, JSArray::kLengthOffset)); 726 __ StoreP(scratch_value, FieldMemOperand(receiver, JSArray::kLengthOffset),
727 r0);
698 } 728 }
699 __ Ret(); 729 __ Ret();
700 730
701 __ bind(&transition_smi_elements); 731 __ bind(&transition_smi_elements);
702 // Transition the array appropriately depending on the value type. 732 // Transition the array appropriately depending on the value type.
703 __ ldr(r4, FieldMemOperand(value, HeapObject::kMapOffset)); 733 __ LoadP(r7, FieldMemOperand(value, HeapObject::kMapOffset));
704 __ CompareRoot(r4, Heap::kHeapNumberMapRootIndex); 734 __ CompareRoot(r7, Heap::kHeapNumberMapRootIndex);
705 __ b(ne, &non_double_value); 735 __ bne(&non_double_value);
706 736
707 // Value is a double. Transition FAST_SMI_ELEMENTS -> 737 // Value is a double. Transition FAST_SMI_ELEMENTS ->
708 // FAST_DOUBLE_ELEMENTS and complete the store. 738 // FAST_DOUBLE_ELEMENTS and complete the store.
709 __ LoadTransitionedArrayMapConditional( 739 __ LoadTransitionedArrayMapConditional(
710 FAST_SMI_ELEMENTS, FAST_DOUBLE_ELEMENTS, receiver_map, r4, slow); 740 FAST_SMI_ELEMENTS, FAST_DOUBLE_ELEMENTS, receiver_map, r7, slow);
711 AllocationSiteMode mode = 741 AllocationSiteMode mode =
712 AllocationSite::GetMode(FAST_SMI_ELEMENTS, FAST_DOUBLE_ELEMENTS); 742 AllocationSite::GetMode(FAST_SMI_ELEMENTS, FAST_DOUBLE_ELEMENTS);
713 ElementsTransitionGenerator::GenerateSmiToDouble(masm, receiver, key, value, 743 ElementsTransitionGenerator::GenerateSmiToDouble(masm, receiver, key, value,
714 receiver_map, mode, slow); 744 receiver_map, mode, slow);
715 __ ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset)); 745 __ LoadP(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
716 __ jmp(&fast_double_without_map_check); 746 __ b(&fast_double_without_map_check);
717 747
718 __ bind(&non_double_value); 748 __ bind(&non_double_value);
719 // Value is not a double, FAST_SMI_ELEMENTS -> FAST_ELEMENTS 749 // Value is not a double, FAST_SMI_ELEMENTS -> FAST_ELEMENTS
720 __ LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS, FAST_ELEMENTS, 750 __ LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS, FAST_ELEMENTS,
721 receiver_map, r4, slow); 751 receiver_map, r7, slow);
722 mode = AllocationSite::GetMode(FAST_SMI_ELEMENTS, FAST_ELEMENTS); 752 mode = AllocationSite::GetMode(FAST_SMI_ELEMENTS, FAST_ELEMENTS);
723 ElementsTransitionGenerator::GenerateMapChangeElementsTransition( 753 ElementsTransitionGenerator::GenerateMapChangeElementsTransition(
724 masm, receiver, key, value, receiver_map, mode, slow); 754 masm, receiver, key, value, receiver_map, mode, slow);
725 __ ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset)); 755 __ LoadP(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
726 __ jmp(&finish_object_store); 756 __ b(&finish_object_store);
727 757
728 __ bind(&transition_double_elements); 758 __ bind(&transition_double_elements);
729 // Elements are FAST_DOUBLE_ELEMENTS, but value is an Object that's not a 759 // Elements are FAST_DOUBLE_ELEMENTS, but value is an Object that's not a
730 // HeapNumber. Make sure that the receiver is a Array with FAST_ELEMENTS and 760 // HeapNumber. Make sure that the receiver is a Array with FAST_ELEMENTS and
731 // transition array from FAST_DOUBLE_ELEMENTS to FAST_ELEMENTS 761 // transition array from FAST_DOUBLE_ELEMENTS to FAST_ELEMENTS
732 __ LoadTransitionedArrayMapConditional(FAST_DOUBLE_ELEMENTS, FAST_ELEMENTS, 762 __ LoadTransitionedArrayMapConditional(FAST_DOUBLE_ELEMENTS, FAST_ELEMENTS,
733 receiver_map, r4, slow); 763 receiver_map, r7, slow);
734 mode = AllocationSite::GetMode(FAST_DOUBLE_ELEMENTS, FAST_ELEMENTS); 764 mode = AllocationSite::GetMode(FAST_DOUBLE_ELEMENTS, FAST_ELEMENTS);
735 ElementsTransitionGenerator::GenerateDoubleToObject( 765 ElementsTransitionGenerator::GenerateDoubleToObject(
736 masm, receiver, key, value, receiver_map, mode, slow); 766 masm, receiver, key, value, receiver_map, mode, slow);
737 __ ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset)); 767 __ LoadP(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
738 __ jmp(&finish_object_store); 768 __ b(&finish_object_store);
739 } 769 }
740 770
741 771
742 void KeyedStoreIC::GenerateMegamorphic(MacroAssembler* masm, 772 void KeyedStoreIC::GenerateMegamorphic(MacroAssembler* masm,
743 StrictMode strict_mode) { 773 StrictMode strict_mode) {
744 // ---------- S t a t e -------------- 774 // ---------- S t a t e --------------
745 // -- r0 : value 775 // -- r3 : value
746 // -- r1 : key 776 // -- r4 : key
747 // -- r2 : receiver 777 // -- r5 : receiver
748 // -- lr : return address 778 // -- lr : return address
749 // ----------------------------------- 779 // -----------------------------------
750 Label slow, fast_object, fast_object_grow; 780 Label slow, fast_object, fast_object_grow;
751 Label fast_double, fast_double_grow; 781 Label fast_double, fast_double_grow;
752 Label array, extra, check_if_double_array, maybe_name_key, miss; 782 Label array, extra, check_if_double_array, maybe_name_key, miss;
753 783
754 // Register usage. 784 // Register usage.
755 Register value = StoreDescriptor::ValueRegister(); 785 Register value = StoreDescriptor::ValueRegister();
756 Register key = StoreDescriptor::NameRegister(); 786 Register key = StoreDescriptor::NameRegister();
757 Register receiver = StoreDescriptor::ReceiverRegister(); 787 Register receiver = StoreDescriptor::ReceiverRegister();
758 DCHECK(receiver.is(r1)); 788 DCHECK(receiver.is(r4));
759 DCHECK(key.is(r2)); 789 DCHECK(key.is(r5));
760 DCHECK(value.is(r0)); 790 DCHECK(value.is(r3));
761 Register receiver_map = r3; 791 Register receiver_map = r6;
762 Register elements_map = r6; 792 Register elements_map = r9;
763 Register elements = r9; // Elements array of the receiver. 793 Register elements = r10; // Elements array of the receiver.
764 // r4 and r5 are used as general scratch registers. 794 // r7 and r8 are used as general scratch registers.
765 795
766 // Check that the key is a smi. 796 // Check that the key is a smi.
767 __ JumpIfNotSmi(key, &maybe_name_key); 797 __ JumpIfNotSmi(key, &maybe_name_key);
768 // Check that the object isn't a smi. 798 // Check that the object isn't a smi.
769 __ JumpIfSmi(receiver, &slow); 799 __ JumpIfSmi(receiver, &slow);
770 // Get the map of the object. 800 // Get the map of the object.
771 __ ldr(receiver_map, FieldMemOperand(receiver, HeapObject::kMapOffset)); 801 __ LoadP(receiver_map, FieldMemOperand(receiver, HeapObject::kMapOffset));
772 // Check that the receiver does not require access checks and is not observed. 802 // Check that the receiver does not require access checks and is not observed.
773 // The generic stub does not perform map checks or handle observed objects. 803 // The generic stub does not perform map checks or handle observed objects.
774 __ ldrb(ip, FieldMemOperand(receiver_map, Map::kBitFieldOffset)); 804 __ lbz(ip, FieldMemOperand(receiver_map, Map::kBitFieldOffset));
775 __ tst(ip, Operand(1 << Map::kIsAccessCheckNeeded | 1 << Map::kIsObserved)); 805 __ andi(r0, ip,
776 __ b(ne, &slow); 806 Operand(1 << Map::kIsAccessCheckNeeded | 1 << Map::kIsObserved));
807 __ bne(&slow, cr0);
777 // Check if the object is a JS array or not. 808 // Check if the object is a JS array or not.
778 __ ldrb(r4, FieldMemOperand(receiver_map, Map::kInstanceTypeOffset)); 809 __ lbz(r7, FieldMemOperand(receiver_map, Map::kInstanceTypeOffset));
779 __ cmp(r4, Operand(JS_ARRAY_TYPE)); 810 __ cmpi(r7, Operand(JS_ARRAY_TYPE));
780 __ b(eq, &array); 811 __ beq(&array);
781 // Check that the object is some kind of JSObject. 812 // Check that the object is some kind of JSObject.
782 __ cmp(r4, Operand(FIRST_JS_OBJECT_TYPE)); 813 __ cmpi(r7, Operand(FIRST_JS_OBJECT_TYPE));
783 __ b(lt, &slow); 814 __ blt(&slow);
784 815
785 // Object case: Check key against length in the elements array. 816 // Object case: Check key against length in the elements array.
786 __ ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset)); 817 __ LoadP(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
787 // Check array bounds. Both the key and the length of FixedArray are smis. 818 // Check array bounds. Both the key and the length of FixedArray are smis.
788 __ ldr(ip, FieldMemOperand(elements, FixedArray::kLengthOffset)); 819 __ LoadP(ip, FieldMemOperand(elements, FixedArray::kLengthOffset));
789 __ cmp(key, Operand(ip)); 820 __ cmpl(key, ip);
790 __ b(lo, &fast_object); 821 __ blt(&fast_object);
791 822
792 // Slow case, handle jump to runtime. 823 // Slow case, handle jump to runtime.
793 __ bind(&slow); 824 __ bind(&slow);
794 // Entry registers are intact. 825 // Entry registers are intact.
795 // r0: value. 826 // r3: value.
796 // r1: key. 827 // r4: key.
797 // r2: receiver. 828 // r5: receiver.
798 PropertyICCompiler::GenerateRuntimeSetProperty(masm, strict_mode); 829 PropertyICCompiler::GenerateRuntimeSetProperty(masm, strict_mode);
799 // Never returns to here. 830 // Never returns to here.
800 831
801 __ bind(&maybe_name_key); 832 __ bind(&maybe_name_key);
802 __ ldr(r4, FieldMemOperand(key, HeapObject::kMapOffset)); 833 __ LoadP(r7, FieldMemOperand(key, HeapObject::kMapOffset));
803 __ ldrb(r4, FieldMemOperand(r4, Map::kInstanceTypeOffset)); 834 __ lbz(r7, FieldMemOperand(r7, Map::kInstanceTypeOffset));
804 __ JumpIfNotUniqueNameInstanceType(r4, &slow); 835 __ JumpIfNotUniqueNameInstanceType(r7, &slow);
805 Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( 836 Code::Flags flags = Code::RemoveTypeAndHolderFromFlags(
806 Code::ComputeHandlerFlags(Code::STORE_IC)); 837 Code::ComputeHandlerFlags(Code::STORE_IC));
807 masm->isolate()->stub_cache()->GenerateProbe(masm, flags, false, receiver, 838 masm->isolate()->stub_cache()->GenerateProbe(masm, flags, false, receiver,
808 key, r3, r4, r5, r6); 839 key, r6, r7, r8, r9);
809 // Cache miss. 840 // Cache miss.
810 __ b(&miss); 841 __ b(&miss);
811 842
812 // Extra capacity case: Check if there is extra capacity to 843 // Extra capacity case: Check if there is extra capacity to
813 // perform the store and update the length. Used for adding one 844 // perform the store and update the length. Used for adding one
814 // element to the array by writing to array[array.length]. 845 // element to the array by writing to array[array.length].
815 __ bind(&extra); 846 __ bind(&extra);
816 // Condition code from comparing key and array length is still available. 847 // Condition code from comparing key and array length is still available.
817 __ b(ne, &slow); // Only support writing to writing to array[array.length]. 848 __ bne(&slow); // Only support writing to writing to array[array.length].
818 // Check for room in the elements backing store. 849 // Check for room in the elements backing store.
819 // Both the key and the length of FixedArray are smis. 850 // Both the key and the length of FixedArray are smis.
820 __ ldr(ip, FieldMemOperand(elements, FixedArray::kLengthOffset)); 851 __ LoadP(ip, FieldMemOperand(elements, FixedArray::kLengthOffset));
821 __ cmp(key, Operand(ip)); 852 __ cmpl(key, ip);
822 __ b(hs, &slow); 853 __ bge(&slow);
823 __ ldr(elements_map, FieldMemOperand(elements, HeapObject::kMapOffset)); 854 __ LoadP(elements_map, FieldMemOperand(elements, HeapObject::kMapOffset));
824 __ cmp(elements_map, Operand(masm->isolate()->factory()->fixed_array_map())); 855 __ mov(ip, Operand(masm->isolate()->factory()->fixed_array_map()));
825 __ b(ne, &check_if_double_array); 856 __ cmp(elements_map, ip); // PPC - I think I can re-use ip here
826 __ jmp(&fast_object_grow); 857 __ bne(&check_if_double_array);
858 __ b(&fast_object_grow);
827 859
828 __ bind(&check_if_double_array); 860 __ bind(&check_if_double_array);
829 __ cmp(elements_map, 861 __ mov(ip, Operand(masm->isolate()->factory()->fixed_double_array_map()));
830 Operand(masm->isolate()->factory()->fixed_double_array_map())); 862 __ cmp(elements_map, ip); // PPC - another ip re-use
831 __ b(ne, &slow); 863 __ bne(&slow);
832 __ jmp(&fast_double_grow); 864 __ b(&fast_double_grow);
833 865
834 // Array case: Get the length and the elements array from the JS 866 // Array case: Get the length and the elements array from the JS
835 // array. Check that the array is in fast mode (and writable); if it 867 // array. Check that the array is in fast mode (and writable); if it
836 // is the length is always a smi. 868 // is the length is always a smi.
837 __ bind(&array); 869 __ bind(&array);
838 __ ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset)); 870 __ LoadP(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
839 871
840 // Check the key against the length in the array. 872 // Check the key against the length in the array.
841 __ ldr(ip, FieldMemOperand(receiver, JSArray::kLengthOffset)); 873 __ LoadP(ip, FieldMemOperand(receiver, JSArray::kLengthOffset));
842 __ cmp(key, Operand(ip)); 874 __ cmpl(key, ip);
843 __ b(hs, &extra); 875 __ bge(&extra);
844 876
845 KeyedStoreGenerateMegamorphicHelper( 877 KeyedStoreGenerateMegamorphicHelper(
846 masm, &fast_object, &fast_double, &slow, kCheckMap, kDontIncrementLength, 878 masm, &fast_object, &fast_double, &slow, kCheckMap, kDontIncrementLength,
847 value, key, receiver, receiver_map, elements_map, elements); 879 value, key, receiver, receiver_map, elements_map, elements);
848 KeyedStoreGenerateMegamorphicHelper(masm, &fast_object_grow, 880 KeyedStoreGenerateMegamorphicHelper(masm, &fast_object_grow,
849 &fast_double_grow, &slow, kDontCheckMap, 881 &fast_double_grow, &slow, kDontCheckMap,
850 kIncrementLength, value, key, receiver, 882 kIncrementLength, value, key, receiver,
851 receiver_map, elements_map, elements); 883 receiver_map, elements_map, elements);
852
853 __ bind(&miss); 884 __ bind(&miss);
854 GenerateMiss(masm); 885 GenerateMiss(masm);
855 } 886 }
856 887
857 888
858 void StoreIC::GenerateMegamorphic(MacroAssembler* masm) { 889 void StoreIC::GenerateMegamorphic(MacroAssembler* masm) {
859 Register receiver = StoreDescriptor::ReceiverRegister(); 890 Register receiver = StoreDescriptor::ReceiverRegister();
860 Register name = StoreDescriptor::NameRegister(); 891 Register name = StoreDescriptor::NameRegister();
861 DCHECK(receiver.is(r1)); 892 DCHECK(receiver.is(r4));
862 DCHECK(name.is(r2)); 893 DCHECK(name.is(r5));
863 DCHECK(StoreDescriptor::ValueRegister().is(r0)); 894 DCHECK(StoreDescriptor::ValueRegister().is(r3));
864 895
865 // Get the receiver from the stack and probe the stub cache. 896 // Get the receiver from the stack and probe the stub cache.
866 Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( 897 Code::Flags flags = Code::RemoveTypeAndHolderFromFlags(
867 Code::ComputeHandlerFlags(Code::STORE_IC)); 898 Code::ComputeHandlerFlags(Code::STORE_IC));
868 899
869 masm->isolate()->stub_cache()->GenerateProbe(masm, flags, false, receiver, 900 masm->isolate()->stub_cache()->GenerateProbe(masm, flags, false, receiver,
870 name, r3, r4, r5, r6); 901 name, r6, r7, r8, r9);
871 902
872 // Cache miss: Jump to runtime. 903 // Cache miss: Jump to runtime.
873 GenerateMiss(masm); 904 GenerateMiss(masm);
874 } 905 }
875 906
876 907
877 void StoreIC::GenerateMiss(MacroAssembler* masm) { 908 void StoreIC::GenerateMiss(MacroAssembler* masm) {
878 __ Push(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister(), 909 __ Push(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister(),
879 StoreDescriptor::ValueRegister()); 910 StoreDescriptor::ValueRegister());
880 911
881 // Perform tail call to the entry. 912 // Perform tail call to the entry.
882 ExternalReference ref = 913 ExternalReference ref =
883 ExternalReference(IC_Utility(kStoreIC_Miss), masm->isolate()); 914 ExternalReference(IC_Utility(kStoreIC_Miss), masm->isolate());
884 __ TailCallExternalReference(ref, 3, 1); 915 __ TailCallExternalReference(ref, 3, 1);
885 } 916 }
886 917
887 918
888 void StoreIC::GenerateNormal(MacroAssembler* masm) { 919 void StoreIC::GenerateNormal(MacroAssembler* masm) {
889 Label miss; 920 Label miss;
890 Register receiver = StoreDescriptor::ReceiverRegister(); 921 Register receiver = StoreDescriptor::ReceiverRegister();
891 Register name = StoreDescriptor::NameRegister(); 922 Register name = StoreDescriptor::NameRegister();
892 Register value = StoreDescriptor::ValueRegister(); 923 Register value = StoreDescriptor::ValueRegister();
893 Register dictionary = r3; 924 Register dictionary = r6;
894 DCHECK(receiver.is(r1)); 925 DCHECK(receiver.is(r4));
895 DCHECK(name.is(r2)); 926 DCHECK(name.is(r5));
896 DCHECK(value.is(r0)); 927 DCHECK(value.is(r3));
897 928
898 __ ldr(dictionary, FieldMemOperand(receiver, JSObject::kPropertiesOffset)); 929 __ LoadP(dictionary, FieldMemOperand(receiver, JSObject::kPropertiesOffset));
899 930
900 GenerateDictionaryStore(masm, &miss, dictionary, name, value, r4, r5); 931 GenerateDictionaryStore(masm, &miss, dictionary, name, value, r7, r8);
901 Counters* counters = masm->isolate()->counters(); 932 Counters* counters = masm->isolate()->counters();
902 __ IncrementCounter(counters->store_normal_hit(), 1, r4, r5); 933 __ IncrementCounter(counters->store_normal_hit(), 1, r7, r8);
903 __ Ret(); 934 __ Ret();
904 935
905 __ bind(&miss); 936 __ bind(&miss);
906 __ IncrementCounter(counters->store_normal_miss(), 1, r4, r5); 937 __ IncrementCounter(counters->store_normal_miss(), 1, r7, r8);
907 GenerateMiss(masm); 938 GenerateMiss(masm);
908 } 939 }
909 940
910 941
911 #undef __ 942 #undef __
912 943
913 944
914 Condition CompareIC::ComputeCondition(Token::Value op) { 945 Condition CompareIC::ComputeCondition(Token::Value op) {
915 switch (op) { 946 switch (op) {
916 case Token::EQ_STRICT: 947 case Token::EQ_STRICT:
(...skipping 19 matching lines...) Expand all
936 Address cmp_instruction_address = 967 Address cmp_instruction_address =
937 Assembler::return_address_from_call_start(address); 968 Assembler::return_address_from_call_start(address);
938 969
939 // If the instruction following the call is not a cmp rx, #yyy, nothing 970 // If the instruction following the call is not a cmp rx, #yyy, nothing
940 // was inlined. 971 // was inlined.
941 Instr instr = Assembler::instr_at(cmp_instruction_address); 972 Instr instr = Assembler::instr_at(cmp_instruction_address);
942 return Assembler::IsCmpImmediate(instr); 973 return Assembler::IsCmpImmediate(instr);
943 } 974 }
944 975
945 976
977 //
978 // This code is paired with the JumpPatchSite class in full-codegen-ppc.cc
979 //
946 void PatchInlinedSmiCode(Address address, InlinedSmiCheck check) { 980 void PatchInlinedSmiCode(Address address, InlinedSmiCheck check) {
947 Address cmp_instruction_address = 981 Address cmp_instruction_address =
948 Assembler::return_address_from_call_start(address); 982 Assembler::return_address_from_call_start(address);
949 983
950 // If the instruction following the call is not a cmp rx, #yyy, nothing 984 // If the instruction following the call is not a cmp rx, #yyy, nothing
951 // was inlined. 985 // was inlined.
952 Instr instr = Assembler::instr_at(cmp_instruction_address); 986 Instr instr = Assembler::instr_at(cmp_instruction_address);
953 if (!Assembler::IsCmpImmediate(instr)) { 987 if (!Assembler::IsCmpImmediate(instr)) {
954 return; 988 return;
955 } 989 }
956 990
957 // The delta to the start of the map check instruction and the 991 // The delta to the start of the map check instruction and the
958 // condition code uses at the patched jump. 992 // condition code uses at the patched jump.
959 int delta = Assembler::GetCmpImmediateRawImmediate(instr); 993 int delta = Assembler::GetCmpImmediateRawImmediate(instr);
960 delta += Assembler::GetCmpImmediateRegister(instr).code() * kOff12Mask; 994 delta += Assembler::GetCmpImmediateRegister(instr).code() * kOff16Mask;
961 // If the delta is 0 the instruction is cmp r0, #0 which also signals that 995 // If the delta is 0 the instruction is cmp r0, #0 which also signals that
962 // nothing was inlined. 996 // nothing was inlined.
963 if (delta == 0) { 997 if (delta == 0) {
964 return; 998 return;
965 } 999 }
966 1000
967 if (FLAG_trace_ic) { 1001 if (FLAG_trace_ic) {
968 PrintF("[ patching ic at %p, cmp=%p, delta=%d\n", address, 1002 PrintF("[ patching ic at %p, cmp=%p, delta=%d\n", address,
969 cmp_instruction_address, delta); 1003 cmp_instruction_address, delta);
970 } 1004 }
971 1005
972 Address patch_address = 1006 Address patch_address =
973 cmp_instruction_address - delta * Instruction::kInstrSize; 1007 cmp_instruction_address - delta * Instruction::kInstrSize;
974 Instr instr_at_patch = Assembler::instr_at(patch_address); 1008 Instr instr_at_patch = Assembler::instr_at(patch_address);
975 Instr branch_instr = 1009 Instr branch_instr =
976 Assembler::instr_at(patch_address + Instruction::kInstrSize); 1010 Assembler::instr_at(patch_address + Instruction::kInstrSize);
977 // This is patching a conditional "jump if not smi/jump if smi" site. 1011 // This is patching a conditional "jump if not smi/jump if smi" site.
978 // Enabling by changing from 1012 // Enabling by changing from
979 // cmp rx, rx 1013 // cmp cr0, rx, rx
980 // b eq/ne, <target>
981 // to 1014 // to
982 // tst rx, #kSmiTagMask 1015 // rlwinm(r0, value, 0, 31, 31, SetRC);
983 // b ne/eq, <target> 1016 // bc(label, BT/BF, 2)
984 // and vice-versa to be disabled again. 1017 // and vice-versa to be disabled again.
985 CodePatcher patcher(patch_address, 2); 1018 CodePatcher patcher(patch_address, 2);
986 Register reg = Assembler::GetRn(instr_at_patch); 1019 Register reg = Assembler::GetRA(instr_at_patch);
987 if (check == ENABLE_INLINED_SMI_CHECK) { 1020 if (check == ENABLE_INLINED_SMI_CHECK) {
988 DCHECK(Assembler::IsCmpRegister(instr_at_patch)); 1021 DCHECK(Assembler::IsCmpRegister(instr_at_patch));
989 DCHECK_EQ(Assembler::GetRn(instr_at_patch).code(), 1022 DCHECK_EQ(Assembler::GetRA(instr_at_patch).code(),
990 Assembler::GetRm(instr_at_patch).code()); 1023 Assembler::GetRB(instr_at_patch).code());
991 patcher.masm()->tst(reg, Operand(kSmiTagMask)); 1024 patcher.masm()->TestIfSmi(reg, r0);
992 } else { 1025 } else {
993 DCHECK(check == DISABLE_INLINED_SMI_CHECK); 1026 DCHECK(check == DISABLE_INLINED_SMI_CHECK);
994 DCHECK(Assembler::IsTstImmediate(instr_at_patch)); 1027 #if V8_TARGET_ARCH_PPC64
995 patcher.masm()->cmp(reg, reg); 1028 DCHECK(Assembler::IsRldicl(instr_at_patch));
1029 #else
1030 DCHECK(Assembler::IsRlwinm(instr_at_patch));
1031 #endif
1032 patcher.masm()->cmp(reg, reg, cr0);
996 } 1033 }
997 DCHECK(Assembler::IsBranch(branch_instr)); 1034 DCHECK(Assembler::IsBranch(branch_instr));
1035
1036 // Invert the logic of the branch
998 if (Assembler::GetCondition(branch_instr) == eq) { 1037 if (Assembler::GetCondition(branch_instr) == eq) {
999 patcher.EmitCondition(ne); 1038 patcher.EmitCondition(ne);
1000 } else { 1039 } else {
1001 DCHECK(Assembler::GetCondition(branch_instr) == ne); 1040 DCHECK(Assembler::GetCondition(branch_instr) == ne);
1002 patcher.EmitCondition(eq); 1041 patcher.EmitCondition(eq);
1003 } 1042 }
1004 } 1043 }
1005 } 1044 }
1006 } // namespace v8::internal 1045 } // namespace v8::internal
1007 1046
1008 #endif // V8_TARGET_ARCH_ARM 1047 #endif // V8_TARGET_ARCH_PPC
OLDNEW
« no previous file with comments | « src/ic/ppc/ic-compiler-ppc.cc ('k') | src/ic/ppc/stub-cache-ppc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698