Chromium Code Reviews| 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_X64) | |
| 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 Register class_reg, | |
| 22 Label* failure, | |
| 23 Register instance_reg) { | |
| 24 #if defined(DEBUG) | |
|
Ivan Posva
2011/11/30 23:50:29
This whole thing needs to start with:
__ Untested(
regis
2011/12/01 00:08:50
Done.
| |
| 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); | |
| 33 ASSERT(class_reg != instance_reg); | |
| 34 if (FLAG_inline_alloc) { | |
| 35 Heap* heap = Isolate::Current()->heap(); | |
| 36 const intptr_t instance_size = cls.instance_size(); | |
| 37 __ movq(instance_reg, Address::Absolute(heap->TopAddress())); | |
| 38 __ addq(instance_reg, Immediate(instance_size)); | |
| 39 // instance_reg: potential next object start. | |
| 40 __ cmpq(instance_reg, Address::Absolute(heap->EndAddress())); | |
| 41 __ j(ABOVE_EQUAL, failure, Assembler::kNearJump); | |
| 42 // Successfully allocated the object, now update top to point to | |
| 43 // next object start and store the class in the class field of object. | |
| 44 __ movq(Address::Absolute(heap->TopAddress()), instance_reg); | |
| 45 ASSERT(instance_size >= kHeapObjectTag); | |
| 46 __ subq(instance_reg, Immediate(instance_size - kHeapObjectTag)); | |
| 47 __ movq(FieldAddress(instance_reg, Instance::class_offset()), class_reg); | |
| 48 } else { | |
| 49 __ jmp(failure); | |
| 50 } | |
| 51 } | |
| 52 | |
| 53 #undef __ | |
| 54 | |
| 55 } // namespace dart | |
| 56 | |
| 57 #endif // defined TARGET_ARCH_X64 | |
| OLD | NEW |