| Index: runtime/vm/assembler_x64.cc
|
| ===================================================================
|
| --- runtime/vm/assembler_x64.cc (revision 43497)
|
| +++ runtime/vm/assembler_x64.cc (working copy)
|
| @@ -23,8 +23,6 @@
|
|
|
| Assembler::Assembler(bool use_far_branches)
|
| : buffer_(),
|
| - object_pool_(GrowableObjectArray::Handle()),
|
| - patchable_pool_entries_(),
|
| prologue_offset_(-1),
|
| comments_(),
|
| allow_constant_pool_(true) {
|
| @@ -32,66 +30,55 @@
|
| ASSERT(!use_far_branches);
|
| Isolate* isolate = Isolate::Current();
|
| if (isolate != Dart::vm_isolate()) {
|
| - object_pool_ = GrowableObjectArray::New(Heap::kOld);
|
| -
|
| // These objects and labels need to be accessible through every pool-pointer
|
| // at the same index.
|
| - object_pool_.Add(Object::null_object(), Heap::kOld);
|
| - patchable_pool_entries_.Add(kNotPatchable);
|
| - object_pool_index_table_.Insert(ObjIndexPair(&Object::null_object(), 0));
|
| + intptr_t index =
|
| + object_pool_.AddObject(Object::null_object(), kNotPatchable);
|
| + ASSERT(index == 0);
|
|
|
| - object_pool_.Add(Bool::True(), Heap::kOld);
|
| - patchable_pool_entries_.Add(kNotPatchable);
|
| - object_pool_index_table_.Insert(ObjIndexPair(&Bool::True(), 1));
|
| + index = object_pool_.AddObject(Bool::True(), kNotPatchable);
|
| + ASSERT(index == 1);
|
|
|
| - object_pool_.Add(Bool::False(), Heap::kOld);
|
| - patchable_pool_entries_.Add(kNotPatchable);
|
| - object_pool_index_table_.Insert(ObjIndexPair(&Bool::False(), 2));
|
| + index = object_pool_.AddObject(Bool::False(), kNotPatchable);
|
| + ASSERT(index == 2);
|
|
|
| const Smi& vacant = Smi::Handle(Smi::New(0xfa >> kSmiTagShift));
|
| -
|
| StubCode* stub_code = isolate->stub_code();
|
| if (stub_code->UpdateStoreBuffer_entry() != NULL) {
|
| - FindExternalLabel(&stub_code->UpdateStoreBufferLabel(), kNotPatchable);
|
| + object_pool_.AddExternalLabel(&stub_code->UpdateStoreBufferLabel(),
|
| + kNotPatchable);
|
| } else {
|
| - object_pool_.Add(vacant, Heap::kOld);
|
| - patchable_pool_entries_.Add(kNotPatchable);
|
| + object_pool_.AddObject(vacant, kNotPatchable);
|
| }
|
|
|
| if (stub_code->CallToRuntime_entry() != NULL) {
|
| - FindExternalLabel(&stub_code->CallToRuntimeLabel(), kNotPatchable);
|
| + object_pool_.AddExternalLabel(&stub_code->CallToRuntimeLabel(),
|
| + kNotPatchable);
|
| } else {
|
| - object_pool_.Add(vacant, Heap::kOld);
|
| - patchable_pool_entries_.Add(kNotPatchable);
|
| + object_pool_.AddObject(vacant, kNotPatchable);
|
| }
|
|
|
| // Create fixed object pool entries for debugger stubs.
|
| if (stub_code->ICCallBreakpoint_entry() != NULL) {
|
| - intptr_t index =
|
| - FindExternalLabel(&stub_code->ICCallBreakpointLabel(),
|
| - kNotPatchable);
|
| + index = object_pool_.AddExternalLabel(
|
| + &stub_code->ICCallBreakpointLabel(), kNotPatchable);
|
| ASSERT(index == kICCallBreakpointCPIndex);
|
| } else {
|
| - object_pool_.Add(vacant, Heap::kOld);
|
| - patchable_pool_entries_.Add(kNotPatchable);
|
| + object_pool_.AddObject(vacant, kNotPatchable);
|
| }
|
| if (stub_code->ClosureCallBreakpoint_entry() != NULL) {
|
| - intptr_t index =
|
| - FindExternalLabel(&stub_code->ClosureCallBreakpointLabel(),
|
| - kNotPatchable);
|
| + index = object_pool_.AddExternalLabel(
|
| + &stub_code->ClosureCallBreakpointLabel(), kNotPatchable);
|
| ASSERT(index == kClosureCallBreakpointCPIndex);
|
| } else {
|
| - object_pool_.Add(vacant, Heap::kOld);
|
| - patchable_pool_entries_.Add(kNotPatchable);
|
| + object_pool_.AddObject(vacant, kNotPatchable);
|
| }
|
| if (stub_code->RuntimeCallBreakpoint_entry() != NULL) {
|
| - intptr_t index =
|
| - FindExternalLabel(&stub_code->RuntimeCallBreakpointLabel(),
|
| - kNotPatchable);
|
| + index = object_pool_.AddExternalLabel(
|
| + &stub_code->RuntimeCallBreakpointLabel(), kNotPatchable);
|
| ASSERT(index == kRuntimeCallBreakpointCPIndex);
|
| } else {
|
| - object_pool_.Add(vacant, Heap::kOld);
|
| - patchable_pool_entries_.Add(kNotPatchable);
|
| + object_pool_.AddObject(vacant, kNotPatchable);
|
| }
|
| }
|
| }
|
| @@ -132,7 +119,7 @@
|
| Patchability patchable,
|
| Register pp) {
|
| const int32_t offset =
|
| - Array::element_offset(FindExternalLabel(label, patchable));
|
| + Array::element_offset(object_pool_.FindExternalLabel(label, patchable));
|
| LoadWordFromPoolOffset(dst, pp, offset - kHeapObjectTag);
|
| }
|
|
|
| @@ -152,7 +139,7 @@
|
| ASSERT(allow_constant_pool());
|
| intptr_t call_start = buffer_.GetPosition();
|
| const int32_t offset =
|
| - Array::element_offset(FindExternalLabel(label, kPatchable));
|
| + Array::element_offset(object_pool_.FindExternalLabel(label, kPatchable));
|
| call(Address::AddressBaseImm32(PP, offset - kHeapObjectTag));
|
| ASSERT((buffer_.GetPosition() - call_start) == kCallExternalLabelSize);
|
| }
|
| @@ -162,8 +149,8 @@
|
| if (Isolate::Current() == Dart::vm_isolate()) {
|
| call(label);
|
| } else {
|
| - const int32_t offset =
|
| - Array::element_offset(FindExternalLabel(label, kNotPatchable));
|
| + const int32_t offset = Array::element_offset(
|
| + object_pool_.FindExternalLabel(label, kNotPatchable));
|
| call(Address::AddressBaseImm32(pp, offset - kHeapObjectTag));
|
| }
|
| }
|
| @@ -2620,7 +2607,7 @@
|
| ASSERT(allow_constant_pool());
|
| intptr_t call_start = buffer_.GetPosition();
|
| const int32_t offset =
|
| - Array::element_offset(FindExternalLabel(label, kPatchable));
|
| + Array::element_offset(object_pool_.FindExternalLabel(label, kPatchable));
|
| // Patchable jumps always use a 32-bit immediate encoding.
|
| jmp(Address::AddressBaseImm32(pp, offset - kHeapObjectTag));
|
| ASSERT((buffer_.GetPosition() - call_start) == JumpPattern::kLengthInBytes);
|
| @@ -2628,8 +2615,8 @@
|
|
|
|
|
| void Assembler::Jmp(const ExternalLabel* label, Register pp) {
|
| - const int32_t offset =
|
| - Array::element_offset(FindExternalLabel(label, kNotPatchable));
|
| + const int32_t offset = Array::element_offset(
|
| + object_pool_.FindExternalLabel(label, kNotPatchable));
|
| jmp(Address(pp, offset - kHeapObjectTag));
|
| }
|
|
|
| @@ -2786,54 +2773,6 @@
|
| }
|
|
|
|
|
| -intptr_t Assembler::FindObject(const Object& obj, Patchability patchable) {
|
| - // The object pool cannot be used in the vm isolate.
|
| - ASSERT(Isolate::Current() != Dart::vm_isolate());
|
| - ASSERT(!object_pool_.IsNull());
|
| -
|
| - // If the object is not patchable, check if we've already got it in the
|
| - // object pool.
|
| - if (patchable == kNotPatchable) {
|
| - intptr_t idx = object_pool_index_table_.Lookup(&obj);
|
| - if (idx != ObjIndexPair::kNoIndex) {
|
| - ASSERT(patchable_pool_entries_[idx] == kNotPatchable);
|
| - return idx;
|
| - }
|
| - }
|
| -
|
| - object_pool_.Add(obj, Heap::kOld);
|
| - patchable_pool_entries_.Add(patchable);
|
| - if (patchable == kNotPatchable) {
|
| - // The object isn't patchable. Record the index for fast lookup.
|
| - object_pool_index_table_.Insert(
|
| - ObjIndexPair(&obj, object_pool_.Length() - 1));
|
| - }
|
| - return object_pool_.Length() - 1;
|
| -}
|
| -
|
| -
|
| -intptr_t Assembler::FindExternalLabel(const ExternalLabel* label,
|
| - Patchability patchable) {
|
| - // The object pool cannot be used in the vm isolate.
|
| - ASSERT(Isolate::Current() != Dart::vm_isolate());
|
| - ASSERT(!object_pool_.IsNull());
|
| - const uword address = label->address();
|
| - ASSERT(Utils::IsAligned(address, 4));
|
| - // The address is stored in the object array as a RawSmi.
|
| - const Smi& smi = Smi::Handle(reinterpret_cast<RawSmi*>(address));
|
| - if (patchable == kNotPatchable) {
|
| - // If the call site is not patchable, we can try to re-use an existing
|
| - // entry.
|
| - return FindObject(smi, kNotPatchable);
|
| - }
|
| - // If the call is patchable, do not reuse an existing entry since each
|
| - // reference may be patched independently.
|
| - object_pool_.Add(smi, Heap::kOld);
|
| - patchable_pool_entries_.Add(patchable);
|
| - return object_pool_.Length() - 1;
|
| -}
|
| -
|
| -
|
| // A set of VM objects that are present in every constant pool.
|
| static bool IsAlwaysInConstantPool(const Object& object) {
|
| // TODO(zra): Evaluate putting all VM heap objects into the pool.
|
| @@ -2877,7 +2816,7 @@
|
| void Assembler::LoadObject(Register dst, const Object& object, Register pp) {
|
| if (CanLoadFromObjectPool(object)) {
|
| const int32_t offset =
|
| - Array::element_offset(FindObject(object, kNotPatchable));
|
| + Array::element_offset(object_pool_.FindObject(object, kNotPatchable));
|
| LoadWordFromPoolOffset(dst, pp, offset - kHeapObjectTag);
|
| } else {
|
| ASSERT((Isolate::Current() == Dart::vm_isolate()) ||
|
| @@ -2912,7 +2851,7 @@
|
| void Assembler::CompareObject(Register reg, const Object& object, Register pp) {
|
| if (CanLoadFromObjectPool(object)) {
|
| const int32_t offset =
|
| - Array::element_offset(FindObject(object, kNotPatchable));
|
| + Array::element_offset(object_pool_.FindObject(object, kNotPatchable));
|
| cmpq(reg, Address(pp, offset-kHeapObjectTag));
|
| } else {
|
| CompareImmediate(
|
| @@ -2923,9 +2862,8 @@
|
|
|
| intptr_t Assembler::FindImmediate(int64_t imm) {
|
| ASSERT(Isolate::Current() != Dart::vm_isolate());
|
| - ASSERT(!object_pool_.IsNull());
|
| const Smi& smi = Smi::Handle(reinterpret_cast<RawSmi*>(imm));
|
| - return FindObject(smi, kNotPatchable);
|
| + return object_pool_.FindObject(smi, kNotPatchable);
|
| }
|
|
|
|
|
|
|