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

Unified Diff: runtime/vm/object.h

Issue 1175523002: Object pool with support for untagged entries. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « runtime/vm/instructions_x64.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.h
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index 612a80b0b66b581dcdde0b5ec7a6e42abc434aac..7ae8f1eb2eba08fb0f92b14d0eb8eca117ae558b 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -413,6 +413,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_;
@@ -510,6 +515,7 @@ class Object {
static RawClass* namespace_class() { return namespace_class_; }
static RawClass* code_class() { return code_class_; }
static RawClass* instructions_class() { return instructions_class_; }
+ static RawClass* object_pool_class() { return object_pool_class_; }
static RawClass* pc_descriptors_class() { return pc_descriptors_class_; }
static RawClass* stackmap_class() { return stackmap_class_; }
static RawClass* var_descriptors_class() { return var_descriptors_class_; }
@@ -768,6 +774,7 @@ class Object {
static RawClass* namespace_class_; // Class of Namespace vm object.
static RawClass* code_class_; // Class of the Code vm object.
static RawClass* instructions_class_; // Class of the Instructions vm object.
+ static RawClass* object_pool_class_; // Class of the ObjectPool vm object.
static RawClass* pc_descriptors_class_; // Class of PcDescriptors vm object.
static RawClass* stackmap_class_; // Class of Stackmap vm object.
static RawClass* var_descriptors_class_; // Class of LocalVarDescriptors.
@@ -792,6 +799,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_;
@@ -3495,6 +3503,108 @@ class Namespace : public Object {
};
+// ObjectPool contains constants, immediates and addresses embedded in code
+// and deoptimization infos. Each entry has an type-info associated with it
+// which is stored in a typed data array (info_array).
+class ObjectPool : public Object {
+ public:
+ enum EntryType {
+ kTaggedObject,
+ kImmediate,
+ };
+
+ struct Entry {
+ Entry() : raw_value_(), type_() { }
+ explicit Entry(const Object* obj) : obj_(obj), type_(kTaggedObject) { }
+ Entry(uword value, EntryType info) : raw_value_(value), type_(info) { }
+ union {
+ const Object* obj_;
+ uword raw_value_;
+ };
+ EntryType type_;
+ };
+
+ intptr_t Length() const {
+ return raw_ptr()->length_;
+ }
+ void SetLength(intptr_t value) const {
+ StoreNonPointer(&raw_ptr()->length_, value);
+ }
+
+ RawTypedData* info_array() const {
+ return raw_ptr()->info_array_;
+ }
+
+ void set_info_array(const TypedData& info_array) const;
+
+ static intptr_t length_offset() { return OFFSET_OF(RawObjectPool, length_); }
+ 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;
+ }
+
+ EntryType InfoAt(intptr_t index) const;
+ void SetInfoAt(intptr_t index, EntryType info) const;
+
+ RawObject* ObjectAt(intptr_t index) const {
+ ASSERT(InfoAt(index) == kTaggedObject);
+ return EntryAddr(index)->raw_obj_;
+ }
+ void SetObjectAt(intptr_t index, const Object& obj) const {
+ ASSERT(InfoAt(index) == kTaggedObject);
+ StorePointer(&EntryAddr(index)->raw_obj_, obj.raw());
+ }
+
+ uword RawValueAt(intptr_t index) const {
+ ASSERT(InfoAt(index) != kTaggedObject);
+ return EntryAddr(index)->raw_value_;
+ }
+ void SetRawValueAt(intptr_t index, uword raw_value) const {
+ ASSERT(InfoAt(index) != kTaggedObject);
+ StoreNonPointer(&EntryAddr(index)->raw_value_, raw_value);
+ }
+
+ 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);
+
+ static intptr_t IndexFromOffset(intptr_t offset) {
+ return (offset + kHeapObjectTag - data_offset()) / kBytesPerElement;
+ }
+
+ void DebugPrint() const;
+
+ 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().
@@ -3502,7 +3612,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_);
}
@@ -3547,7 +3657,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);
}
@@ -3899,7 +4009,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();
}
« no previous file with comments | « runtime/vm/instructions_x64.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698