Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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_ARM64) | 6 #if defined(TARGET_ARCH_ARM64) |
| 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/longjump.h" | 10 #include "vm/longjump.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 use_far_branches_(use_far_branches), | 33 use_far_branches_(use_far_branches), |
| 34 comments_(), | 34 comments_(), |
| 35 allow_constant_pool_(true) { | 35 allow_constant_pool_(true) { |
| 36 if (Isolate::Current() != Dart::vm_isolate()) { | 36 if (Isolate::Current() != Dart::vm_isolate()) { |
| 37 object_pool_ = GrowableObjectArray::New(Heap::kOld); | 37 object_pool_ = GrowableObjectArray::New(Heap::kOld); |
| 38 | 38 |
| 39 // These objects and labels need to be accessible through every pool-pointer | 39 // These objects and labels need to be accessible through every pool-pointer |
| 40 // at the same index. | 40 // at the same index. |
| 41 object_pool_.Add(Object::null_object(), Heap::kOld); | 41 object_pool_.Add(Object::null_object(), Heap::kOld); |
| 42 patchable_pool_entries_.Add(kNotPatchable); | 42 patchable_pool_entries_.Add(kNotPatchable); |
| 43 // Not adding Object::null() to the index table. It is at index 0 in the | 43 object_pool_index_table_.Insert(ObjIndexPair(&Object::null_object(), 0)); |
|
Ivan Posva
2015/01/15 23:59:58
We have three data structures in the assembler tha
| |
| 44 // object pool, but the HashMap uses 0 to indicate not found. | |
| 45 | 44 |
| 46 object_pool_.Add(Bool::True(), Heap::kOld); | 45 object_pool_.Add(Bool::True(), Heap::kOld); |
| 47 patchable_pool_entries_.Add(kNotPatchable); | 46 patchable_pool_entries_.Add(kNotPatchable); |
| 48 object_pool_index_table_.Insert(ObjIndexPair(Bool::True().raw(), 1)); | 47 object_pool_index_table_.Insert(ObjIndexPair(&Bool::True(), 1)); |
| 49 | 48 |
| 50 object_pool_.Add(Bool::False(), Heap::kOld); | 49 object_pool_.Add(Bool::False(), Heap::kOld); |
| 51 patchable_pool_entries_.Add(kNotPatchable); | 50 patchable_pool_entries_.Add(kNotPatchable); |
| 52 object_pool_index_table_.Insert(ObjIndexPair(Bool::False().raw(), 2)); | 51 object_pool_index_table_.Insert(ObjIndexPair(&Bool::False(), 2)); |
| 53 | 52 |
| 54 const Smi& vacant = Smi::Handle(Smi::New(0xfa >> kSmiTagShift)); | 53 const Smi& vacant = Smi::Handle(Smi::New(0xfa >> kSmiTagShift)); |
| 55 StubCode* stub_code = Isolate::Current()->stub_code(); | 54 StubCode* stub_code = Isolate::Current()->stub_code(); |
| 56 | 55 |
| 57 if (stub_code->UpdateStoreBuffer_entry() != NULL) { | 56 if (stub_code->UpdateStoreBuffer_entry() != NULL) { |
| 58 FindExternalLabel(&stub_code->UpdateStoreBufferLabel(), kNotPatchable); | 57 FindExternalLabel(&stub_code->UpdateStoreBufferLabel(), kNotPatchable); |
| 59 } else { | 58 } else { |
| 60 object_pool_.Add(vacant, Heap::kOld); | 59 object_pool_.Add(vacant, Heap::kOld); |
| 61 patchable_pool_entries_.Add(kNotPatchable); | 60 patchable_pool_entries_.Add(kNotPatchable); |
| 62 } | 61 } |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 448 | 447 |
| 449 | 448 |
| 450 intptr_t Assembler::FindObject(const Object& obj, Patchability patchable) { | 449 intptr_t Assembler::FindObject(const Object& obj, Patchability patchable) { |
| 451 // The object pool cannot be used in the vm isolate. | 450 // The object pool cannot be used in the vm isolate. |
| 452 ASSERT(Isolate::Current() != Dart::vm_isolate()); | 451 ASSERT(Isolate::Current() != Dart::vm_isolate()); |
| 453 ASSERT(!object_pool_.IsNull()); | 452 ASSERT(!object_pool_.IsNull()); |
| 454 | 453 |
| 455 // If the object is not patchable, check if we've already got it in the | 454 // If the object is not patchable, check if we've already got it in the |
| 456 // object pool. | 455 // object pool. |
| 457 if (patchable == kNotPatchable) { | 456 if (patchable == kNotPatchable) { |
| 458 // Special case for Object::null(), which is always at object_pool_ index 0 | 457 intptr_t idx = object_pool_index_table_.Lookup(&obj); |
| 459 // because Lookup() below returns 0 when the object is not mapped in the | 458 if (idx != ObjIndexPair::kNoIndex) { |
| 460 // table. | |
| 461 if (obj.raw() == Object::null()) { | |
| 462 return 0; | |
| 463 } | |
| 464 | |
| 465 intptr_t idx = object_pool_index_table_.Lookup(obj.raw()); | |
| 466 if (idx != 0) { | |
| 467 ASSERT(patchable_pool_entries_[idx] == kNotPatchable); | 459 ASSERT(patchable_pool_entries_[idx] == kNotPatchable); |
| 468 return idx; | 460 return idx; |
| 469 } | 461 } |
| 470 } | 462 } |
| 471 | 463 |
| 472 object_pool_.Add(obj, Heap::kOld); | 464 object_pool_.Add(obj, Heap::kOld); |
| 473 patchable_pool_entries_.Add(patchable); | 465 patchable_pool_entries_.Add(patchable); |
| 474 if (patchable == kNotPatchable) { | 466 if (patchable == kNotPatchable) { |
| 475 // The object isn't patchable. Record the index for fast lookup. | 467 // The object isn't patchable. Record the index for fast lookup. |
| 476 object_pool_index_table_.Insert( | 468 object_pool_index_table_.Insert( |
| 477 ObjIndexPair(obj.raw(), object_pool_.Length() - 1)); | 469 ObjIndexPair(&obj, object_pool_.Length() - 1)); |
| 478 } | 470 } |
| 479 return object_pool_.Length() - 1; | 471 return object_pool_.Length() - 1; |
| 480 } | 472 } |
| 481 | 473 |
| 482 | 474 |
| 483 intptr_t Assembler::FindImmediate(int64_t imm) { | 475 intptr_t Assembler::FindImmediate(int64_t imm) { |
| 484 ASSERT(Isolate::Current() != Dart::vm_isolate()); | 476 ASSERT(Isolate::Current() != Dart::vm_isolate()); |
| 485 ASSERT(!object_pool_.IsNull()); | 477 ASSERT(!object_pool_.IsNull()); |
| 486 const Smi& smi = Smi::Handle(reinterpret_cast<RawSmi*>(imm)); | 478 const Smi& smi = Smi::Handle(reinterpret_cast<RawSmi*>(imm)); |
| 487 return FindObject(smi, kNotPatchable); | 479 return FindObject(smi, kNotPatchable); |
| (...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1557 add(base, array, Operand(index, LSL, shift)); | 1549 add(base, array, Operand(index, LSL, shift)); |
| 1558 } | 1550 } |
| 1559 const OperandSize size = Address::OperandSizeFor(cid); | 1551 const OperandSize size = Address::OperandSizeFor(cid); |
| 1560 ASSERT(Address::CanHoldOffset(offset, Address::Offset, size)); | 1552 ASSERT(Address::CanHoldOffset(offset, Address::Offset, size)); |
| 1561 return Address(base, offset, Address::Offset, size); | 1553 return Address(base, offset, Address::Offset, size); |
| 1562 } | 1554 } |
| 1563 | 1555 |
| 1564 } // namespace dart | 1556 } // namespace dart |
| 1565 | 1557 |
| 1566 #endif // defined TARGET_ARCH_ARM64 | 1558 #endif // defined TARGET_ARCH_ARM64 |
| OLD | NEW |