Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(712)

Unified Diff: runtime/vm/assembler.cc

Issue 886173003: VM: Align implementations of assembler constant pools. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/assembler.cc
===================================================================
--- runtime/vm/assembler.cc (revision 43497)
+++ runtime/vm/assembler.cc (working copy)
@@ -241,4 +241,67 @@
return comments;
}
+
+intptr_t ObjectPool::AddObject(const Object& obj, Patchability patchable) {
+ if (object_pool_.IsNull()) {
+ // The object pool cannot be used in the vm isolate.
+ ASSERT(Isolate::Current() != Dart::vm_isolate());
+ object_pool_ = GrowableObjectArray::New(Heap::kOld);
+ }
+ 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 ObjectPool::AddExternalLabel(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));
+ return AddObject(smi, patchable);
+}
+
+
+intptr_t ObjectPool::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;
+ }
+ }
+
+ return AddObject(obj, patchable);
+}
+
+
+intptr_t ObjectPool::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));
+ return FindObject(smi, patchable);
+}
+
+
} // namespace dart
« no previous file with comments | « runtime/vm/assembler.h ('k') | runtime/vm/assembler_arm.h » ('j') | runtime/vm/assembler_arm.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698