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

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 final 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
« no previous file with comments | « runtime/vm/gc_marker.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 3563b91b67661240972751b4ee28511ce4e2425c..06ca870d29de3b34f027ea843eb0f1e56724072b 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -5410,6 +5410,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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698