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

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

Issue 11817017: Additional work to get array literal allocation tracking working, even with --always-opt (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Removed unnecessary class specifiers Created 7 years, 11 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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 static void GenerateFastCloneShallowArrayCommon( 315 static void GenerateFastCloneShallowArrayCommon(
316 MacroAssembler* masm, 316 MacroAssembler* masm,
317 int length, 317 int length,
318 FastCloneShallowArrayStub::Mode mode, 318 FastCloneShallowArrayStub::Mode mode,
319 AllocationSiteInfoMode allocation_site_info_mode, 319 AllocationSiteInfoMode allocation_site_info_mode,
320 Label* fail) { 320 Label* fail) {
321 // Registers on entry: 321 // Registers on entry:
322 // 322 //
323 // rcx: boilerplate literal array. 323 // rcx: boilerplate literal array.
324 ASSERT(mode != FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS); 324 ASSERT(mode != FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS);
325 bool tracking_on = allocation_site_info_mode == TRACK_ALLOCATION_SITE_INFO;
325 326
326 // All sizes here are multiples of kPointerSize. 327 // All sizes here are multiples of kPointerSize.
327 int elements_size = 0; 328 int elements_size = 0;
328 if (length > 0) { 329 if (length > 0) {
329 elements_size = mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS 330 elements_size = mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS
330 ? FixedDoubleArray::SizeFor(length) 331 ? FixedDoubleArray::SizeFor(length)
331 : FixedArray::SizeFor(length); 332 : FixedArray::SizeFor(length);
332 } 333 }
333 int size = JSArray::kSize; 334 int size = JSArray::kSize;
334 int allocation_info_start = size; 335 int allocation_info_start = size;
335 if (allocation_site_info_mode == TRACK_ALLOCATION_SITE_INFO) { 336 size += tracking_on ? AllocationSiteInfo::kSize + elements_size
336 size += AllocationSiteInfo::kSize; 337 : elements_size;
337 }
338 size += elements_size;
339 338
340 // Allocate both the JS array and the elements array in one big 339 // Allocate both the JS array and the elements array in one big
341 // allocation. This avoids multiple limit checks. 340 // allocation. This avoids multiple limit checks.
342 AllocationFlags flags = TAG_OBJECT; 341 AllocationFlags flags = TAG_OBJECT;
343 if (mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS) { 342 if (mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS) {
344 flags = static_cast<AllocationFlags>(DOUBLE_ALIGNMENT | flags); 343 flags = static_cast<AllocationFlags>(DOUBLE_ALIGNMENT | flags);
345 } 344 }
346 __ AllocateInNewSpace(size, rax, rbx, rdx, fail, flags); 345 __ AllocateInNewSpace(size, rax, rbx, rdx, fail, flags);
347 346
348 if (allocation_site_info_mode == TRACK_ALLOCATION_SITE_INFO) { 347 if (tracking_on) {
349 __ LoadRoot(kScratchRegister, Heap::kAllocationSiteInfoMapRootIndex); 348 __ LoadRoot(kScratchRegister, Heap::kAllocationSiteInfoMapRootIndex);
350 __ movq(FieldOperand(rax, allocation_info_start), kScratchRegister); 349 __ movq(FieldOperand(rax, allocation_info_start), kScratchRegister);
351 __ movq(FieldOperand(rax, allocation_info_start + kPointerSize), rcx); 350 __ movq(FieldOperand(rax, allocation_info_start + kPointerSize), rcx);
352 } 351 }
353 352
354 // Copy the JS array part. 353 // Copy the JS array part.
355 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { 354 for (int i = 0; i < JSArray::kSize; i += kPointerSize) {
356 if ((i != JSArray::kElementsOffset) || (length == 0)) { 355 if ((i != JSArray::kElementsOffset) || (length == 0)) {
357 __ movq(rbx, FieldOperand(rcx, i)); 356 __ movq(rbx, FieldOperand(rcx, i));
358 __ movq(FieldOperand(rax, i), rbx); 357 __ movq(FieldOperand(rax, i), rbx);
359 } 358 }
360 } 359 }
361 360
362 if (length > 0) { 361 if (length > 0) {
363 // Get hold of the elements array of the boilerplate and setup the 362 // Get hold of the elements array of the boilerplate and setup the
364 // elements pointer in the resulting object. 363 // elements pointer in the resulting object.
365 __ movq(rcx, FieldOperand(rcx, JSArray::kElementsOffset)); 364 __ movq(rcx, FieldOperand(rcx, JSArray::kElementsOffset));
366 if (allocation_site_info_mode == TRACK_ALLOCATION_SITE_INFO) { 365 if (tracking_on) {
367 __ lea(rdx, Operand(rax, JSArray::kSize + AllocationSiteInfo::kSize)); 366 __ lea(rdx, Operand(rax, JSArray::kSize + AllocationSiteInfo::kSize));
368 } else { 367 } else {
369 __ lea(rdx, Operand(rax, JSArray::kSize)); 368 __ lea(rdx, Operand(rax, JSArray::kSize));
370 } 369 }
371 __ movq(FieldOperand(rax, JSArray::kElementsOffset), rdx); 370 __ movq(FieldOperand(rax, JSArray::kElementsOffset), rdx);
372 371
373 // Copy the elements array. 372 // Copy the elements array.
374 if (mode == FastCloneShallowArrayStub::CLONE_ELEMENTS) { 373 if (mode == FastCloneShallowArrayStub::CLONE_ELEMENTS) {
375 for (int i = 0; i < elements_size; i += kPointerSize) { 374 for (int i = 0; i < elements_size; i += kPointerSize) {
376 __ movq(rbx, FieldOperand(rcx, i)); 375 __ movq(rbx, FieldOperand(rcx, i));
(...skipping 30 matching lines...) Expand all
407 SmiIndex index = masm->SmiToIndex(rax, rax, kPointerSizeLog2); 406 SmiIndex index = masm->SmiToIndex(rax, rax, kPointerSizeLog2);
408 __ movq(rcx, 407 __ movq(rcx,
409 FieldOperand(rcx, index.reg, index.scale, FixedArray::kHeaderSize)); 408 FieldOperand(rcx, index.reg, index.scale, FixedArray::kHeaderSize));
410 __ CompareRoot(rcx, Heap::kUndefinedValueRootIndex); 409 __ CompareRoot(rcx, Heap::kUndefinedValueRootIndex);
411 Label slow_case; 410 Label slow_case;
412 __ j(equal, &slow_case); 411 __ j(equal, &slow_case);
413 412
414 FastCloneShallowArrayStub::Mode mode = mode_; 413 FastCloneShallowArrayStub::Mode mode = mode_;
415 // rcx is boilerplate object. 414 // rcx is boilerplate object.
416 Factory* factory = masm->isolate()->factory(); 415 Factory* factory = masm->isolate()->factory();
417 AllocationSiteInfoMode allocation_site_info_mode =
418 DONT_TRACK_ALLOCATION_SITE_INFO;
419 if (mode == CLONE_ANY_ELEMENTS_WITH_ALLOCATION_SITE_INFO) {
420 mode = CLONE_ANY_ELEMENTS;
421 allocation_site_info_mode = TRACK_ALLOCATION_SITE_INFO;
422 }
423
424 if (mode == CLONE_ANY_ELEMENTS) { 416 if (mode == CLONE_ANY_ELEMENTS) {
425 Label double_elements, check_fast_elements; 417 Label double_elements, check_fast_elements;
426 __ movq(rbx, FieldOperand(rcx, JSArray::kElementsOffset)); 418 __ movq(rbx, FieldOperand(rcx, JSArray::kElementsOffset));
427 __ Cmp(FieldOperand(rbx, HeapObject::kMapOffset), 419 __ Cmp(FieldOperand(rbx, HeapObject::kMapOffset),
428 factory->fixed_cow_array_map()); 420 factory->fixed_cow_array_map());
429 __ j(not_equal, &check_fast_elements); 421 __ j(not_equal, &check_fast_elements);
430 GenerateFastCloneShallowArrayCommon(masm, 0, 422 GenerateFastCloneShallowArrayCommon(masm, 0, COPY_ON_WRITE_ELEMENTS,
431 COPY_ON_WRITE_ELEMENTS, 423 allocation_site_info_mode_,
432 allocation_site_info_mode,
433 &slow_case); 424 &slow_case);
434 __ ret(3 * kPointerSize); 425 __ ret(3 * kPointerSize);
435 426
436 __ bind(&check_fast_elements); 427 __ bind(&check_fast_elements);
437 __ Cmp(FieldOperand(rbx, HeapObject::kMapOffset), 428 __ Cmp(FieldOperand(rbx, HeapObject::kMapOffset),
438 factory->fixed_array_map()); 429 factory->fixed_array_map());
439 __ j(not_equal, &double_elements); 430 __ j(not_equal, &double_elements);
440 GenerateFastCloneShallowArrayCommon(masm, length_, 431 GenerateFastCloneShallowArrayCommon(masm, length_, CLONE_ELEMENTS,
441 CLONE_ELEMENTS, 432 allocation_site_info_mode_,
442 allocation_site_info_mode,
443 &slow_case); 433 &slow_case);
444 __ ret(3 * kPointerSize); 434 __ ret(3 * kPointerSize);
445 435
446 __ bind(&double_elements); 436 __ bind(&double_elements);
447 mode = CLONE_DOUBLE_ELEMENTS; 437 mode = CLONE_DOUBLE_ELEMENTS;
448 // Fall through to generate the code to handle double elements. 438 // Fall through to generate the code to handle double elements.
449 } 439 }
450 440
451 if (FLAG_debug_code) { 441 if (FLAG_debug_code) {
452 const char* message; 442 const char* message;
(...skipping 11 matching lines...) Expand all
464 } 454 }
465 __ push(rcx); 455 __ push(rcx);
466 __ movq(rcx, FieldOperand(rcx, JSArray::kElementsOffset)); 456 __ movq(rcx, FieldOperand(rcx, JSArray::kElementsOffset));
467 __ CompareRoot(FieldOperand(rcx, HeapObject::kMapOffset), 457 __ CompareRoot(FieldOperand(rcx, HeapObject::kMapOffset),
468 expected_map_index); 458 expected_map_index);
469 __ Assert(equal, message); 459 __ Assert(equal, message);
470 __ pop(rcx); 460 __ pop(rcx);
471 } 461 }
472 462
473 GenerateFastCloneShallowArrayCommon(masm, length_, mode, 463 GenerateFastCloneShallowArrayCommon(masm, length_, mode,
474 allocation_site_info_mode, &slow_case); 464 allocation_site_info_mode_,
465 &slow_case);
475 __ ret(3 * kPointerSize); 466 __ ret(3 * kPointerSize);
476 467
477 __ bind(&slow_case); 468 __ bind(&slow_case);
478 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1); 469 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1);
479 } 470 }
480 471
481 472
482 void FastCloneShallowObjectStub::Generate(MacroAssembler* masm) { 473 void FastCloneShallowObjectStub::Generate(MacroAssembler* masm) {
483 // Stack layout on entry: 474 // Stack layout on entry:
484 // 475 //
(...skipping 6062 matching lines...) Expand 10 before | Expand all | Expand 10 after
6547 #endif 6538 #endif
6548 6539
6549 __ Ret(); 6540 __ Ret();
6550 } 6541 }
6551 6542
6552 #undef __ 6543 #undef __
6553 6544
6554 } } // namespace v8::internal 6545 } } // namespace v8::internal
6555 6546
6556 #endif // V8_TARGET_ARCH_X64 6547 #endif // V8_TARGET_ARCH_X64
OLDNEW
« src/objects.cc ('K') | « src/runtime.cc ('k') | src/x64/codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698