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

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

Issue 173568: Add allocation support to x64 macro assembler (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 3 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/assembler-x64-inl.h ('k') | src/x64/cfg-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ native
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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 __ j(equal, &rt_call); 535 __ j(equal, &rt_call);
536 536
537 // Now allocate the JSObject on the heap. 537 // Now allocate the JSObject on the heap.
538 __ movzxbq(rdi, FieldOperand(rax, Map::kInstanceSizeOffset)); 538 __ movzxbq(rdi, FieldOperand(rax, Map::kInstanceSizeOffset));
539 __ shl(rdi, Immediate(kPointerSizeLog2)); 539 __ shl(rdi, Immediate(kPointerSizeLog2));
540 // rdi: size of new object 540 // rdi: size of new object
541 // Make sure that the maximum heap object size will never cause us 541 // Make sure that the maximum heap object size will never cause us
542 // problem here, because it is always greater than the maximum 542 // problem here, because it is always greater than the maximum
543 // instance size that can be represented in a byte. 543 // instance size that can be represented in a byte.
544 ASSERT(Heap::MaxObjectSizeInPagedSpace() >= (1 << kBitsPerByte)); 544 ASSERT(Heap::MaxObjectSizeInPagedSpace() >= (1 << kBitsPerByte));
545 ExternalReference new_space_allocation_top = 545 __ AllocateObjectInNewSpace(rdi, rbx, rdi, no_reg, &rt_call, false);
546 ExternalReference::new_space_allocation_top_address();
547 __ movq(kScratchRegister, new_space_allocation_top);
548 __ movq(rbx, Operand(kScratchRegister, 0));
549 __ addq(rdi, rbx); // Calculate new top
550 ExternalReference new_space_allocation_limit =
551 ExternalReference::new_space_allocation_limit_address();
552 __ movq(kScratchRegister, new_space_allocation_limit);
553 __ cmpq(rdi, Operand(kScratchRegister, 0));
554 __ j(above_equal, &rt_call);
555 // Allocated the JSObject, now initialize the fields. 546 // Allocated the JSObject, now initialize the fields.
556 // rax: initial map 547 // rax: initial map
557 // rbx: JSObject (not HeapObject tagged - the actual address). 548 // rbx: JSObject (not HeapObject tagged - the actual address).
558 // rdi: start of next object 549 // rdi: start of next object
559 __ movq(Operand(rbx, JSObject::kMapOffset), rax); 550 __ movq(Operand(rbx, JSObject::kMapOffset), rax);
560 __ Move(rcx, Factory::empty_fixed_array()); 551 __ Move(rcx, Factory::empty_fixed_array());
561 __ movq(Operand(rbx, JSObject::kPropertiesOffset), rcx); 552 __ movq(Operand(rbx, JSObject::kPropertiesOffset), rcx);
562 __ movq(Operand(rbx, JSObject::kElementsOffset), rcx); 553 __ movq(Operand(rbx, JSObject::kElementsOffset), rcx);
563 // Set extra fields in the newly allocated object. 554 // Set extra fields in the newly allocated object.
564 // rax: initial map 555 // rax: initial map
565 // rbx: JSObject 556 // rbx: JSObject
566 // rdi: start of next object 557 // rdi: start of next object
567 { Label loop, entry; 558 { Label loop, entry;
568 __ Move(rdx, Factory::undefined_value()); 559 __ Move(rdx, Factory::undefined_value());
569 __ lea(rcx, Operand(rbx, JSObject::kHeaderSize)); 560 __ lea(rcx, Operand(rbx, JSObject::kHeaderSize));
570 __ jmp(&entry); 561 __ jmp(&entry);
571 __ bind(&loop); 562 __ bind(&loop);
572 __ movq(Operand(rcx, 0), rdx); 563 __ movq(Operand(rcx, 0), rdx);
573 __ addq(rcx, Immediate(kPointerSize)); 564 __ addq(rcx, Immediate(kPointerSize));
574 __ bind(&entry); 565 __ bind(&entry);
575 __ cmpq(rcx, rdi); 566 __ cmpq(rcx, rdi);
576 __ j(less, &loop); 567 __ j(less, &loop);
577 } 568 }
578 569
579 // Mostly done with the JSObject. Add the heap tag and store the new top, so 570 // Add the object tag to make the JSObject real, so that we can continue and
580 // that we can continue and jump into the continuation code at any time from 571 // jump into the continuation code at any time from now on. Any failures
581 // now on. Any failures need to undo the setting of the new top, so that the 572 // need to undo the allocation, so that the heap is in a consistent state
582 // heap is in a consistent state and verifiable. 573 // and verifiable.
583 // rax: initial map 574 // rax: initial map
584 // rbx: JSObject 575 // rbx: JSObject
585 // rdi: start of next object 576 // rdi: start of next object
586 __ or_(rbx, Immediate(kHeapObjectTag)); 577 __ or_(rbx, Immediate(kHeapObjectTag));
587 __ movq(kScratchRegister, new_space_allocation_top);
588 __ movq(Operand(kScratchRegister, 0), rdi);
589 578
590 // Check if a non-empty properties array is needed. 579 // Check if a non-empty properties array is needed.
591 // Allocate and initialize a FixedArray if it is. 580 // Allocate and initialize a FixedArray if it is.
592 // rax: initial map 581 // rax: initial map
593 // rbx: JSObject 582 // rbx: JSObject
594 // rdi: start of next object 583 // rdi: start of next object
595 // Calculate total properties described map. 584 // Calculate total properties described map.
596 __ movzxbq(rdx, FieldOperand(rax, Map::kUnusedPropertyFieldsOffset)); 585 __ movzxbq(rdx, FieldOperand(rax, Map::kUnusedPropertyFieldsOffset));
597 __ movzxbq(rcx, FieldOperand(rax, Map::kPreAllocatedPropertyFieldsOffset)); 586 __ movzxbq(rcx, FieldOperand(rax, Map::kPreAllocatedPropertyFieldsOffset));
598 __ addq(rdx, rcx); 587 __ addq(rdx, rcx);
599 // Calculate unused properties past the end of the in-object properties. 588 // Calculate unused properties past the end of the in-object properties.
600 __ movzxbq(rcx, FieldOperand(rax, Map::kInObjectPropertiesOffset)); 589 __ movzxbq(rcx, FieldOperand(rax, Map::kInObjectPropertiesOffset));
601 __ subq(rdx, rcx); 590 __ subq(rdx, rcx);
602 // Done if no extra properties are to be allocated. 591 // Done if no extra properties are to be allocated.
603 __ j(zero, &allocated); 592 __ j(zero, &allocated);
604 __ Assert(positive, "Property allocation count failed."); 593 __ Assert(positive, "Property allocation count failed.");
605 594
606 // Scale the number of elements by pointer size and add the header for 595 // Scale the number of elements by pointer size and add the header for
607 // FixedArrays to the start of the next object calculation from above. 596 // FixedArrays to the start of the next object calculation from above.
608 // rbx: JSObject 597 // rbx: JSObject
609 // rdi: start of next object (will be start of FixedArray) 598 // rdi: start of next object (will be start of FixedArray)
610 // rdx: number of elements in properties array 599 // rdx: number of elements in properties array
611 ASSERT(Heap::MaxObjectSizeInPagedSpace() > 600 ASSERT(Heap::MaxObjectSizeInPagedSpace() >
612 (FixedArray::kHeaderSize + 255*kPointerSize)); 601 (FixedArray::kHeaderSize + 255*kPointerSize));
613 __ lea(rax, Operand(rdi, rdx, times_pointer_size, FixedArray::kHeaderSize)); 602 __ AllocateObjectInNewSpace(FixedArray::kHeaderSize,
614 __ movq(kScratchRegister, new_space_allocation_limit); 603 times_pointer_size,
615 __ cmpq(rax, Operand(kScratchRegister, 0)); 604 rdx,
616 __ j(above_equal, &undo_allocation); 605 rdi,
617 __ store_rax(new_space_allocation_top); 606 rax,
607 no_reg,
608 &undo_allocation,
609 true);
618 610
619 // Initialize the FixedArray. 611 // Initialize the FixedArray.
620 // rbx: JSObject 612 // rbx: JSObject
621 // rdi: FixedArray 613 // rdi: FixedArray
622 // rdx: number of elements 614 // rdx: number of elements
623 // rax: start of next object 615 // rax: start of next object
624 __ Move(rcx, Factory::fixed_array_map()); 616 __ Move(rcx, Factory::fixed_array_map());
625 __ movq(Operand(rdi, JSObject::kMapOffset), rcx); // setup the map 617 __ movq(Operand(rdi, JSObject::kMapOffset), rcx); // setup the map
626 __ movl(Operand(rdi, FixedArray::kLengthOffset), rdx); // and length 618 __ movl(Operand(rdi, FixedArray::kLengthOffset), rdx); // and length
627 619
(...skipping 24 matching lines...) Expand all
652 644
653 // Continue with JSObject being successfully allocated 645 // Continue with JSObject being successfully allocated
654 // rbx: JSObject 646 // rbx: JSObject
655 __ jmp(&allocated); 647 __ jmp(&allocated);
656 648
657 // Undo the setting of the new top so that the heap is verifiable. For 649 // Undo the setting of the new top so that the heap is verifiable. For
658 // example, the map's unused properties potentially do not match the 650 // example, the map's unused properties potentially do not match the
659 // allocated objects unused properties. 651 // allocated objects unused properties.
660 // rbx: JSObject (previous new top) 652 // rbx: JSObject (previous new top)
661 __ bind(&undo_allocation); 653 __ bind(&undo_allocation);
662 __ xor_(rbx, Immediate(kHeapObjectTag)); // clear the heap tag 654 __ UndoAllocationInNewSpace(rbx);
663 __ movq(kScratchRegister, new_space_allocation_top);
664 __ movq(Operand(kScratchRegister, 0), rbx);
665 } 655 }
666 656
667 // Allocate the new receiver object using the runtime call. 657 // Allocate the new receiver object using the runtime call.
668 // rdi: function (constructor) 658 // rdi: function (constructor)
669 __ bind(&rt_call); 659 __ bind(&rt_call);
670 // Must restore rdi (constructor) before calling runtime. 660 // Must restore rdi (constructor) before calling runtime.
671 __ movq(rdi, Operand(rsp, 0)); 661 __ movq(rdi, Operand(rsp, 0));
672 __ push(rdi); 662 __ push(rdi);
673 __ CallRuntime(Runtime::kNewObject, 1); 663 __ CallRuntime(Runtime::kNewObject, 1);
674 __ movq(rbx, rax); // store result in rbx 664 __ movq(rbx, rax); // store result in rbx
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { 844 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) {
855 Generate_JSEntryTrampolineHelper(masm, false); 845 Generate_JSEntryTrampolineHelper(masm, false);
856 } 846 }
857 847
858 848
859 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { 849 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) {
860 Generate_JSEntryTrampolineHelper(masm, true); 850 Generate_JSEntryTrampolineHelper(masm, true);
861 } 851 }
862 852
863 } } // namespace v8::internal 853 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/x64/assembler-x64-inl.h ('k') | src/x64/cfg-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698