| 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" // NOLINT | 5 #include "vm/globals.h" // NOLINT |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
| 10 #include "vm/heap.h" | 10 #include "vm/heap.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // Far branching mode is only needed and implemented for MIPS and ARM. | 30 // Far branching mode is only needed and implemented for MIPS and ARM. |
| 31 ASSERT(!use_far_branches); | 31 ASSERT(!use_far_branches); |
| 32 Isolate* isolate = Isolate::Current(); | 32 Isolate* isolate = Isolate::Current(); |
| 33 if (isolate != Dart::vm_isolate()) { | 33 if (isolate != Dart::vm_isolate()) { |
| 34 object_pool_ = GrowableObjectArray::New(Heap::kOld); | 34 object_pool_ = GrowableObjectArray::New(Heap::kOld); |
| 35 | 35 |
| 36 // These objects and labels need to be accessible through every pool-pointer | 36 // These objects and labels need to be accessible through every pool-pointer |
| 37 // at the same index. | 37 // at the same index. |
| 38 object_pool_.Add(Object::null_object(), Heap::kOld); | 38 object_pool_.Add(Object::null_object(), Heap::kOld); |
| 39 patchable_pool_entries_.Add(kNotPatchable); | 39 patchable_pool_entries_.Add(kNotPatchable); |
| 40 // Not adding Object::null() to the index table. It is at index 0 in the | 40 object_pool_index_table_.Insert(ObjIndexPair(&Object::null_object(), 0)); |
| 41 // object pool, but the HashMap uses 0 to indicate not found. | |
| 42 | 41 |
| 43 object_pool_.Add(Bool::True(), Heap::kOld); | 42 object_pool_.Add(Bool::True(), Heap::kOld); |
| 44 patchable_pool_entries_.Add(kNotPatchable); | 43 patchable_pool_entries_.Add(kNotPatchable); |
| 45 object_pool_index_table_.Insert(ObjIndexPair(Bool::True().raw(), 1)); | 44 object_pool_index_table_.Insert(ObjIndexPair(&Bool::True(), 1)); |
| 46 | 45 |
| 47 object_pool_.Add(Bool::False(), Heap::kOld); | 46 object_pool_.Add(Bool::False(), Heap::kOld); |
| 48 patchable_pool_entries_.Add(kNotPatchable); | 47 patchable_pool_entries_.Add(kNotPatchable); |
| 49 object_pool_index_table_.Insert(ObjIndexPair(Bool::False().raw(), 2)); | 48 object_pool_index_table_.Insert(ObjIndexPair(&Bool::False(), 2)); |
| 50 | 49 |
| 51 const Smi& vacant = Smi::Handle(Smi::New(0xfa >> kSmiTagShift)); | 50 const Smi& vacant = Smi::Handle(Smi::New(0xfa >> kSmiTagShift)); |
| 52 | 51 |
| 53 StubCode* stub_code = isolate->stub_code(); | 52 StubCode* stub_code = isolate->stub_code(); |
| 54 if (stub_code->UpdateStoreBuffer_entry() != NULL) { | 53 if (stub_code->UpdateStoreBuffer_entry() != NULL) { |
| 55 FindExternalLabel(&stub_code->UpdateStoreBufferLabel(), kNotPatchable); | 54 FindExternalLabel(&stub_code->UpdateStoreBufferLabel(), kNotPatchable); |
| 56 } else { | 55 } else { |
| 57 object_pool_.Add(vacant, Heap::kOld); | 56 object_pool_.Add(vacant, Heap::kOld); |
| 58 patchable_pool_entries_.Add(kNotPatchable); | 57 patchable_pool_entries_.Add(kNotPatchable); |
| 59 } | 58 } |
| (...skipping 2705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2765 | 2764 |
| 2766 | 2765 |
| 2767 intptr_t Assembler::FindObject(const Object& obj, Patchability patchable) { | 2766 intptr_t Assembler::FindObject(const Object& obj, Patchability patchable) { |
| 2768 // The object pool cannot be used in the vm isolate. | 2767 // The object pool cannot be used in the vm isolate. |
| 2769 ASSERT(Isolate::Current() != Dart::vm_isolate()); | 2768 ASSERT(Isolate::Current() != Dart::vm_isolate()); |
| 2770 ASSERT(!object_pool_.IsNull()); | 2769 ASSERT(!object_pool_.IsNull()); |
| 2771 | 2770 |
| 2772 // If the object is not patchable, check if we've already got it in the | 2771 // If the object is not patchable, check if we've already got it in the |
| 2773 // object pool. | 2772 // object pool. |
| 2774 if (patchable == kNotPatchable) { | 2773 if (patchable == kNotPatchable) { |
| 2775 // Special case for Object::null(), which is always at object_pool_ index 0 | 2774 intptr_t idx = object_pool_index_table_.Lookup(&obj); |
| 2776 // because Lookup() below returns 0 when the object is not mapped in the | 2775 if (idx != ObjIndexPair::NoValue()) { |
| 2777 // table. | |
| 2778 if (obj.raw() == Object::null()) { | |
| 2779 return 0; | |
| 2780 } | |
| 2781 | |
| 2782 intptr_t idx = object_pool_index_table_.Lookup(obj.raw()); | |
| 2783 if (idx != 0) { | |
| 2784 ASSERT(patchable_pool_entries_[idx] == kNotPatchable); | 2776 ASSERT(patchable_pool_entries_[idx] == kNotPatchable); |
| 2785 return idx; | 2777 return idx; |
| 2786 } | 2778 } |
| 2787 } | 2779 } |
| 2788 | 2780 |
| 2789 object_pool_.Add(obj, Heap::kOld); | 2781 object_pool_.Add(obj, Heap::kOld); |
| 2790 patchable_pool_entries_.Add(patchable); | 2782 patchable_pool_entries_.Add(patchable); |
| 2791 if (patchable == kNotPatchable) { | 2783 if (patchable == kNotPatchable) { |
| 2792 // The object isn't patchable. Record the index for fast lookup. | 2784 // The object isn't patchable. Record the index for fast lookup. |
| 2793 object_pool_index_table_.Insert( | 2785 object_pool_index_table_.Insert( |
| 2794 ObjIndexPair(obj.raw(), object_pool_.Length() - 1)); | 2786 ObjIndexPair(&obj, object_pool_.Length() - 1)); |
| 2795 } | 2787 } |
| 2796 return object_pool_.Length() - 1; | 2788 return object_pool_.Length() - 1; |
| 2797 } | 2789 } |
| 2798 | 2790 |
| 2799 | 2791 |
| 2800 intptr_t Assembler::FindExternalLabel(const ExternalLabel* label, | 2792 intptr_t Assembler::FindExternalLabel(const ExternalLabel* label, |
| 2801 Patchability patchable) { | 2793 Patchability patchable) { |
| 2802 // The object pool cannot be used in the vm isolate. | 2794 // The object pool cannot be used in the vm isolate. |
| 2803 ASSERT(Isolate::Current() != Dart::vm_isolate()); | 2795 ASSERT(Isolate::Current() != Dart::vm_isolate()); |
| 2804 ASSERT(!object_pool_.IsNull()); | 2796 ASSERT(!object_pool_.IsNull()); |
| (...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4002 | 3994 |
| 4003 | 3995 |
| 4004 const char* Assembler::FpuRegisterName(FpuRegister reg) { | 3996 const char* Assembler::FpuRegisterName(FpuRegister reg) { |
| 4005 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); | 3997 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); |
| 4006 return xmm_reg_names[reg]; | 3998 return xmm_reg_names[reg]; |
| 4007 } | 3999 } |
| 4008 | 4000 |
| 4009 } // namespace dart | 4001 } // namespace dart |
| 4010 | 4002 |
| 4011 #endif // defined TARGET_ARCH_X64 | 4003 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |