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

Unified Diff: runtime/vm/raw_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/raw_object.h
diff --git a/runtime/vm/raw_object.h b/runtime/vm/raw_object.h
index 40d90726467cd8b8fa9f7bd4cc0b0ba499b383cd..ef257734235e7c244b86ce1b4ffe76c194a979a0 100644
--- a/runtime/vm/raw_object.h
+++ b/runtime/vm/raw_object.h
@@ -89,6 +89,7 @@ namespace dart {
V(Closure) \
V(Stacktrace) \
V(JSRegExp) \
+ V(WeakProperty) \
#define CLASS_LIST(V) \
V(Object) \
@@ -184,8 +185,9 @@ class RawObject {
kMarkBit = 1,
kCanonicalBit = 2,
kFromSnapshotBit = 3,
- kReservedTagBit = 4, // kReservedBit{10K,100K,1M,10M}
- kReservedTagSize = 4,
+ kWatchedBit = 4,
Ivan Posva 2012/08/14 00:26:39 I was wondering whether you considered using the k
cshapiro 2012/08/14 04:58:18 This might be strictly true in old space but the u
Ivan Posva 2012/08/14 15:23:36 We can consolidate the bits later, I was under the
+ kReservedTagBit = 5, // kReservedBit{10K,100K,1M,10M}
+ kReservedTagSize = 3,
kSizeTagBit = 8,
kSizeTagSize = 8,
kClassIdTagBit = kSizeTagBit + kSizeTagSize,
@@ -256,6 +258,21 @@ class RawObject {
ptr()->tags_ = MarkBit::update(false, tags);
}
+ // Support for GC watched bit.
+ bool IsWatched() const {
+ return WatchedBit::decode(ptr()->tags_);
+ }
+ void SetWatchedBit() {
+ ASSERT(!IsWatched());
+ uword tags = ptr()->tags_;
+ ptr()->tags_ = WatchedBit::update(true, tags);
+ }
+ void ClearWatchedBit() {
+ ASSERT(IsWatched());
+ uword tags = ptr()->tags_;
+ ptr()->tags_ = WatchedBit::update(false, tags);
+ }
+
// Support for object tags.
bool IsCanonical() const {
return CanonicalObjectTag::decode(ptr()->tags_);
@@ -325,6 +342,8 @@ class RawObject {
class MarkBit : public BitField<bool, kMarkBit, 1> {};
+ class WatchedBit : public BitField<bool, kWatchedBit, 1> {};
+
class CanonicalObjectTag : public BitField<bool, kCanonicalBit, 1> {};
class CreatedFromSnapshotTag : public BitField<bool, kFromSnapshotBit, 1> {};
@@ -351,6 +370,7 @@ class RawObject {
friend class Api;
friend class Array;
friend class FreeListElement;
+ friend class GCMarker;
friend class Heap;
friend class HeapProfiler;
friend class HeapProfilerRootVisitor;
@@ -358,6 +378,7 @@ class RawObject {
friend class Object;
friend class RawInstructions;
friend class RawInstance;
+ friend class Scavenger;
friend class SnapshotReader;
friend class SnapshotWriter;
@@ -1492,6 +1513,28 @@ class RawJSRegExp : public RawInstance {
uint8_t data_[0];
};
+
+class RawWeakProperty : public RawInstance {
+ RAW_HEAP_OBJECT_IMPLEMENTATION(WeakProperty);
+
+ RawObject** from() {
+ return reinterpret_cast<RawObject**>(&ptr()->key_);
+ }
+ RawObject* key_;
+ RawObject* value_;
+ RawObject** to() {
+ return reinterpret_cast<RawObject**>(&ptr()->value_);
+ }
+
+ RawWeakProperty* next_; // This field is owned by the garbage collector.
turnidge 2012/08/09 18:34:34 Even more, it is only used during garbage collecti
cshapiro 2012/08/14 04:58:18 Yes. Removed.
+
+ friend class GCMarker;
+ friend class MarkingVisitor;
+ friend class Scavenger;
+ friend class ScavengerVisitor;
+};
+
+
// ObjectKind predicates.
inline bool RawObject::IsErrorClassId(intptr_t index) {

Powered by Google App Engine
This is Rietveld 408576698