OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 #include "vm/globals.h" | |
6 #if defined(TARGET_ARCH_IA32) | |
7 | |
8 #include "vm/assembler_macros.h" | |
9 | |
10 #include "vm/assembler.h" | |
11 | |
12 namespace dart { | |
13 | |
14 DECLARE_FLAG(bool, inline_alloc); | |
15 | |
16 #define __ assembler-> | |
17 | |
18 // Static. | |
19 void AssemblerMacros::TryAllocate(Assembler* assembler, | |
20 const Class& cls, | |
21 Label* failure, | |
22 bool near_jump, | |
23 Register instance_reg) { | |
24 ASSERT(failure != NULL); | |
25 if (FLAG_inline_alloc) { | |
26 Heap* heap = Isolate::Current()->heap(); | |
27 const intptr_t instance_size = cls.instance_size(); | |
28 __ movl(instance_reg, Address::Absolute(heap->TopAddress())); | |
29 __ addl(instance_reg, Immediate(instance_size)); | |
30 // instance_reg: potential next object start. | |
31 __ cmpl(instance_reg, Address::Absolute(heap->EndAddress())); | |
32 __ j(ABOVE_EQUAL, failure, near_jump); | |
33 // Successfully allocated the object, now update top to point to | |
34 // next object start and store the class in the class field of object. | |
35 __ movl(Address::Absolute(heap->TopAddress()), instance_reg); | |
36 ASSERT(instance_size >= kHeapObjectTag); | |
37 __ subl(instance_reg, Immediate(instance_size - kHeapObjectTag)); | |
38 uword tags = 0; | |
39 tags = RawObject::SizeTag::update(instance_size, tags); | |
40 ASSERT(cls.id() != kIllegalCid); | |
41 tags = RawObject::ClassIdTag::update(cls.id(), tags); | |
42 __ movl(FieldAddress(instance_reg, Object::tags_offset()), Immediate(tags)); | |
43 } else { | |
44 __ jmp(failure); | |
45 } | |
46 } | |
47 | |
48 | |
49 void AssemblerMacros::EnterDartFrame(Assembler* assembler, | |
50 intptr_t frame_size) { | |
51 const intptr_t offset = assembler->CodeSize(); | |
52 __ EnterFrame(0); | |
53 Label dart_entry; | |
54 __ call(&dart_entry); | |
55 __ Bind(&dart_entry); | |
56 // Adjust saved PC for any intrinsic code that could have been generated | |
57 // before a frame is created. | |
58 if (offset != 0) { | |
59 __ addl(Address(ESP, 0), Immediate(-offset)); | |
60 } | |
61 if (frame_size != 0) { | |
62 __ subl(ESP, Immediate(frame_size)); | |
63 } | |
64 } | |
65 | |
66 | |
67 void AssemblerMacros::EnterStubFrame(Assembler* assembler) { | |
68 __ EnterFrame(0); | |
69 __ pushl(Immediate(0)); // Push 0 in the saved PC area for stub frames. | |
70 } | |
71 | |
72 #undef __ | |
73 | |
74 } // namespace dart | |
75 | |
76 #endif // defined TARGET_ARCH_IA32 | |
OLD | NEW |