| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 } | 554 } |
| 555 __ cmpl(EDX, Immediate(0)); | 555 __ cmpl(EDX, Immediate(0)); |
| 556 __ j(LESS, &slow_case); | 556 __ j(LESS, &slow_case); |
| 557 | 557 |
| 558 // Check for maximum allowed length. | 558 // Check for maximum allowed length. |
| 559 const Immediate& max_len = | 559 const Immediate& max_len = |
| 560 Immediate(reinterpret_cast<int32_t>(Smi::New(Array::kMaxElements))); | 560 Immediate(reinterpret_cast<int32_t>(Smi::New(Array::kMaxElements))); |
| 561 __ cmpl(EDX, max_len); | 561 __ cmpl(EDX, max_len); |
| 562 __ j(GREATER, &slow_case); | 562 __ j(GREATER, &slow_case); |
| 563 | 563 |
| 564 __ MaybeTraceAllocation(kArrayCid, | 564 NOT_IN_PRODUCT(__ MaybeTraceAllocation(kArrayCid, |
| 565 EAX, | 565 EAX, |
| 566 &slow_case, | 566 &slow_case, |
| 567 Assembler::kFarJump); | 567 Assembler::kFarJump)); |
| 568 | 568 |
| 569 const intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1; | 569 const intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1; |
| 570 __ leal(EBX, Address(EDX, TIMES_2, fixed_size)); // EDX is Smi. | 570 __ leal(EBX, Address(EDX, TIMES_2, fixed_size)); // EDX is Smi. |
| 571 ASSERT(kSmiTagShift == 1); | 571 ASSERT(kSmiTagShift == 1); |
| 572 __ andl(EBX, Immediate(-kObjectAlignment)); | 572 __ andl(EBX, Immediate(-kObjectAlignment)); |
| 573 | 573 |
| 574 // ECX: array element type. | 574 // ECX: array element type. |
| 575 // EDX: array length as Smi. | 575 // EDX: array length as Smi. |
| 576 // EBX: allocation size. | 576 // EBX: allocation size. |
| 577 | 577 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 589 // ECX: array element type. | 589 // ECX: array element type. |
| 590 // EDX: array length as Smi). | 590 // EDX: array length as Smi). |
| 591 __ cmpl(EBX, Address(EDI, Heap::EndOffset(space))); | 591 __ cmpl(EBX, Address(EDI, Heap::EndOffset(space))); |
| 592 __ j(ABOVE_EQUAL, &slow_case); | 592 __ j(ABOVE_EQUAL, &slow_case); |
| 593 | 593 |
| 594 // Successfully allocated the object(s), now update top to point to | 594 // Successfully allocated the object(s), now update top to point to |
| 595 // next object start and initialize the object. | 595 // next object start and initialize the object. |
| 596 __ movl(Address(EDI, Heap::TopOffset(space)), EBX); | 596 __ movl(Address(EDI, Heap::TopOffset(space)), EBX); |
| 597 __ subl(EBX, EAX); | 597 __ subl(EBX, EAX); |
| 598 __ addl(EAX, Immediate(kHeapObjectTag)); | 598 __ addl(EAX, Immediate(kHeapObjectTag)); |
| 599 __ UpdateAllocationStatsWithSize(cid, EBX, EDI, space); | 599 NOT_IN_PRODUCT(__ UpdateAllocationStatsWithSize(cid, EBX, EDI, space)); |
| 600 | 600 |
| 601 // Initialize the tags. | 601 // Initialize the tags. |
| 602 // EAX: new object start as a tagged pointer. | 602 // EAX: new object start as a tagged pointer. |
| 603 // EBX: allocation size. | 603 // EBX: allocation size. |
| 604 // ECX: array element type. | 604 // ECX: array element type. |
| 605 // EDX: array length as Smi. | 605 // EDX: array length as Smi. |
| 606 { | 606 { |
| 607 Label size_tag_overflow, done; | 607 Label size_tag_overflow, done; |
| 608 __ movl(EDI, EBX); | 608 __ movl(EDI, EBX); |
| 609 __ cmpl(EDI, Immediate(RawObject::SizeTag::kMaxSizeTag)); | 609 __ cmpl(EDI, Immediate(RawObject::SizeTag::kMaxSizeTag)); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 const Immediate& raw_null = | 791 const Immediate& raw_null = |
| 792 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 792 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 793 if (FLAG_inline_alloc) { | 793 if (FLAG_inline_alloc) { |
| 794 Label slow_case; | 794 Label slow_case; |
| 795 // First compute the rounded instance size. | 795 // First compute the rounded instance size. |
| 796 // EDX: number of context variables. | 796 // EDX: number of context variables. |
| 797 intptr_t fixed_size = (sizeof(RawContext) + kObjectAlignment - 1); | 797 intptr_t fixed_size = (sizeof(RawContext) + kObjectAlignment - 1); |
| 798 __ leal(EBX, Address(EDX, TIMES_4, fixed_size)); | 798 __ leal(EBX, Address(EDX, TIMES_4, fixed_size)); |
| 799 __ andl(EBX, Immediate(-kObjectAlignment)); | 799 __ andl(EBX, Immediate(-kObjectAlignment)); |
| 800 | 800 |
| 801 __ MaybeTraceAllocation(kContextCid, | 801 NOT_IN_PRODUCT(__ MaybeTraceAllocation(kContextCid, |
| 802 EAX, | 802 EAX, |
| 803 &slow_case, | 803 &slow_case, |
| 804 Assembler::kFarJump); | 804 Assembler::kFarJump)); |
| 805 | 805 |
| 806 // Now allocate the object. | 806 // Now allocate the object. |
| 807 // EDX: number of context variables. | 807 // EDX: number of context variables. |
| 808 const intptr_t cid = kContextCid; | 808 const intptr_t cid = kContextCid; |
| 809 Heap::Space space = Heap::SpaceForAllocation(cid); | 809 Heap::Space space = Heap::SpaceForAllocation(cid); |
| 810 __ movl(ECX, Address(THR, Thread::heap_offset())); | 810 __ movl(ECX, Address(THR, Thread::heap_offset())); |
| 811 __ movl(EAX, Address(ECX, Heap::TopOffset(space))); | 811 __ movl(EAX, Address(ECX, Heap::TopOffset(space))); |
| 812 __ addl(EBX, EAX); | 812 __ addl(EBX, EAX); |
| 813 // Check if the allocation fits into the remaining space. | 813 // Check if the allocation fits into the remaining space. |
| 814 // EAX: potential new object. | 814 // EAX: potential new object. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 829 // Successfully allocated the object, now update top to point to | 829 // Successfully allocated the object, now update top to point to |
| 830 // next object start and initialize the object. | 830 // next object start and initialize the object. |
| 831 // EAX: new object. | 831 // EAX: new object. |
| 832 // EBX: next object start. | 832 // EBX: next object start. |
| 833 // EDX: number of context variables. | 833 // EDX: number of context variables. |
| 834 __ movl(Address(ECX, Heap::TopOffset(space)), EBX); | 834 __ movl(Address(ECX, Heap::TopOffset(space)), EBX); |
| 835 // EBX: Size of allocation in bytes. | 835 // EBX: Size of allocation in bytes. |
| 836 __ subl(EBX, EAX); | 836 __ subl(EBX, EAX); |
| 837 __ addl(EAX, Immediate(kHeapObjectTag)); | 837 __ addl(EAX, Immediate(kHeapObjectTag)); |
| 838 // Generate isolate-independent code to allow sharing between isolates. | 838 // Generate isolate-independent code to allow sharing between isolates. |
| 839 __ UpdateAllocationStatsWithSize(cid, EBX, EDI, space); | 839 NOT_IN_PRODUCT(__ UpdateAllocationStatsWithSize(cid, EBX, EDI, space)); |
| 840 | 840 |
| 841 // Calculate the size tag. | 841 // Calculate the size tag. |
| 842 // EAX: new object. | 842 // EAX: new object. |
| 843 // EDX: number of context variables. | 843 // EDX: number of context variables. |
| 844 { | 844 { |
| 845 Label size_tag_overflow, done; | 845 Label size_tag_overflow, done; |
| 846 __ leal(EBX, Address(EDX, TIMES_4, fixed_size)); | 846 __ leal(EBX, Address(EDX, TIMES_4, fixed_size)); |
| 847 __ andl(EBX, Immediate(-kObjectAlignment)); | 847 __ andl(EBX, Immediate(-kObjectAlignment)); |
| 848 __ cmpl(EBX, Immediate(RawObject::SizeTag::kMaxSizeTag)); | 848 __ cmpl(EBX, Immediate(RawObject::SizeTag::kMaxSizeTag)); |
| 849 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); | 849 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1026 // EAX: potential new object start. | 1026 // EAX: potential new object start. |
| 1027 // EBX: potential next object start. | 1027 // EBX: potential next object start. |
| 1028 // EDI: heap. | 1028 // EDI: heap. |
| 1029 __ cmpl(EBX, Address(EDI, Heap::EndOffset(space))); | 1029 __ cmpl(EBX, Address(EDI, Heap::EndOffset(space))); |
| 1030 if (FLAG_use_slow_path) { | 1030 if (FLAG_use_slow_path) { |
| 1031 __ jmp(&slow_case); | 1031 __ jmp(&slow_case); |
| 1032 } else { | 1032 } else { |
| 1033 __ j(ABOVE_EQUAL, &slow_case); | 1033 __ j(ABOVE_EQUAL, &slow_case); |
| 1034 } | 1034 } |
| 1035 __ movl(Address(EDI, Heap::TopOffset(space)), EBX); | 1035 __ movl(Address(EDI, Heap::TopOffset(space)), EBX); |
| 1036 __ UpdateAllocationStats(cls.id(), ECX, space); | 1036 NOT_IN_PRODUCT(__ UpdateAllocationStats(cls.id(), ECX, space)); |
| 1037 | 1037 |
| 1038 // EAX: new object start (untagged). | 1038 // EAX: new object start (untagged). |
| 1039 // EBX: next object start. | 1039 // EBX: next object start. |
| 1040 // EDX: new object type arguments (if is_cls_parameterized). | 1040 // EDX: new object type arguments (if is_cls_parameterized). |
| 1041 // Set the tags. | 1041 // Set the tags. |
| 1042 uword tags = 0; | 1042 uword tags = 0; |
| 1043 tags = RawObject::SizeTag::update(instance_size, tags); | 1043 tags = RawObject::SizeTag::update(instance_size, tags); |
| 1044 ASSERT(cls.id() != kIllegalCid); | 1044 ASSERT(cls.id() != kIllegalCid); |
| 1045 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 1045 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
| 1046 __ movl(Address(EAX, Instance::tags_offset()), Immediate(tags)); | 1046 __ movl(Address(EAX, Instance::tags_offset()), Immediate(tags)); |
| (...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2091 | 2091 |
| 2092 | 2092 |
| 2093 | 2093 |
| 2094 void StubCode::GenerateFrameAwaitingMaterializationStub(Assembler* assembler) { | 2094 void StubCode::GenerateFrameAwaitingMaterializationStub(Assembler* assembler) { |
| 2095 __ int3(); | 2095 __ int3(); |
| 2096 } | 2096 } |
| 2097 | 2097 |
| 2098 } // namespace dart | 2098 } // namespace dart |
| 2099 | 2099 |
| 2100 #endif // defined TARGET_ARCH_IA32 | 2100 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |