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_macros.h" | 8 #include "vm/assembler_macros.h" |
9 | 9 |
10 #include "vm/assembler.h" | 10 #include "vm/assembler.h" |
11 | 11 |
12 namespace dart { | 12 namespace dart { |
13 | 13 |
14 DECLARE_FLAG(bool, inline_alloc); | 14 DECLARE_FLAG(bool, inline_alloc); |
15 | 15 |
16 #define __ assembler-> | 16 #define __ assembler-> |
17 | 17 |
18 // Static. | 18 // Static. |
19 void AssemblerMacros::TryAllocate(Assembler* assembler, | 19 void AssemblerMacros::TryAllocate(Assembler* assembler, |
20 const Class& cls, | 20 const Class& cls, |
21 Register class_reg, | |
22 Label* failure, | 21 Label* failure, |
23 Register instance_reg) { | 22 Register instance_reg) { |
24 #if defined(DEBUG) | |
25 Label ok; | |
26 __ LoadObject(instance_reg, cls); | |
27 __ cmpl(instance_reg, class_reg); | |
28 __ j(EQUAL, &ok, Assembler::kNearJump); | |
29 __ Stop("AssemblerMacros::TryAllocate, wrong arguments"); | |
30 __ Bind(&ok); | |
31 #endif | |
32 ASSERT(failure != NULL); | 23 ASSERT(failure != NULL); |
33 ASSERT(class_reg != instance_reg); | |
34 if (FLAG_inline_alloc) { | 24 if (FLAG_inline_alloc) { |
35 Heap* heap = Isolate::Current()->heap(); | 25 Heap* heap = Isolate::Current()->heap(); |
36 const intptr_t instance_size = cls.instance_size(); | 26 const intptr_t instance_size = cls.instance_size(); |
37 __ movl(instance_reg, Address::Absolute(heap->TopAddress())); | 27 __ movl(instance_reg, Address::Absolute(heap->TopAddress())); |
38 __ addl(instance_reg, Immediate(instance_size)); | 28 __ addl(instance_reg, Immediate(instance_size)); |
39 // instance_reg: potential next object start. | 29 // instance_reg: potential next object start. |
40 __ cmpl(instance_reg, Address::Absolute(heap->EndAddress())); | 30 __ cmpl(instance_reg, Address::Absolute(heap->EndAddress())); |
41 __ j(ABOVE_EQUAL, failure, Assembler::kNearJump); | 31 __ j(ABOVE_EQUAL, failure, Assembler::kNearJump); |
42 // Successfully allocated the object, now update top to point to | 32 // Successfully allocated the object, now update top to point to |
43 // next object start and store the class in the class field of object. | 33 // next object start and store the class in the class field of object. |
44 __ movl(Address::Absolute(heap->TopAddress()), instance_reg); | 34 __ movl(Address::Absolute(heap->TopAddress()), instance_reg); |
45 ASSERT(instance_size >= kHeapObjectTag); | 35 ASSERT(instance_size >= kHeapObjectTag); |
46 __ subl(instance_reg, Immediate(instance_size - kHeapObjectTag)); | 36 __ subl(instance_reg, Immediate(instance_size - kHeapObjectTag)); |
47 __ StoreIntoObject(instance_reg, | |
48 FieldAddress(instance_reg, Instance::class_offset()), | |
49 class_reg); | |
50 uword tags = 0; | 37 uword tags = 0; |
51 tags = RawObject::SizeTag::update(instance_size, tags); | 38 tags = RawObject::SizeTag::update(instance_size, tags); |
52 ASSERT(cls.id() != kIllegalObjectKind); | 39 ASSERT(cls.id() != kIllegalObjectKind); |
53 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 40 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
54 __ movl(FieldAddress(instance_reg, Object::tags_offset()), Immediate(tags)); | 41 __ movl(FieldAddress(instance_reg, Object::tags_offset()), Immediate(tags)); |
55 } else { | 42 } else { |
56 __ jmp(failure); | 43 __ jmp(failure); |
57 } | 44 } |
58 } | 45 } |
59 | 46 |
(...skipping 19 matching lines...) Expand all Loading... |
79 void AssemblerMacros::EnterStubFrame(Assembler* assembler) { | 66 void AssemblerMacros::EnterStubFrame(Assembler* assembler) { |
80 __ EnterFrame(0); | 67 __ EnterFrame(0); |
81 __ pushl(Immediate(0)); // Push 0 in the saved PC area for stub frames. | 68 __ pushl(Immediate(0)); // Push 0 in the saved PC area for stub frames. |
82 } | 69 } |
83 | 70 |
84 #undef __ | 71 #undef __ |
85 | 72 |
86 } // namespace dart | 73 } // namespace dart |
87 | 74 |
88 #endif // defined TARGET_ARCH_IA32 | 75 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |