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

Side by Side Diff: src/arm/codegen-arm.cc

Issue 9310117: Implement KeyedStoreICs to grow arrays on out-of-bound stores. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: nits Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 void ElementsTransitionGenerator::GenerateSmiOnlyToDouble( 83 void ElementsTransitionGenerator::GenerateSmiOnlyToDouble(
84 MacroAssembler* masm, Label* fail) { 84 MacroAssembler* masm, Label* fail) {
85 // ----------- S t a t e ------------- 85 // ----------- S t a t e -------------
86 // -- r0 : value 86 // -- r0 : value
87 // -- r1 : key 87 // -- r1 : key
88 // -- r2 : receiver 88 // -- r2 : receiver
89 // -- lr : return address 89 // -- lr : return address
90 // -- r3 : target map, scratch for subsequent call 90 // -- r3 : target map, scratch for subsequent call
91 // -- r4 : scratch (elements) 91 // -- r4 : scratch (elements)
92 // ----------------------------------- 92 // -----------------------------------
93 Label loop, entry, convert_hole, gc_required; 93 Label loop, entry, convert_hole, gc_required, only_change_map, done;
94 bool vfp3_supported = CpuFeatures::IsSupported(VFP3); 94 bool vfp3_supported = CpuFeatures::IsSupported(VFP3);
95
96 // Check for empty arrays, which only require a map transition and no changes
97 // to the backing store.
98 __ ldr(r4, FieldMemOperand(r2, JSObject::kElementsOffset));
99 __ LoadRoot(r5, Heap::kEmptyFixedArrayRootIndex);
100 __ cmp(r4, r5);
Vyacheslav Egorov (Chromium) 2012/02/10 00:19:18 CompareRoot(r4, Heap::kEmptyFixedArrayRootIndex) ?
danno 2012/02/10 12:25:34 Done.
101 __ b(eq, &only_change_map);
102
95 __ push(lr); 103 __ push(lr);
96
97 __ ldr(r4, FieldMemOperand(r2, JSObject::kElementsOffset));
98 __ ldr(r5, FieldMemOperand(r4, FixedArray::kLengthOffset)); 104 __ ldr(r5, FieldMemOperand(r4, FixedArray::kLengthOffset));
99 // r4: source FixedArray 105 // r4: source FixedArray
100 // r5: number of elements (smi-tagged) 106 // r5: number of elements (smi-tagged)
101 107
102 // Allocate new FixedDoubleArray. 108 // Allocate new FixedDoubleArray.
103 __ mov(lr, Operand(FixedDoubleArray::kHeaderSize)); 109 __ mov(lr, Operand(FixedDoubleArray::kHeaderSize));
104 __ add(lr, lr, Operand(r5, LSL, 2)); 110 __ add(lr, lr, Operand(r5, LSL, 2));
105 __ AllocateInNewSpace(lr, r6, r7, r9, &gc_required, NO_ALLOCATION_FLAGS); 111 __ AllocateInNewSpace(lr, r6, r7, r9, &gc_required, NO_ALLOCATION_FLAGS);
106 // r6: destination FixedDoubleArray, not tagged as heap object 112 // r6: destination FixedDoubleArray, not tagged as heap object
107 // Set destination FixedDoubleArray's length and map. 113 // Set destination FixedDoubleArray's length and map.
108 __ LoadRoot(r9, Heap::kFixedDoubleArrayMapRootIndex); 114 __ LoadRoot(r9, Heap::kFixedDoubleArrayMapRootIndex);
109 __ str(r5, MemOperand(r6, FixedDoubleArray::kLengthOffset)); 115 __ str(r5, MemOperand(r6, FixedDoubleArray::kLengthOffset));
110 __ str(r9, MemOperand(r6, HeapObject::kMapOffset)); 116 __ str(r9, MemOperand(r6, HeapObject::kMapOffset));
111 // Update receiver's map. 117 // Update receiver's map.
112 118
113 __ str(r3, FieldMemOperand(r2, HeapObject::kMapOffset)); 119 __ str(r3, FieldMemOperand(r2, HeapObject::kMapOffset));
114 __ RecordWriteField(r2, 120 __ RecordWriteField(r2,
115 HeapObject::kMapOffset, 121 HeapObject::kMapOffset,
116 r3, 122 r3,
117 r9, 123 r9,
118 kLRHasBeenSaved, 124 kLRHasBeenSaved,
119 kDontSaveFPRegs, 125 kDontSaveFPRegs,
120 EMIT_REMEMBERED_SET, 126 EMIT_REMEMBERED_SET,
Vyacheslav Egorov (Chromium) 2012/02/09 16:29:19 OMIT_REMEMBERED_SET (maps are never in new space).
danno 2012/02/10 12:25:34 Done.
121 OMIT_SMI_CHECK); 127 OMIT_SMI_CHECK);
122 // Replace receiver's backing store with newly created FixedDoubleArray. 128 // Replace receiver's backing store with newly created FixedDoubleArray.
123 __ add(r3, r6, Operand(kHeapObjectTag)); 129 __ add(r3, r6, Operand(kHeapObjectTag));
124 __ str(r3, FieldMemOperand(r2, JSObject::kElementsOffset)); 130 __ str(r3, FieldMemOperand(r2, JSObject::kElementsOffset));
125 __ RecordWriteField(r2, 131 __ RecordWriteField(r2,
126 JSObject::kElementsOffset, 132 JSObject::kElementsOffset,
127 r3, 133 r3,
128 r9, 134 r9,
129 kLRHasBeenSaved, 135 kLRHasBeenSaved,
130 kDontSaveFPRegs, 136 kDontSaveFPRegs,
131 EMIT_REMEMBERED_SET, 137 EMIT_REMEMBERED_SET,
132 OMIT_SMI_CHECK); 138 OMIT_SMI_CHECK);
133 139
134 // Prepare for conversion loop. 140 // Prepare for conversion loop.
135 __ add(r3, r4, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); 141 __ add(r3, r4, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
136 __ add(r7, r6, Operand(FixedDoubleArray::kHeaderSize)); 142 __ add(r7, r6, Operand(FixedDoubleArray::kHeaderSize));
137 __ add(r6, r7, Operand(r5, LSL, 2)); 143 __ add(r6, r7, Operand(r5, LSL, 2));
138 __ mov(r4, Operand(kHoleNanLower32)); 144 __ mov(r4, Operand(kHoleNanLower32));
139 __ mov(r5, Operand(kHoleNanUpper32)); 145 __ mov(r5, Operand(kHoleNanUpper32));
140 // r3: begin of source FixedArray element fields, not tagged 146 // r3: begin of source FixedArray element fields, not tagged
141 // r4: kHoleNanLower32 147 // r4: kHoleNanLower32
142 // r5: kHoleNanUpper32 148 // r5: kHoleNanUpper32
143 // r6: end of destination FixedDoubleArray, not tagged 149 // r6: end of destination FixedDoubleArray, not tagged
144 // r7: begin of FixedDoubleArray element fields, not tagged 150 // r7: begin of FixedDoubleArray element fields, not tagged
145 if (!vfp3_supported) __ Push(r1, r0); 151 if (!vfp3_supported) __ Push(r1, r0);
146 152
147 __ b(&entry); 153 __ b(&entry);
148 154
155 __ bind(&only_change_map);
156 __ str(r3, FieldMemOperand(r2, HeapObject::kMapOffset));
157 __ RecordWriteField(r2,
158 HeapObject::kMapOffset,
159 r3,
160 r9,
161 kLRHasBeenSaved,
162 kDontSaveFPRegs,
163 EMIT_REMEMBERED_SET,
Vyacheslav Egorov (Chromium) 2012/02/09 16:29:19 OMIT_REMEMBERED_SET (maps are never in new space).
danno 2012/02/10 12:25:34 Done.
164 OMIT_SMI_CHECK);
165 __ b(&done);
166
149 // Call into runtime if GC is required. 167 // Call into runtime if GC is required.
150 __ bind(&gc_required); 168 __ bind(&gc_required);
151 __ pop(lr); 169 __ pop(lr);
152 __ b(fail); 170 __ b(fail);
153 171
154 // Convert and copy elements. 172 // Convert and copy elements.
155 __ bind(&loop); 173 __ bind(&loop);
156 __ ldr(r9, MemOperand(r3, 4, PostIndex)); 174 __ ldr(r9, MemOperand(r3, 4, PostIndex));
157 // r9: current element 175 // r9: current element
158 __ UntagAndJumpIfNotSmi(r9, r9, &convert_hole); 176 __ UntagAndJumpIfNotSmi(r9, r9, &convert_hole);
(...skipping 28 matching lines...) Expand all
187 __ Assert(eq, "object found in smi-only array"); 205 __ Assert(eq, "object found in smi-only array");
188 } 206 }
189 __ Strd(r4, r5, MemOperand(r7, 8, PostIndex)); 207 __ Strd(r4, r5, MemOperand(r7, 8, PostIndex));
190 208
191 __ bind(&entry); 209 __ bind(&entry);
192 __ cmp(r7, r6); 210 __ cmp(r7, r6);
193 __ b(lt, &loop); 211 __ b(lt, &loop);
194 212
195 if (!vfp3_supported) __ Pop(r1, r0); 213 if (!vfp3_supported) __ Pop(r1, r0);
196 __ pop(lr); 214 __ pop(lr);
215 __ bind(&done);
197 } 216 }
198 217
199 218
200 void ElementsTransitionGenerator::GenerateDoubleToObject( 219 void ElementsTransitionGenerator::GenerateDoubleToObject(
201 MacroAssembler* masm, Label* fail) { 220 MacroAssembler* masm, Label* fail) {
202 // ----------- S t a t e ------------- 221 // ----------- S t a t e -------------
203 // -- r0 : value 222 // -- r0 : value
204 // -- r1 : key 223 // -- r1 : key
205 // -- r2 : receiver 224 // -- r2 : receiver
206 // -- lr : return address 225 // -- lr : return address
207 // -- r3 : target map, scratch for subsequent call 226 // -- r3 : target map, scratch for subsequent call
208 // -- r4 : scratch (elements) 227 // -- r4 : scratch (elements)
209 // ----------------------------------- 228 // -----------------------------------
210 Label entry, loop, convert_hole, gc_required; 229 Label entry, loop, convert_hole, gc_required, only_change_map;
230
231 // Check for empty arrays, which only require a map transition and no changes
232 // to the backing store.
233 __ ldr(r4, FieldMemOperand(r2, JSObject::kElementsOffset));
234 __ LoadRoot(r5, Heap::kEmptyFixedArrayRootIndex);
235 __ cmp(r4, r5);
Vyacheslav Egorov (Chromium) 2012/02/10 00:19:18 CompareRoot?
danno 2012/02/10 12:25:34 Done.
236 __ b(eq, &only_change_map);
211 237
212 __ push(lr); 238 __ push(lr);
213 __ ldr(r4, FieldMemOperand(r2, JSObject::kElementsOffset));
214 __ Push(r3, r2, r1, r0); 239 __ Push(r3, r2, r1, r0);
215 __ ldr(r5, FieldMemOperand(r4, FixedArray::kLengthOffset)); 240 __ ldr(r5, FieldMemOperand(r4, FixedArray::kLengthOffset));
216 // r4: source FixedDoubleArray 241 // r4: source FixedDoubleArray
217 // r5: number of elements (smi-tagged) 242 // r5: number of elements (smi-tagged)
218 243
219 // Allocate new FixedArray. 244 // Allocate new FixedArray.
220 __ mov(r0, Operand(FixedDoubleArray::kHeaderSize)); 245 __ mov(r0, Operand(FixedDoubleArray::kHeaderSize));
221 __ add(r0, r0, Operand(r5, LSL, 1)); 246 __ add(r0, r0, Operand(r5, LSL, 1));
222 __ AllocateInNewSpace(r0, r6, r7, r9, &gc_required, NO_ALLOCATION_FLAGS); 247 __ AllocateInNewSpace(r0, r6, r7, r9, &gc_required, NO_ALLOCATION_FLAGS);
223 // r6: destination FixedArray, not tagged as heap object 248 // r6: destination FixedArray, not tagged as heap object
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 298
274 // Replace the-hole NaN with the-hole pointer. 299 // Replace the-hole NaN with the-hole pointer.
275 __ bind(&convert_hole); 300 __ bind(&convert_hole);
276 __ str(r7, MemOperand(r3, 4, PostIndex)); 301 __ str(r7, MemOperand(r3, 4, PostIndex));
277 302
278 __ bind(&entry); 303 __ bind(&entry);
279 __ cmp(r3, r5); 304 __ cmp(r3, r5);
280 __ b(lt, &loop); 305 __ b(lt, &loop);
281 306
282 __ Pop(r3, r2, r1, r0); 307 __ Pop(r3, r2, r1, r0);
283 // Update receiver's map.
284 __ str(r3, FieldMemOperand(r2, HeapObject::kMapOffset));
285 __ RecordWriteField(r2,
286 HeapObject::kMapOffset,
287 r3,
288 r9,
289 kLRHasBeenSaved,
290 kDontSaveFPRegs,
291 EMIT_REMEMBERED_SET,
292 OMIT_SMI_CHECK);
293 // Replace receiver's backing store with newly created and filled FixedArray. 308 // Replace receiver's backing store with newly created and filled FixedArray.
294 __ str(r6, FieldMemOperand(r2, JSObject::kElementsOffset)); 309 __ str(r6, FieldMemOperand(r2, JSObject::kElementsOffset));
295 __ RecordWriteField(r2, 310 __ RecordWriteField(r2,
296 JSObject::kElementsOffset, 311 JSObject::kElementsOffset,
297 r6, 312 r6,
298 r9, 313 r9,
299 kLRHasBeenSaved, 314 kLRHasBeenSaved,
300 kDontSaveFPRegs, 315 kDontSaveFPRegs,
301 EMIT_REMEMBERED_SET, 316 EMIT_REMEMBERED_SET,
302 OMIT_SMI_CHECK); 317 OMIT_SMI_CHECK);
303 __ pop(lr); 318 __ pop(lr);
319
320 __ bind(&only_change_map);
321 // Update receiver's map.
322 __ str(r3, FieldMemOperand(r2, HeapObject::kMapOffset));
323 __ RecordWriteField(r2,
324 HeapObject::kMapOffset,
325 r3,
326 r9,
327 kLRHasNotBeenSaved,
328 kDontSaveFPRegs,
329 EMIT_REMEMBERED_SET,
Vyacheslav Egorov (Chromium) 2012/02/09 16:29:19 OMIT_
danno 2012/02/10 12:25:34 Done.
330 OMIT_SMI_CHECK);
304 } 331 }
305 332
306 333
307 void StringCharLoadGenerator::Generate(MacroAssembler* masm, 334 void StringCharLoadGenerator::Generate(MacroAssembler* masm,
308 Register string, 335 Register string,
309 Register index, 336 Register index,
310 Register result, 337 Register result,
311 Label* call_runtime) { 338 Label* call_runtime) {
312 // Fetch the instance type of the receiver into result register. 339 // Fetch the instance type of the receiver into result register.
313 __ ldr(result, FieldMemOperand(string, HeapObject::kMapOffset)); 340 __ ldr(result, FieldMemOperand(string, HeapObject::kMapOffset));
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 // Ascii string. 415 // Ascii string.
389 __ ldrb(result, MemOperand(string, index)); 416 __ ldrb(result, MemOperand(string, index));
390 __ bind(&done); 417 __ bind(&done);
391 } 418 }
392 419
393 #undef __ 420 #undef __
394 421
395 } } // namespace v8::internal 422 } } // namespace v8::internal
396 423
397 #endif // V8_TARGET_ARCH_ARM 424 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/code-stubs-arm.cc ('k') | src/arm/stub-cache-arm.cc » ('j') | src/arm/stub-cache-arm.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698