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 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 | 568 |
569 // Check for maximum allowed length. | 569 // Check for maximum allowed length. |
570 const Immediate& max_len = | 570 const Immediate& max_len = |
571 Immediate(reinterpret_cast<int32_t>(Smi::New(Array::kMaxElements))); | 571 Immediate(reinterpret_cast<int32_t>(Smi::New(Array::kMaxElements))); |
572 __ cmpl(EDX, max_len); | 572 __ cmpl(EDX, max_len); |
573 __ j(GREATER, &slow_case); | 573 __ j(GREATER, &slow_case); |
574 | 574 |
575 __ MaybeTraceAllocation(kArrayCid, | 575 __ MaybeTraceAllocation(kArrayCid, |
576 EAX, | 576 EAX, |
577 &slow_case, | 577 &slow_case, |
578 /* near_jump = */ false, | 578 Assembler::kFarJump, |
579 /* inline_isolate = */ false); | 579 /* inline_isolate = */ false); |
580 | 580 |
581 const intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1; | 581 const intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1; |
582 __ leal(EBX, Address(EDX, TIMES_2, fixed_size)); // EDX is Smi. | 582 __ leal(EBX, Address(EDX, TIMES_2, fixed_size)); // EDX is Smi. |
583 ASSERT(kSmiTagShift == 1); | 583 ASSERT(kSmiTagShift == 1); |
584 __ andl(EBX, Immediate(-kObjectAlignment)); | 584 __ andl(EBX, Immediate(-kObjectAlignment)); |
585 | 585 |
586 // ECX: array element type. | 586 // ECX: array element type. |
587 // EDX: array length as Smi. | 587 // EDX: array length as Smi. |
588 // EBX: allocation size. | 588 // EBX: allocation size. |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 const Immediate& raw_null = | 801 const Immediate& raw_null = |
802 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 802 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
803 if (FLAG_inline_alloc) { | 803 if (FLAG_inline_alloc) { |
804 Label slow_case; | 804 Label slow_case; |
805 // First compute the rounded instance size. | 805 // First compute the rounded instance size. |
806 // EDX: number of context variables. | 806 // EDX: number of context variables. |
807 intptr_t fixed_size = (sizeof(RawContext) + kObjectAlignment - 1); | 807 intptr_t fixed_size = (sizeof(RawContext) + kObjectAlignment - 1); |
808 __ leal(EBX, Address(EDX, TIMES_4, fixed_size)); | 808 __ leal(EBX, Address(EDX, TIMES_4, fixed_size)); |
809 __ andl(EBX, Immediate(-kObjectAlignment)); | 809 __ andl(EBX, Immediate(-kObjectAlignment)); |
810 | 810 |
| 811 __ MaybeTraceAllocation(kContextCid, |
| 812 EAX, |
| 813 &slow_case, |
| 814 Assembler::kFarJump, |
| 815 /* inline_isolate = */ false); |
| 816 |
811 // Now allocate the object. | 817 // Now allocate the object. |
812 // EDX: number of context variables. | 818 // EDX: number of context variables. |
813 const intptr_t cid = kContextCid; | 819 const intptr_t cid = kContextCid; |
814 Heap::Space space = Heap::SpaceForAllocation(cid); | 820 Heap::Space space = Heap::SpaceForAllocation(cid); |
815 __ movl(ECX, Address(THR, Thread::heap_offset())); | 821 __ movl(ECX, Address(THR, Thread::heap_offset())); |
816 __ movl(EAX, Address(ECX, Heap::TopOffset(space))); | 822 __ movl(EAX, Address(ECX, Heap::TopOffset(space))); |
817 __ addl(EBX, EAX); | 823 __ addl(EBX, EAX); |
818 // Check if the allocation fits into the remaining space. | 824 // Check if the allocation fits into the remaining space. |
819 // EAX: potential new object. | 825 // EAX: potential new object. |
820 // EBX: potential next object start. | 826 // EBX: potential next object start. |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 // kInlineInstanceSize is a constant used as a threshold for determining | 1018 // kInlineInstanceSize is a constant used as a threshold for determining |
1013 // when the object initialization should be done as a loop or as | 1019 // when the object initialization should be done as a loop or as |
1014 // straight line code. | 1020 // straight line code. |
1015 const int kInlineInstanceSize = 12; // In words. | 1021 const int kInlineInstanceSize = 12; // In words. |
1016 const intptr_t instance_size = cls.instance_size(); | 1022 const intptr_t instance_size = cls.instance_size(); |
1017 ASSERT(instance_size > 0); | 1023 ASSERT(instance_size > 0); |
1018 if (is_cls_parameterized) { | 1024 if (is_cls_parameterized) { |
1019 __ movl(EDX, Address(ESP, kObjectTypeArgumentsOffset)); | 1025 __ movl(EDX, Address(ESP, kObjectTypeArgumentsOffset)); |
1020 // EDX: instantiated type arguments. | 1026 // EDX: instantiated type arguments. |
1021 } | 1027 } |
| 1028 Isolate* isolate = Isolate::Current(); |
1022 if (FLAG_inline_alloc && Heap::IsAllocatableInNewSpace(instance_size) && | 1029 if (FLAG_inline_alloc && Heap::IsAllocatableInNewSpace(instance_size) && |
1023 !cls.trace_allocation()) { | 1030 !cls.TraceAllocation(isolate)) { |
1024 Label slow_case; | 1031 Label slow_case; |
1025 // Allocate the object and update top to point to | 1032 // Allocate the object and update top to point to |
1026 // next object start and initialize the allocated object. | 1033 // next object start and initialize the allocated object. |
1027 // EDX: instantiated type arguments (if is_cls_parameterized). | 1034 // EDX: instantiated type arguments (if is_cls_parameterized). |
1028 Heap::Space space = Heap::SpaceForAllocation(cls.id()); | 1035 Heap::Space space = Heap::SpaceForAllocation(cls.id()); |
1029 __ movl(EDI, Address(THR, Thread::heap_offset())); | 1036 __ movl(EDI, Address(THR, Thread::heap_offset())); |
1030 __ movl(EAX, Address(EDI, Heap::TopOffset(space))); | 1037 __ movl(EAX, Address(EDI, Heap::TopOffset(space))); |
1031 __ leal(EBX, Address(EAX, instance_size)); | 1038 __ leal(EBX, Address(EAX, instance_size)); |
1032 // Check if the allocation fits into the remaining space. | 1039 // Check if the allocation fits into the remaining space. |
1033 // EAX: potential new object start. | 1040 // EAX: potential new object start. |
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2080 // EBX: entry point. | 2087 // EBX: entry point. |
2081 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { | 2088 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { |
2082 EmitMegamorphicLookup(assembler, EDI, EBX, EBX); | 2089 EmitMegamorphicLookup(assembler, EDI, EBX, EBX); |
2083 __ ret(); | 2090 __ ret(); |
2084 } | 2091 } |
2085 | 2092 |
2086 | 2093 |
2087 } // namespace dart | 2094 } // namespace dart |
2088 | 2095 |
2089 #endif // defined TARGET_ARCH_IA32 | 2096 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |