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

Side by Side Diff: src/x64/builtins-x64.cc

Issue 2274001: Revert r4715. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 7 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/spaces-inl.h ('k') | src/x64/codegen-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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 __ Jump(Handle<Code>(builtin(ArgumentsAdaptorTrampoline)), 301 __ Jump(Handle<Code>(builtin(ArgumentsAdaptorTrampoline)),
302 RelocInfo::CODE_TARGET); 302 RelocInfo::CODE_TARGET);
303 __ bind(&function); 303 __ bind(&function);
304 } 304 }
305 305
306 // 5b. Get the code to call from the function and check that the number of 306 // 5b. Get the code to call from the function and check that the number of
307 // expected arguments matches what we're providing. If so, jump 307 // expected arguments matches what we're providing. If so, jump
308 // (tail-call) to the code in register edx without checking arguments. 308 // (tail-call) to the code in register edx without checking arguments.
309 __ movq(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); 309 __ movq(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset));
310 __ movsxlq(rbx, 310 __ movsxlq(rbx,
311 FieldOperand(rdx, 311 FieldOperand(rdx, SharedFunctionInfo::kFormalParameterCountOffset));
312 SharedFunctionInfo::kFormalParameterCountOffset));
313 __ movq(rdx, FieldOperand(rdx, SharedFunctionInfo::kCodeOffset)); 312 __ movq(rdx, FieldOperand(rdx, SharedFunctionInfo::kCodeOffset));
314 __ lea(rdx, FieldOperand(rdx, Code::kHeaderSize)); 313 __ lea(rdx, FieldOperand(rdx, Code::kHeaderSize));
315 __ cmpq(rax, rbx); 314 __ cmpq(rax, rbx);
316 __ j(not_equal, 315 __ j(not_equal,
317 Handle<Code>(builtin(ArgumentsAdaptorTrampoline)), 316 Handle<Code>(builtin(ArgumentsAdaptorTrampoline)),
318 RelocInfo::CODE_TARGET); 317 RelocInfo::CODE_TARGET);
319 318
320 ParameterCount expected(0); 319 ParameterCount expected(0);
321 __ InvokeCode(rdx, expected, expected, JUMP_FUNCTION); 320 __ InvokeCode(rdx, expected, expected, JUMP_FUNCTION);
322 } 321 }
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 return; 518 return;
520 } 519 }
521 520
522 // Calculate the location of the elements array and set elements array member 521 // Calculate the location of the elements array and set elements array member
523 // of the JSArray. 522 // of the JSArray.
524 // result: JSObject 523 // result: JSObject
525 // scratch2: start of next object 524 // scratch2: start of next object
526 __ lea(scratch1, Operand(result, JSArray::kSize)); 525 __ lea(scratch1, Operand(result, JSArray::kSize));
527 __ movq(FieldOperand(result, JSArray::kElementsOffset), scratch1); 526 __ movq(FieldOperand(result, JSArray::kElementsOffset), scratch1);
528 527
529 // Initialize the FixedArray and fill it with holes. FixedArray length is 528 // Initialize the FixedArray and fill it with holes. FixedArray length is not
530 // stored as a smi. 529 // stored as a smi.
531 // result: JSObject 530 // result: JSObject
532 // scratch1: elements array 531 // scratch1: elements array
533 // scratch2: start of next object 532 // scratch2: start of next object
534 __ Move(FieldOperand(scratch1, HeapObject::kMapOffset), 533 __ Move(FieldOperand(scratch1, JSObject::kMapOffset),
535 Factory::fixed_array_map()); 534 Factory::fixed_array_map());
536 __ Move(FieldOperand(scratch1, FixedArray::kLengthOffset), 535 __ movq(FieldOperand(scratch1, Array::kLengthOffset),
537 Smi::FromInt(initial_capacity)); 536 Immediate(initial_capacity));
538 537
539 // Fill the FixedArray with the hole value. Inline the code if short. 538 // Fill the FixedArray with the hole value. Inline the code if short.
540 // Reconsider loop unfolding if kPreallocatedArrayElements gets changed. 539 // Reconsider loop unfolding if kPreallocatedArrayElements gets changed.
541 static const int kLoopUnfoldLimit = 4; 540 static const int kLoopUnfoldLimit = 4;
542 ASSERT(kPreallocatedArrayElements <= kLoopUnfoldLimit); 541 ASSERT(kPreallocatedArrayElements <= kLoopUnfoldLimit);
543 __ Move(scratch3, Factory::the_hole_value()); 542 __ Move(scratch3, Factory::the_hole_value());
544 if (initial_capacity <= kLoopUnfoldLimit) { 543 if (initial_capacity <= kLoopUnfoldLimit) {
545 // Use a scratch register here to have only one reloc info when unfolding 544 // Use a scratch register here to have only one reloc info when unfolding
546 // the loop. 545 // the loop.
547 for (int i = 0; i < initial_capacity; i++) { 546 for (int i = 0; i < initial_capacity; i++) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 bool fill_with_hole, 580 bool fill_with_hole,
582 Label* gc_required) { 581 Label* gc_required) {
583 Label not_empty, allocated; 582 Label not_empty, allocated;
584 583
585 // Load the initial map from the array function. 584 // Load the initial map from the array function.
586 __ movq(elements_array, 585 __ movq(elements_array,
587 FieldOperand(array_function, 586 FieldOperand(array_function,
588 JSFunction::kPrototypeOrInitialMapOffset)); 587 JSFunction::kPrototypeOrInitialMapOffset));
589 588
590 // Check whether an empty sized array is requested. 589 // Check whether an empty sized array is requested.
590 __ SmiToInteger64(array_size, array_size);
591 __ testq(array_size, array_size); 591 __ testq(array_size, array_size);
592 __ j(not_zero, &not_empty); 592 __ j(not_zero, &not_empty);
593 593
594 // If an empty array is requested allocate a small elements array anyway. This 594 // If an empty array is requested allocate a small elements array anyway. This
595 // keeps the code below free of special casing for the empty array. 595 // keeps the code below free of special casing for the empty array.
596 int size = JSArray::kSize + FixedArray::SizeFor(kPreallocatedArrayElements); 596 int size = JSArray::kSize + FixedArray::SizeFor(kPreallocatedArrayElements);
597 __ AllocateInNewSpace(size, 597 __ AllocateInNewSpace(size,
598 result, 598 result,
599 elements_array_end, 599 elements_array_end,
600 scratch, 600 scratch,
601 gc_required, 601 gc_required,
602 TAG_OBJECT); 602 TAG_OBJECT);
603 __ jmp(&allocated); 603 __ jmp(&allocated);
604 604
605 // Allocate the JSArray object together with space for a FixedArray with the 605 // Allocate the JSArray object together with space for a FixedArray with the
606 // requested elements. 606 // requested elements.
607 __ bind(&not_empty); 607 __ bind(&not_empty);
608 SmiIndex index = 608 ASSERT(kSmiTagSize == 1 && kSmiTag == 0);
609 masm->SmiToIndex(kScratchRegister, array_size, kPointerSizeLog2);
610 __ AllocateInNewSpace(JSArray::kSize + FixedArray::kHeaderSize, 609 __ AllocateInNewSpace(JSArray::kSize + FixedArray::kHeaderSize,
611 index.scale, 610 times_pointer_size,
612 index.reg, 611 array_size,
613 result, 612 result,
614 elements_array_end, 613 elements_array_end,
615 scratch, 614 scratch,
616 gc_required, 615 gc_required,
617 TAG_OBJECT); 616 TAG_OBJECT);
618 617
619 // Allocated the JSArray. Now initialize the fields except for the elements 618 // Allocated the JSArray. Now initialize the fields except for the elements
620 // array. 619 // array.
621 // result: JSObject 620 // result: JSObject
622 // elements_array: initial map 621 // elements_array: initial map
623 // elements_array_end: start of next object 622 // elements_array_end: start of next object
624 // array_size: size of array (smi) 623 // array_size: size of array
625 __ bind(&allocated); 624 __ bind(&allocated);
626 __ movq(FieldOperand(result, JSObject::kMapOffset), elements_array); 625 __ movq(FieldOperand(result, JSObject::kMapOffset), elements_array);
627 __ Move(elements_array, Factory::empty_fixed_array()); 626 __ Move(elements_array, Factory::empty_fixed_array());
628 __ movq(FieldOperand(result, JSArray::kPropertiesOffset), elements_array); 627 __ movq(FieldOperand(result, JSArray::kPropertiesOffset), elements_array);
629 // Field JSArray::kElementsOffset is initialized later. 628 // Field JSArray::kElementsOffset is initialized later.
630 __ movq(FieldOperand(result, JSArray::kLengthOffset), array_size); 629 __ Integer32ToSmi(scratch, array_size);
630 __ movq(FieldOperand(result, JSArray::kLengthOffset), scratch);
631 631
632 // Calculate the location of the elements array and set elements array member 632 // Calculate the location of the elements array and set elements array member
633 // of the JSArray. 633 // of the JSArray.
634 // result: JSObject 634 // result: JSObject
635 // elements_array_end: start of next object 635 // elements_array_end: start of next object
636 // array_size: size of array (smi) 636 // array_size: size of array
637 __ lea(elements_array, Operand(result, JSArray::kSize)); 637 __ lea(elements_array, Operand(result, JSArray::kSize));
638 __ movq(FieldOperand(result, JSArray::kElementsOffset), elements_array); 638 __ movq(FieldOperand(result, JSArray::kElementsOffset), elements_array);
639 639
640 // Initialize the fixed array. FixedArray length is stored as a smi. 640 // Initialize the fixed array. FixedArray length is not stored as a smi.
641 // result: JSObject 641 // result: JSObject
642 // elements_array: elements array 642 // elements_array: elements array
643 // elements_array_end: start of next object 643 // elements_array_end: start of next object
644 // array_size: size of array (smi) 644 // array_size: size of array
645 ASSERT(kSmiTag == 0);
645 __ Move(FieldOperand(elements_array, JSObject::kMapOffset), 646 __ Move(FieldOperand(elements_array, JSObject::kMapOffset),
646 Factory::fixed_array_map()); 647 Factory::fixed_array_map());
647 Label not_empty_2, fill_array; 648 Label not_empty_2, fill_array;
648 __ SmiTest(array_size); 649 __ testq(array_size, array_size);
649 __ j(not_zero, &not_empty_2); 650 __ j(not_zero, &not_empty_2);
650 // Length of the FixedArray is the number of pre-allocated elements even 651 // Length of the FixedArray is the number of pre-allocated elements even
651 // though the actual JSArray has length 0. 652 // though the actual JSArray has length 0.
652 __ Move(FieldOperand(elements_array, FixedArray::kLengthOffset), 653 __ movq(FieldOperand(elements_array, Array::kLengthOffset),
653 Smi::FromInt(kPreallocatedArrayElements)); 654 Immediate(kPreallocatedArrayElements));
654 __ jmp(&fill_array); 655 __ jmp(&fill_array);
655 __ bind(&not_empty_2); 656 __ bind(&not_empty_2);
656 // For non-empty JSArrays the length of the FixedArray and the JSArray is the 657 // For non-empty JSArrays the length of the FixedArray and the JSArray is the
657 // same. 658 // same.
658 __ movq(FieldOperand(elements_array, FixedArray::kLengthOffset), array_size); 659 __ movq(FieldOperand(elements_array, Array::kLengthOffset), array_size);
659 660
660 // Fill the allocated FixedArray with the hole value if requested. 661 // Fill the allocated FixedArray with the hole value if requested.
661 // result: JSObject 662 // result: JSObject
662 // elements_array: elements array 663 // elements_array: elements array
663 // elements_array_end: start of next object 664 // elements_array_end: start of next object
664 __ bind(&fill_array); 665 __ bind(&fill_array);
665 if (fill_with_hole) { 666 if (fill_with_hole) {
666 Label loop, entry; 667 Label loop, entry;
667 __ Move(scratch, Factory::the_hole_value()); 668 __ Move(scratch, Factory::the_hole_value());
668 __ lea(elements_array, Operand(elements_array, 669 __ lea(elements_array, Operand(elements_array,
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 no_reg, 1032 no_reg,
1032 &undo_allocation, 1033 &undo_allocation,
1033 RESULT_CONTAINS_TOP); 1034 RESULT_CONTAINS_TOP);
1034 1035
1035 // Initialize the FixedArray. 1036 // Initialize the FixedArray.
1036 // rbx: JSObject 1037 // rbx: JSObject
1037 // rdi: FixedArray 1038 // rdi: FixedArray
1038 // rdx: number of elements 1039 // rdx: number of elements
1039 // rax: start of next object 1040 // rax: start of next object
1040 __ LoadRoot(rcx, Heap::kFixedArrayMapRootIndex); 1041 __ LoadRoot(rcx, Heap::kFixedArrayMapRootIndex);
1041 __ movq(Operand(rdi, HeapObject::kMapOffset), rcx); // setup the map 1042 __ movq(Operand(rdi, JSObject::kMapOffset), rcx); // setup the map
1042 __ Integer32ToSmi(rdx, rdx); 1043 __ movl(Operand(rdi, FixedArray::kLengthOffset), rdx); // and length
1043 __ movq(Operand(rdi, FixedArray::kLengthOffset), rdx); // and length
1044 1044
1045 // Initialize the fields to undefined. 1045 // Initialize the fields to undefined.
1046 // rbx: JSObject 1046 // rbx: JSObject
1047 // rdi: FixedArray 1047 // rdi: FixedArray
1048 // rax: start of next object 1048 // rax: start of next object
1049 // rdx: number of elements 1049 // rdx: number of elements
1050 { Label loop, entry; 1050 { Label loop, entry;
1051 __ LoadRoot(rdx, Heap::kUndefinedValueRootIndex); 1051 __ LoadRoot(rdx, Heap::kUndefinedValueRootIndex);
1052 __ lea(rcx, Operand(rdi, FixedArray::kHeaderSize)); 1052 __ lea(rcx, Operand(rdi, FixedArray::kHeaderSize));
1053 __ jmp(&entry); 1053 __ jmp(&entry);
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 } 1294 }
1295 1295
1296 1296
1297 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { 1297 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) {
1298 Generate_JSEntryTrampolineHelper(masm, true); 1298 Generate_JSEntryTrampolineHelper(masm, true);
1299 } 1299 }
1300 1300
1301 } } // namespace v8::internal 1301 } } // namespace v8::internal
1302 1302
1303 #endif // V8_TARGET_ARCH_X64 1303 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/spaces-inl.h ('k') | src/x64/codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698