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

Side by Side 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, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | runtime/vm/become.cc » ('j') | runtime/vm/class_table.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_BECOME_H_ 5 #ifndef VM_BECOME_H_
6 #define VM_BECOME_H_ 6 #define VM_BECOME_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/raw_object.h"
9 10
10 namespace dart { 11 namespace dart {
11 12
12 class Array; 13 class Array;
13 14
15 // Objects on the left-hand side of a become are tranformed into forwarding
16 // 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
17 // FreeListElement.
Cutch 2016/06/02 14:09:53 I don't understand the last sentence.
18 class ForwardingCorpse {
19 public:
20 RawObject* target() const {
21 return target_;
22 }
23 void set_target(RawObject* target) {
24 target_ = target;
25 }
26
27 intptr_t Size() {
28 intptr_t size = RawObject::SizeTag::decode(tags_);
29 if (size != 0) return size;
30 return *SizeAddress();
31 }
32
33 static ForwardingCorpse* AsForwarder(uword addr, intptr_t size);
34
35 static void InitOnce();
36
37 // 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.
38 class FakeInstance {
39 public:
40 FakeInstance() { }
41 static cpp_vtable vtable() { return 0; }
42 static intptr_t InstanceSize() { return 0; }
43 static intptr_t NextFieldOffset() { return -kWordSize; }
44 static const ClassId kClassId = kForwardingCorpse;
45 static bool IsInstance() { return true; }
46
47 private:
48 DISALLOW_ALLOCATION();
49 DISALLOW_COPY_AND_ASSIGN(FakeInstance);
50 };
51
52 private:
53 // This layout mirrors the layout of RawObject.
54 uword tags_;
55 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
56
57 // Returns the address of the embedded size.
58 intptr_t* SizeAddress() const {
59 uword addr = reinterpret_cast<uword>(&target_) + kWordSize;
60 return reinterpret_cast<intptr_t*>(addr);
61 }
62
63 // ForwardingCorpses cannot be allocated. Instead references to them are
64 // created using the AsForwarder factory method.
65 DISALLOW_ALLOCATION();
66 DISALLOW_IMPLICIT_CONSTRUCTORS(ForwardingCorpse);
67 };
68
14 // TODO(johnmccutchan): Refactor this class so that it is not all static and 69 // TODO(johnmccutchan): Refactor this class so that it is not all static and
15 // provides utility methods for building the mapping of before and after. 70 // provides utility methods for building the mapping of before and after.
16 class Become : public AllStatic { 71 class Become : public AllStatic {
17 public: 72 public:
18 // Smalltalk's one-way bulk become (Array>>#elementsForwardIdentityTo:). 73 // Smalltalk's one-way bulk become (Array>>#elementsForwardIdentityTo:).
19 // Redirects all pointers to elements of 'before' to the corresponding element 74 // Redirects all pointers to elements of 'before' to the corresponding element
20 // in 'after'. Every element in 'before' is guaranteed to be not reachable. 75 // in 'after'. Every element in 'before' is guaranteed to be not reachable.
21 // Useful for atomically applying behavior and schema changes. 76 // Useful for atomically applying behavior and schema changes.
22 static void ElementsForwardIdentity(const Array& before, const Array& after); 77 static void ElementsForwardIdentity(const Array& before, const Array& after);
23 }; 78 };
24 79
25 } // namespace dart 80 } // namespace dart
26 81
27 #endif // VM_BECOME_H_ 82 #endif // VM_BECOME_H_
OLDNEW
« 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