| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/assembler_macros.h" | 9 #include "vm/assembler_macros.h" |
| 10 #include "vm/code_generator.h" | 10 #include "vm/code_generator.h" |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 | 658 |
| 659 if (FLAG_inline_alloc) { | 659 if (FLAG_inline_alloc) { |
| 660 // Compute the size to be allocated, it is based on the array length | 660 // Compute the size to be allocated, it is based on the array length |
| 661 // and it computed as: | 661 // and it computed as: |
| 662 // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)). | 662 // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)). |
| 663 // Assert that length is a Smi. | 663 // Assert that length is a Smi. |
| 664 __ testl(EDX, Immediate(kSmiTagSize)); | 664 __ testl(EDX, Immediate(kSmiTagSize)); |
| 665 if (FLAG_use_slow_path) { | 665 if (FLAG_use_slow_path) { |
| 666 __ jmp(&slow_case); | 666 __ jmp(&slow_case); |
| 667 } else { | 667 } else { |
| 668 __ j(NOT_ZERO, &slow_case, Assembler::kNearJump); | 668 __ j(NOT_ZERO, &slow_case); |
| 669 } | 669 } |
| 670 __ movl(EDI, FieldAddress(CTX, Context::isolate_offset())); | 670 __ movl(EDI, FieldAddress(CTX, Context::isolate_offset())); |
| 671 __ movl(EDI, Address(EDI, Isolate::heap_offset())); | 671 __ movl(EDI, Address(EDI, Isolate::heap_offset())); |
| 672 __ movl(EDI, Address(EDI, Heap::new_space_offset())); | 672 __ movl(EDI, Address(EDI, Heap::new_space_offset())); |
| 673 | 673 |
| 674 // Calculate and align allocation size. | 674 // Calculate and align allocation size. |
| 675 // Load new object start and calculate next object start. | 675 // Load new object start and calculate next object start. |
| 676 // ECX: array element type. | 676 // ECX: array element type. |
| 677 // EDX: Array length as Smi. | 677 // EDX: Array length as Smi. |
| 678 // EDI: Points to new space object. | 678 // EDI: Points to new space object. |
| 679 __ movl(EAX, Address(EDI, Scavenger::top_offset())); | 679 __ movl(EAX, Address(EDI, Scavenger::top_offset())); |
| 680 intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1; | 680 intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1; |
| 681 __ leal(EBX, Address(EDX, TIMES_2, fixed_size)); // EDX is Smi. | 681 __ leal(EBX, Address(EDX, TIMES_2, fixed_size)); // EDX is Smi. |
| 682 ASSERT(kSmiTagShift == 1); | 682 ASSERT(kSmiTagShift == 1); |
| 683 __ andl(EBX, Immediate(-kObjectAlignment)); | 683 __ andl(EBX, Immediate(-kObjectAlignment)); |
| 684 __ leal(EBX, Address(EAX, EBX, TIMES_1, 0)); | 684 __ leal(EBX, Address(EAX, EBX, TIMES_1, 0)); |
| 685 | 685 |
| 686 // Check if the allocation fits into the remaining space. | 686 // Check if the allocation fits into the remaining space. |
| 687 // EAX: potential new object start. | 687 // EAX: potential new object start. |
| 688 // EBX: potential next object start. | 688 // EBX: potential next object start. |
| 689 // ECX: array element type. | 689 // ECX: array element type. |
| 690 // EDX: Array length as Smi. | 690 // EDX: Array length as Smi. |
| 691 // EDI: Points to new space object. | 691 // EDI: Points to new space object. |
| 692 __ cmpl(EBX, Address(EDI, Scavenger::end_offset())); | 692 __ cmpl(EBX, Address(EDI, Scavenger::end_offset())); |
| 693 __ j(ABOVE_EQUAL, &slow_case, Assembler::kNearJump); | 693 __ j(ABOVE_EQUAL, &slow_case); |
| 694 | 694 |
| 695 // Successfully allocated the object(s), now update top to point to | 695 // Successfully allocated the object(s), now update top to point to |
| 696 // next object start and initialize the object. | 696 // next object start and initialize the object. |
| 697 // EAX: potential new object start. | 697 // EAX: potential new object start. |
| 698 // EBX: potential next object start. | 698 // EBX: potential next object start. |
| 699 // EDX: Array length as Smi. | 699 // EDX: Array length as Smi. |
| 700 // EDI: Points to new space object. | 700 // EDI: Points to new space object. |
| 701 __ movl(Address(EDI, Scavenger::top_offset()), EBX); | 701 __ movl(Address(EDI, Scavenger::top_offset()), EBX); |
| 702 __ addl(EAX, Immediate(kHeapObjectTag)); | 702 __ addl(EAX, Immediate(kHeapObjectTag)); |
| 703 | 703 |
| 704 // EAX: new object start as a tagged pointer. | 704 // EAX: new object start as a tagged pointer. |
| 705 // EBX: new object end address. | 705 // EBX: new object end address. |
| 706 // ECX: array element type. | 706 // ECX: array element type. |
| 707 // EDX: Array length as Smi. | 707 // EDX: Array length as Smi. |
| 708 | 708 |
| 709 // Store the type argument field. | 709 // Store the type argument field. |
| 710 __ StoreIntoObject(EAX, | 710 __ StoreIntoObjectNoBarrier( |
| 711 FieldAddress(EAX, Array::type_arguments_offset()), | 711 EAX, |
| 712 ECX); | 712 FieldAddress(EAX, Array::type_arguments_offset()), |
| 713 ECX); |
| 713 | 714 |
| 714 // Set the length field. | 715 // Set the length field. |
| 715 __ StoreIntoObject(EAX, | 716 __ StoreIntoObjectNoBarrier( |
| 716 FieldAddress(EAX, Array::length_offset()), | 717 EAX, |
| 717 EDX); | 718 FieldAddress(EAX, Array::length_offset()), |
| 719 EDX); |
| 718 | 720 |
| 719 // Calculate the size tag. | 721 // Calculate the size tag. |
| 720 // EAX: new object start as a tagged pointer. | 722 // EAX: new object start as a tagged pointer. |
| 721 // EBX: new object end address. | 723 // EBX: new object end address. |
| 722 // EDX: Array length as Smi. | 724 // EDX: Array length as Smi. |
| 723 { | 725 { |
| 724 Label size_tag_overflow, done; | 726 Label size_tag_overflow, done; |
| 725 __ leal(ECX, Address(EDX, TIMES_2, fixed_size)); // EDX is Smi. | 727 __ leal(ECX, Address(EDX, TIMES_2, fixed_size)); // EDX is Smi. |
| 726 ASSERT(kSmiTagShift == 1); | 728 ASSERT(kSmiTagShift == 1); |
| 727 __ andl(ECX, Immediate(-kObjectAlignment)); | 729 __ andl(ECX, Immediate(-kObjectAlignment)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 744 // EBX: new object end address. | 746 // EBX: new object end address. |
| 745 // EDX: Array length as Smi. | 747 // EDX: Array length as Smi. |
| 746 __ leal(ECX, FieldAddress(EAX, Array::data_offset())); | 748 __ leal(ECX, FieldAddress(EAX, Array::data_offset())); |
| 747 // ECX: iterator which initially points to the start of the variable | 749 // ECX: iterator which initially points to the start of the variable |
| 748 // data area to be initialized. | 750 // data area to be initialized. |
| 749 Label done; | 751 Label done; |
| 750 Label init_loop; | 752 Label init_loop; |
| 751 __ Bind(&init_loop); | 753 __ Bind(&init_loop); |
| 752 __ cmpl(ECX, EBX); | 754 __ cmpl(ECX, EBX); |
| 753 __ j(ABOVE_EQUAL, &done, Assembler::kNearJump); | 755 __ j(ABOVE_EQUAL, &done, Assembler::kNearJump); |
| 756 // TODO(cshapiro): StoreIntoObjectNoBarrier |
| 754 __ movl(Address(ECX, 0), raw_null); | 757 __ movl(Address(ECX, 0), raw_null); |
| 755 __ addl(ECX, Immediate(kWordSize)); | 758 __ addl(ECX, Immediate(kWordSize)); |
| 756 __ jmp(&init_loop, Assembler::kNearJump); | 759 __ jmp(&init_loop, Assembler::kNearJump); |
| 757 __ Bind(&done); | 760 __ Bind(&done); |
| 758 | 761 |
| 759 // Done allocating and initializing the array. | 762 // Done allocating and initializing the array. |
| 760 // EAX: new object. | 763 // EAX: new object. |
| 761 // EDX: Array length as Smi (preserved for the caller.) | 764 // EDX: Array length as Smi (preserved for the caller.) |
| 762 __ ret(); | 765 __ ret(); |
| 763 } | 766 } |
| (...skipping 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1897 // TOS + 2: instance. | 1900 // TOS + 2: instance. |
| 1898 // TOS + 3: cache array. | 1901 // TOS + 3: cache array. |
| 1899 // Result in ECX: null -> not found, otherwise result (true or false). | 1902 // Result in ECX: null -> not found, otherwise result (true or false). |
| 1900 void StubCode::GenerateSubtype3TestCacheStub(Assembler* assembler) { | 1903 void StubCode::GenerateSubtype3TestCacheStub(Assembler* assembler) { |
| 1901 GenerateSubtypeNTestCacheStub(assembler, 3); | 1904 GenerateSubtypeNTestCacheStub(assembler, 3); |
| 1902 } | 1905 } |
| 1903 | 1906 |
| 1904 } // namespace dart | 1907 } // namespace dart |
| 1905 | 1908 |
| 1906 #endif // defined TARGET_ARCH_IA32 | 1909 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |