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

Unified Diff: runtime/vm/object.h

Issue 1147303002: Support untagged object pool entries. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: rebased Created 5 years, 7 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/object.h
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index 5bc4ab171b6fdf9a952b9ada01c6702024d931e5..5c2a5f2fd079baed99afc2a51544c8adb8b10497 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -407,6 +407,11 @@ class Object {
return *zero_array_;
}
+ static const ObjectPool& empty_object_pool() {
+ ASSERT(empty_object_pool_ != NULL);
+ return *empty_object_pool_;
+ }
+
static const PcDescriptors& empty_descriptors() {
ASSERT(empty_descriptors_ != NULL);
return *empty_descriptors_;
@@ -503,6 +508,7 @@ class Object {
static RawClass* library_class() { return library_class_; }
static RawClass* namespace_class() { return namespace_class_; }
static RawClass* code_class() { return code_class_; }
+ static RawClass* object_pool_class() { return object_pool_class_; }
static RawClass* instructions_class() { return instructions_class_; }
static RawClass* pc_descriptors_class() { return pc_descriptors_class_; }
static RawClass* stackmap_class() { return stackmap_class_; }
@@ -757,6 +763,7 @@ class Object {
static RawClass* library_class_; // Class of the Library vm object.
static RawClass* namespace_class_; // Class of Namespace vm object.
static RawClass* code_class_; // Class of the Code vm object.
+ static RawClass* object_pool_class_; // Class of the ObjectPool vm object.
static RawClass* instructions_class_; // Class of the Instructions vm object.
static RawClass* pc_descriptors_class_; // Class of PcDescriptors vm object.
static RawClass* stackmap_class_; // Class of Stackmap vm object.
@@ -782,6 +789,7 @@ class Object {
static TypeArguments* null_type_arguments_;
static Array* empty_array_;
static Array* zero_array_;
+ static ObjectPool* empty_object_pool_;
static PcDescriptors* empty_descriptors_;
static LocalVarDescriptors* empty_var_descriptors_;
static ExceptionHandlers* empty_exception_handlers_;
@@ -3172,6 +3180,93 @@ class Namespace : public Object {
};
+class ObjectPool : public Object {
+ public:
+ struct Entry {
+ Entry() : raw_value_() { }
+ explicit Entry(const Object* obj) : obj_(obj) { }
+ explicit Entry(uword value) : raw_value_(value) { }
+ union {
+ const Object* obj_;
+ uword raw_value_;
+ };
+ };
+
+ intptr_t Length() const {
+ return raw_ptr()->length_;
+ }
+ void SetLength(intptr_t value) const {
+ StoreNonPointer(&raw_ptr()->length_, value);
+ }
+
+ intptr_t NumTaggedEntries() const {
+ return raw_ptr()->num_tagged_entries_;
+ }
+
+ void SetNumTaggedEntries(intptr_t value) {
+ StoreNonPointer(&raw_ptr()->num_tagged_entries_, value);
+ }
+
+ static intptr_t data_offset() {
+ return OFFSET_OF_RETURNED_VALUE(RawObjectPool, data);
+ }
+ static intptr_t element_offset(intptr_t index) {
+ return OFFSET_OF_RETURNED_VALUE(RawObjectPool, data)
+ + kBytesPerElement * index;
+ }
+
+ RawObject* ObjectAt(intptr_t index) const {
+ return EntryAddr(index)->raw_obj_;
+ }
+ void SetObjectAt(intptr_t index, const Object& obj) const {
+ StorePointer(&EntryAddr(index)->raw_obj_, obj.raw());
+ }
+
+ uword RawValueAt(intptr_t index) const {
+ return EntryAddr(index)->raw_value_;
+ }
+ void SetRawValueAt(intptr_t index, uword raw_value) const {
+ StoreNonPointer(&EntryAddr(index)->raw_value_, raw_value);
+ }
+
+ void DebugPrint() const;
+
+ static intptr_t InstanceSize() {
+ ASSERT(sizeof(RawObjectPool) ==
+ OFFSET_OF_RETURNED_VALUE(RawObjectPool, data));
+ return 0;
+ }
+
+ static const intptr_t kBytesPerElement = sizeof(RawObjectPool::Entry);
+ static const intptr_t kMaxElements = kSmiMax / kBytesPerElement;
+
+ static intptr_t InstanceSize(intptr_t len) {
+ // Ensure that variable length data is not adding to the object length.
+ ASSERT(sizeof(RawObjectPool) == (sizeof(RawObject) + (2 * kWordSize)));
+ ASSERT(0 <= len && len <= kMaxElements);
+ return RoundedAllocationSize(
+ sizeof(RawObjectPool) + (len * kBytesPerElement));
+ }
+
+ static RawObjectPool* New(intptr_t len, intptr_t num_tagged_entries);
+
+ static intptr_t IndexFromOffset(intptr_t offset) {
+ return (offset + kHeapObjectTag - data_offset()) / kBytesPerElement;
+ }
+
+ private:
+ RawObjectPool::Entry const* EntryAddr(intptr_t index) const {
+ ASSERT((index >= 0) && (index < Length()));
+ return &raw_ptr()->data()[index];
+ }
+
+ FINAL_HEAP_OBJECT_IMPLEMENTATION(ObjectPool, Object);
+ friend class Class;
+ friend class Object;
+ friend class RawObjectPool;
+};
+
+
class Instructions : public Object {
public:
intptr_t size() const { return raw_ptr()->size_; } // Excludes HeaderSize().
@@ -3179,7 +3274,7 @@ class Instructions : public Object {
static intptr_t code_offset() {
return OFFSET_OF(RawInstructions, code_);
}
- RawArray* object_pool() const { return raw_ptr()->object_pool_; }
+ RawObjectPool* object_pool() const { return raw_ptr()->object_pool_; }
static intptr_t object_pool_offset() {
return OFFSET_OF(RawInstructions, object_pool_);
}
@@ -3224,7 +3319,7 @@ class Instructions : public Object {
void set_code(RawCode* code) const {
StorePointer(&raw_ptr()->code_, code);
}
- void set_object_pool(RawArray* object_pool) const {
+ void set_object_pool(RawObjectPool* object_pool) const {
StorePointer(&raw_ptr()->object_pool_, object_pool);
}
@@ -3890,7 +3985,7 @@ class Code : public Object {
const Instructions& instr = Instructions::Handle(instructions());
return instr.size();
}
- RawArray* ObjectPool() const {
+ RawObjectPool* GetObjectPool() const {
const Instructions& instr = Instructions::Handle(instructions());
return instr.object_pool();
}

Powered by Google App Engine
This is Rietveld 408576698