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

Side by Side Diff: src/x64/codegen-x64.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: Add missing WB stub 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
« no previous file with comments | « src/x64/code-stubs-x64.cc ('k') | src/x64/stub-cache-x64.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 2011 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
11 // with the distribution. 11 // with the distribution.
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 void ElementsTransitionGenerator::GenerateSmiOnlyToDouble( 175 void ElementsTransitionGenerator::GenerateSmiOnlyToDouble(
176 MacroAssembler* masm, Label* fail) { 176 MacroAssembler* masm, Label* fail) {
177 // ----------- S t a t e ------------- 177 // ----------- S t a t e -------------
178 // -- rax : value 178 // -- rax : value
179 // -- rbx : target map 179 // -- rbx : target map
180 // -- rcx : key 180 // -- rcx : key
181 // -- rdx : receiver 181 // -- rdx : receiver
182 // -- rsp[0] : return address 182 // -- rsp[0] : return address
183 // ----------------------------------- 183 // -----------------------------------
184 // The fail label is not actually used since we do not allocate. 184 // The fail label is not actually used since we do not allocate.
185 Label allocated, cow_array; 185 Label allocated, cow_array, only_change_map, done;
186
187 // Check for empty arrays, which only require a map transition and no changes
188 // to the backing store.
189 __ movq(r8, FieldOperand(rdx, JSObject::kElementsOffset));
190 __ CompareRoot(r8, Heap::kEmptyFixedArrayRootIndex);
191 __ j(equal, &only_change_map);
186 192
187 // Check backing store for COW-ness. If the negative case, we do not have to 193 // Check backing store for COW-ness. If the negative case, we do not have to
188 // allocate a new array, since FixedArray and FixedDoubleArray do not differ 194 // allocate a new array, since FixedArray and FixedDoubleArray do not differ
189 // in size. 195 // in size.
190 __ movq(r8, FieldOperand(rdx, JSObject::kElementsOffset));
191 __ SmiToInteger32(r9, FieldOperand(r8, FixedDoubleArray::kLengthOffset)); 196 __ SmiToInteger32(r9, FieldOperand(r8, FixedDoubleArray::kLengthOffset));
192 __ CompareRoot(FieldOperand(r8, HeapObject::kMapOffset), 197 __ CompareRoot(FieldOperand(r8, HeapObject::kMapOffset),
193 Heap::kFixedCOWArrayMapRootIndex); 198 Heap::kFixedCOWArrayMapRootIndex);
194 __ j(equal, &cow_array); 199 __ j(equal, &cow_array);
195 __ movq(r14, r8); // Destination array equals source array. 200 __ movq(r14, r8); // Destination array equals source array.
196 201
197 __ bind(&allocated); 202 __ bind(&allocated);
198 // r8 : source FixedArray 203 // r8 : source FixedArray
199 // r9 : elements array length 204 // r9 : elements array length
200 // r14: destination FixedDoubleArray 205 // r14: destination FixedDoubleArray
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 r11, 239 r11,
235 r15, 240 r15,
236 kDontSaveFPRegs, 241 kDontSaveFPRegs,
237 EMIT_REMEMBERED_SET, 242 EMIT_REMEMBERED_SET,
238 OMIT_SMI_CHECK); 243 OMIT_SMI_CHECK);
239 // Set backing store's length. 244 // Set backing store's length.
240 __ Integer32ToSmi(r11, r9); 245 __ Integer32ToSmi(r11, r9);
241 __ movq(FieldOperand(r14, FixedDoubleArray::kLengthOffset), r11); 246 __ movq(FieldOperand(r14, FixedDoubleArray::kLengthOffset), r11);
242 __ jmp(&allocated); 247 __ jmp(&allocated);
243 248
249 __ bind(&only_change_map);
250 // Set transitioned map.
251 __ movq(FieldOperand(rdx, HeapObject::kMapOffset), rbx);
252 __ RecordWriteField(rdx,
253 HeapObject::kMapOffset,
254 rbx,
255 rdi,
256 kDontSaveFPRegs,
257 OMIT_REMEMBERED_SET,
258 OMIT_SMI_CHECK);
259 __ jmp(&done);
260
244 // Conversion loop. 261 // Conversion loop.
245 __ bind(&loop); 262 __ bind(&loop);
246 __ movq(rbx, 263 __ movq(rbx,
247 FieldOperand(r8, r9, times_8, FixedArray::kHeaderSize)); 264 FieldOperand(r8, r9, times_8, FixedArray::kHeaderSize));
248 // r9 : current element's index 265 // r9 : current element's index
249 // rbx: current element (smi-tagged) 266 // rbx: current element (smi-tagged)
250 __ JumpIfNotSmi(rbx, &convert_hole); 267 __ JumpIfNotSmi(rbx, &convert_hole);
251 __ SmiToInteger32(rbx, rbx); 268 __ SmiToInteger32(rbx, rbx);
252 __ cvtlsi2sd(xmm0, rbx); 269 __ cvtlsi2sd(xmm0, rbx);
253 __ movsd(FieldOperand(r14, r9, times_8, FixedDoubleArray::kHeaderSize), 270 __ movsd(FieldOperand(r14, r9, times_8, FixedDoubleArray::kHeaderSize),
254 xmm0); 271 xmm0);
255 __ jmp(&entry); 272 __ jmp(&entry);
256 __ bind(&convert_hole); 273 __ bind(&convert_hole);
257 274
258 if (FLAG_debug_code) { 275 if (FLAG_debug_code) {
259 __ CompareRoot(rbx, Heap::kTheHoleValueRootIndex); 276 __ CompareRoot(rbx, Heap::kTheHoleValueRootIndex);
260 __ Assert(equal, "object found in smi-only array"); 277 __ Assert(equal, "object found in smi-only array");
261 } 278 }
262 279
263 __ movq(FieldOperand(r14, r9, times_8, FixedDoubleArray::kHeaderSize), r15); 280 __ movq(FieldOperand(r14, r9, times_8, FixedDoubleArray::kHeaderSize), r15);
264 __ bind(&entry); 281 __ bind(&entry);
265 __ decq(r9); 282 __ decq(r9);
266 __ j(not_sign, &loop); 283 __ j(not_sign, &loop);
284
285 __ bind(&done);
267 } 286 }
268 287
269 288
270 void ElementsTransitionGenerator::GenerateDoubleToObject( 289 void ElementsTransitionGenerator::GenerateDoubleToObject(
271 MacroAssembler* masm, Label* fail) { 290 MacroAssembler* masm, Label* fail) {
272 // ----------- S t a t e ------------- 291 // ----------- S t a t e -------------
273 // -- rax : value 292 // -- rax : value
274 // -- rbx : target map 293 // -- rbx : target map
275 // -- rcx : key 294 // -- rcx : key
276 // -- rdx : receiver 295 // -- rdx : receiver
277 // -- rsp[0] : return address 296 // -- rsp[0] : return address
278 // ----------------------------------- 297 // -----------------------------------
279 Label loop, entry, convert_hole, gc_required; 298 Label loop, entry, convert_hole, gc_required, only_change_map;
299
300 // Check for empty arrays, which only require a map transition and no changes
301 // to the backing store.
302 __ movq(r8, FieldOperand(rdx, JSObject::kElementsOffset));
303 __ CompareRoot(r8, Heap::kEmptyFixedArrayRootIndex);
304 __ j(equal, &only_change_map);
305
280 __ push(rax); 306 __ push(rax);
281 307
282 __ movq(r8, FieldOperand(rdx, JSObject::kElementsOffset)); 308 __ movq(r8, FieldOperand(rdx, JSObject::kElementsOffset));
283 __ SmiToInteger32(r9, FieldOperand(r8, FixedDoubleArray::kLengthOffset)); 309 __ SmiToInteger32(r9, FieldOperand(r8, FixedDoubleArray::kLengthOffset));
284 // r8 : source FixedDoubleArray 310 // r8 : source FixedDoubleArray
285 // r9 : number of elements 311 // r9 : number of elements
286 __ lea(rdi, Operand(r9, times_pointer_size, FixedArray::kHeaderSize)); 312 __ lea(rdi, Operand(r9, times_pointer_size, FixedArray::kHeaderSize));
287 __ AllocateInNewSpace(rdi, r11, r14, r15, &gc_required, TAG_OBJECT); 313 __ AllocateInNewSpace(rdi, r11, r14, r15, &gc_required, TAG_OBJECT);
288 // r11: destination FixedArray 314 // r11: destination FixedArray
289 __ LoadRoot(rdi, Heap::kFixedArrayMapRootIndex); 315 __ LoadRoot(rdi, Heap::kFixedArrayMapRootIndex);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 __ movq(FieldOperand(r11, 364 __ movq(FieldOperand(r11,
339 r9, 365 r9,
340 times_pointer_size, 366 times_pointer_size,
341 FixedArray::kHeaderSize), 367 FixedArray::kHeaderSize),
342 rdi); 368 rdi);
343 369
344 __ bind(&entry); 370 __ bind(&entry);
345 __ decq(r9); 371 __ decq(r9);
346 __ j(not_sign, &loop); 372 __ j(not_sign, &loop);
347 373
348 // Set transitioned map.
349 __ movq(FieldOperand(rdx, HeapObject::kMapOffset), rbx);
350 __ RecordWriteField(rdx,
351 HeapObject::kMapOffset,
352 rbx,
353 rdi,
354 kDontSaveFPRegs,
355 EMIT_REMEMBERED_SET,
356 OMIT_SMI_CHECK);
357 // Replace receiver's backing store with newly created and filled FixedArray. 374 // Replace receiver's backing store with newly created and filled FixedArray.
358 __ movq(FieldOperand(rdx, JSObject::kElementsOffset), r11); 375 __ movq(FieldOperand(rdx, JSObject::kElementsOffset), r11);
359 __ RecordWriteField(rdx, 376 __ RecordWriteField(rdx,
360 JSObject::kElementsOffset, 377 JSObject::kElementsOffset,
361 r11, 378 r11,
362 r15, 379 r15,
363 kDontSaveFPRegs, 380 kDontSaveFPRegs,
364 EMIT_REMEMBERED_SET, 381 EMIT_REMEMBERED_SET,
365 OMIT_SMI_CHECK); 382 OMIT_SMI_CHECK);
366 __ pop(rax); 383 __ pop(rax);
367 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); 384 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
385
386 __ bind(&only_change_map);
387 // Set transitioned map.
388 __ movq(FieldOperand(rdx, HeapObject::kMapOffset), rbx);
389 __ RecordWriteField(rdx,
390 HeapObject::kMapOffset,
391 rbx,
392 rdi,
393 kDontSaveFPRegs,
394 OMIT_REMEMBERED_SET,
395 OMIT_SMI_CHECK);
368 } 396 }
369 397
370 398
371 void StringCharLoadGenerator::Generate(MacroAssembler* masm, 399 void StringCharLoadGenerator::Generate(MacroAssembler* masm,
372 Register string, 400 Register string,
373 Register index, 401 Register index,
374 Register result, 402 Register result,
375 Label* call_runtime) { 403 Label* call_runtime) {
376 // Fetch the instance type of the receiver into result register. 404 // Fetch the instance type of the receiver into result register.
377 __ movq(result, FieldOperand(string, HeapObject::kMapOffset)); 405 __ movq(result, FieldOperand(string, HeapObject::kMapOffset));
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 times_1, 496 times_1,
469 SeqAsciiString::kHeaderSize)); 497 SeqAsciiString::kHeaderSize));
470 __ bind(&done); 498 __ bind(&done);
471 } 499 }
472 500
473 #undef __ 501 #undef __
474 502
475 } } // namespace v8::internal 503 } } // namespace v8::internal
476 504
477 #endif // V8_TARGET_ARCH_X64 505 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/code-stubs-x64.cc ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698