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

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: minor clean-up 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 1169efb476c0abb81741a7030d74b3c3afc0f4d4..71eb07920d7ebb0494d0b3ab67df49450be96e6b 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -5355,6 +5355,60 @@ 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) {
turnidge 2012/08/09 18:34:34 These static functions (Clear/Pop/Push) all are ex
cshapiro 2012/08/14 04:58:18 Removed. Done.
+ raw_weak->ptr()->key_ = Object::null();
+ raw_weak->ptr()->value_ = Object::null();
+ }
+
+ static RawWeakProperty* Pop(RawWeakProperty** queue) {
turnidge 2012/08/09 18:34:34 Not sure if this is technically a 'queue'. Seems
cshapiro 2012/08/14 04:58:18 True. This method has been removed. Done.
+ ASSERT(queue != NULL);
+ RawWeakProperty* result = WeakProperty::null();
+ if (*queue != WeakProperty::null()) {
+ result = *queue;
+ RawWeakProperty* next = result->ptr()->next_;
+ result->ptr()->next_ = WeakProperty::null();
+ *queue = next;
+ }
+ return result;
+ }
+
+ static void Push(RawWeakProperty* raw_weak, RawWeakProperty** queue) {
+ ASSERT(queue != NULL);
+ RawWeakProperty* next = *queue;
+ raw_weak->ptr()->next_ = next;
+ *queue = raw_weak;
+ }
+
+ private:
+ HEAP_OBJECT_IMPLEMENTATION(WeakProperty, Instance);
+ friend class Class;
+};
+
+
// Breaking cycles and loops.
RawClass* Object::clazz() const {
uword raw_value = reinterpret_cast<uword>(raw_);

Powered by Google App Engine
This is Rietveld 408576698