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_X64) | 6 #if defined(TARGET_ARCH_X64) |
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 Label* failure, | 21 Label* failure, |
| 22 bool near_jump, |
22 Register instance_reg) { | 23 Register instance_reg) { |
23 ASSERT(failure != NULL); | 24 ASSERT(failure != NULL); |
24 if (FLAG_inline_alloc) { | 25 if (FLAG_inline_alloc) { |
25 Heap* heap = Isolate::Current()->heap(); | 26 Heap* heap = Isolate::Current()->heap(); |
26 const intptr_t instance_size = cls.instance_size(); | 27 const intptr_t instance_size = cls.instance_size(); |
27 __ movq(TMP, Immediate(heap->TopAddress())); | 28 __ movq(TMP, Immediate(heap->TopAddress())); |
28 __ movq(instance_reg, Address(TMP, 0)); | 29 __ movq(instance_reg, Address(TMP, 0)); |
29 __ addq(instance_reg, Immediate(instance_size)); | 30 __ addq(instance_reg, Immediate(instance_size)); |
30 // instance_reg: potential next object start. | 31 // instance_reg: potential next object start. |
31 __ movq(TMP, Immediate(heap->EndAddress())); | 32 __ movq(TMP, Immediate(heap->EndAddress())); |
32 __ cmpq(instance_reg, Address(TMP, 0)); | 33 __ cmpq(instance_reg, Address(TMP, 0)); |
33 __ j(ABOVE_EQUAL, failure, Assembler::kNearJump); | 34 __ j(ABOVE_EQUAL, failure, near_jump); |
34 // Successfully allocated the object, now update top to point to | 35 // Successfully allocated the object, now update top to point to |
35 // next object start and store the class in the class field of object. | 36 // next object start and store the class in the class field of object. |
36 __ movq(TMP, Immediate(heap->TopAddress())); | 37 __ movq(TMP, Immediate(heap->TopAddress())); |
37 __ movq(Address(TMP, 0), instance_reg); | 38 __ movq(Address(TMP, 0), instance_reg); |
38 ASSERT(instance_size >= kHeapObjectTag); | 39 ASSERT(instance_size >= kHeapObjectTag); |
39 __ subq(instance_reg, Immediate(instance_size - kHeapObjectTag)); | 40 __ subq(instance_reg, Immediate(instance_size - kHeapObjectTag)); |
40 uword tags = 0; | 41 uword tags = 0; |
41 tags = RawObject::SizeTag::update(instance_size, tags); | 42 tags = RawObject::SizeTag::update(instance_size, tags); |
42 ASSERT(cls.id() != kIllegalCid); | 43 ASSERT(cls.id() != kIllegalCid); |
43 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 44 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 void AssemblerMacros::EnterStubFrame(Assembler* assembler) { | 84 void AssemblerMacros::EnterStubFrame(Assembler* assembler) { |
84 __ EnterFrame(0); | 85 __ EnterFrame(0); |
85 __ pushq(Immediate(0)); // Push 0 in the saved PC area for stub frames. | 86 __ pushq(Immediate(0)); // Push 0 in the saved PC area for stub frames. |
86 } | 87 } |
87 | 88 |
88 #undef __ | 89 #undef __ |
89 | 90 |
90 } // namespace dart | 91 } // namespace dart |
91 | 92 |
92 #endif // defined TARGET_ARCH_X64 | 93 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |