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

Unified Diff: runtime/vm/object.h

Issue 10832199: Add a weak property type to the virtual machine. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address review comments Created 8 years, 4 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 0a1dcc928beb183551fbdfa198f2c1910bb800c2..c7c8f84b800c20e4240bd0f3a315fb6c0eeac9ed 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -5348,6 +5348,41 @@ class JSRegExp : public Instance {
};
+class WeakProperty : public Instance {
+ public:
+ RawObject* key() const {
+ return raw_ptr()->key_;
+ }
+
+ void set_key(const Object& key) {
+ StorePointer(&raw_ptr()->key_, key.raw());
+ }
+
+ RawObject* value() const {
+ return raw_ptr()->value_;
+ }
+
+ void set_value(const Object& value) {
+ StorePointer(&raw_ptr()->value_, value.raw());
+ }
+
+ static RawWeakProperty* New(Heap::Space space = Heap::kNew);
+
+ static intptr_t InstanceSize() {
+ return RoundedAllocationSize(sizeof(RawWeakProperty));
+ }
+
+ static void Clear(RawWeakProperty* raw_weak) {
+ raw_weak->ptr()->key_ = Object::null();
+ raw_weak->ptr()->value_ = Object::null();
+ }
+
+ private:
+ HEAP_OBJECT_IMPLEMENTATION(WeakProperty, Instance);
+ friend class Class;
+};
+
+
// Breaking cycles and loops.
RawClass* Object::clazz() const {
uword raw_value = reinterpret_cast<uword>(raw_);
« no previous file with comments | « runtime/vm/gc_marker.cc ('k') | runtime/vm/object.cc » ('j') | runtime/vm/scavenger.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698