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

Unified Diff: runtime/vm/become.h

Issue 2026643004: Don't overload FreeListElement for become. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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 | « no previous file | runtime/vm/become.cc » ('j') | runtime/vm/class_table.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/become.h
diff --git a/runtime/vm/become.h b/runtime/vm/become.h
index 977355364628c4bea80a24bbcbd8883a8af5ea7f..109e5880cae021c37811caec4b5ab220e317a294 100644
--- a/runtime/vm/become.h
+++ b/runtime/vm/become.h
@@ -6,11 +6,66 @@
#define VM_BECOME_H_
#include "vm/allocation.h"
+#include "vm/raw_object.h"
namespace dart {
class Array;
+// Objects on the left-hand side of a become are tranformed into forwarding
+// corpses pointing to the right-hand side. Compare the representation of a
Cutch 2016/06/02 14:09:53 you talk about "right-hand" side in the comment th
rmacnak 2016/06/02 17:57:06 Changed to Objects that are a source in a become
+// FreeListElement.
Cutch 2016/06/02 14:09:53 I don't understand the last sentence.
+class ForwardingCorpse {
+ public:
+ RawObject* target() const {
+ return target_;
+ }
+ void set_target(RawObject* target) {
+ target_ = target;
+ }
+
+ intptr_t Size() {
+ intptr_t size = RawObject::SizeTag::decode(tags_);
+ if (size != 0) return size;
+ return *SizeAddress();
+ }
+
+ static ForwardingCorpse* AsForwarder(uword addr, intptr_t size);
+
+ static void InitOnce();
+
+ // Used to allocate class for free list elements in Object::InitOnce.
siva 2016/06/02 00:23:36 "free list elements" => "forwarding corpse element
rmacnak 2016/06/02 17:57:06 Done.
+ class FakeInstance {
+ public:
+ FakeInstance() { }
+ static cpp_vtable vtable() { return 0; }
+ static intptr_t InstanceSize() { return 0; }
+ static intptr_t NextFieldOffset() { return -kWordSize; }
+ static const ClassId kClassId = kForwardingCorpse;
+ static bool IsInstance() { return true; }
+
+ private:
+ DISALLOW_ALLOCATION();
+ DISALLOW_COPY_AND_ASSIGN(FakeInstance);
+ };
+
+ private:
+ // This layout mirrors the layout of RawObject.
+ uword tags_;
+ RawObject* target_;
siva 2016/06/02 00:23:36 Why did you do it this way instead of adding a Raw
rmacnak 2016/06/02 17:57:06 As discussed offline, this follows the precedent o
+
+ // Returns the address of the embedded size.
+ intptr_t* SizeAddress() const {
+ uword addr = reinterpret_cast<uword>(&target_) + kWordSize;
+ return reinterpret_cast<intptr_t*>(addr);
+ }
+
+ // ForwardingCorpses cannot be allocated. Instead references to them are
+ // created using the AsForwarder factory method.
+ DISALLOW_ALLOCATION();
+ DISALLOW_IMPLICIT_CONSTRUCTORS(ForwardingCorpse);
+};
+
// TODO(johnmccutchan): Refactor this class so that it is not all static and
// provides utility methods for building the mapping of before and after.
class Become : public AllStatic {
« no previous file with comments | « no previous file | runtime/vm/become.cc » ('j') | runtime/vm/class_table.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698