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

Side by Side Diff: runtime/vm/deferred_objects.cc

Issue 395943003: Support allocation sinking for compound objects. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: improve tests Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/deferred_objects.h ('k') | runtime/vm/deopt_instructions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 #include "vm/deferred_objects.h" 5 #include "vm/deferred_objects.h"
6 6
7 #include "vm/deopt_instructions.h" 7 #include "vm/deopt_instructions.h"
8 #include "vm/flags.h" 8 #include "vm/flags.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 10
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 if (FLAG_trace_deoptimization_verbose) { 90 if (FLAG_trace_deoptimization_verbose) {
91 OS::PrintErr("writing instance ref at %" Px ": %s\n", 91 OS::PrintErr("writing instance ref at %" Px ": %s\n",
92 reinterpret_cast<uword>(slot()), 92 reinterpret_cast<uword>(slot()),
93 Instance::Handle(obj->object()).ToCString()); 93 Instance::Handle(obj->object()).ToCString());
94 } 94 }
95 } 95 }
96 96
97 97
98 RawInstance* DeferredObject::object() { 98 RawInstance* DeferredObject::object() {
99 if (object_ == NULL) { 99 if (object_ == NULL) {
100 Materialize(); 100 Create();
101 } 101 }
102 return object_->raw(); 102 return object_->raw();
103 } 103 }
104 104
105 105
106 void DeferredObject::Materialize() { 106 void DeferredObject::Create() {
107 if (object_ != NULL) {
108 return;
109 }
110
107 Class& cls = Class::Handle(); 111 Class& cls = Class::Handle();
108 cls ^= GetClass(); 112 cls ^= GetClass();
109 113
110 if (FLAG_trace_deoptimization_verbose) { 114 if (FLAG_trace_deoptimization_verbose) {
111 OS::PrintErr("materializing instance of %s (%" Px ", %" Pd " fields)\n", 115 OS::PrintErr("materializing instance of %s (%" Px ", %" Pd " fields)\n",
112 cls.ToCString(), 116 cls.ToCString(),
113 reinterpret_cast<uword>(args_), 117 reinterpret_cast<uword>(args_),
114 field_count_); 118 field_count_);
115 } 119 }
116 120
117 const Instance& obj = Instance::ZoneHandle(Instance::New(cls)); 121 object_ = &Instance::ZoneHandle(Instance::New(cls));
122 }
123
124
125 void DeferredObject::Fill() {
126 Create(); // Ensure instance is created.
127
128 Class& cls = Class::Handle();
129 cls ^= GetClass();
130
131 const Instance& obj = *object_;
118 132
119 Smi& offset = Smi::Handle(); 133 Smi& offset = Smi::Handle();
120 Field& field = Field::Handle(); 134 Field& field = Field::Handle();
121 Object& value = Object::Handle(); 135 Object& value = Object::Handle();
122 const Array& offset_map = Array::Handle(cls.OffsetToFieldMap()); 136 const Array& offset_map = Array::Handle(cls.OffsetToFieldMap());
123 137
124 for (intptr_t i = 0; i < field_count_; i++) { 138 for (intptr_t i = 0; i < field_count_; i++) {
125 offset ^= GetFieldOffset(i); 139 offset ^= GetFieldOffset(i);
126 field ^= offset_map.At(offset.Value() / kWordSize); 140 field ^= offset_map.At(offset.Value() / kWordSize);
127 value = GetValue(i); 141 value = GetValue(i);
128 if (!field.IsNull()) { 142 if (!field.IsNull()) {
129 obj.SetField(field, value); 143 obj.SetField(field, value);
130 if (FLAG_trace_deoptimization_verbose) { 144 if (FLAG_trace_deoptimization_verbose) {
131 OS::PrintErr(" %s <- %s\n", 145 OS::PrintErr(" %s <- %s\n",
132 String::Handle(field.name()).ToCString(), 146 String::Handle(field.name()).ToCString(),
133 value.ToCString()); 147 value.ToCString());
134 } 148 }
135 } else { 149 } else {
136 ASSERT(cls.IsSignatureClass() || 150 ASSERT(cls.IsSignatureClass() ||
137 (offset.Value() == cls.type_arguments_field_offset())); 151 (offset.Value() == cls.type_arguments_field_offset()));
138 obj.SetFieldAtOffset(offset.Value(), value); 152 obj.SetFieldAtOffset(offset.Value(), value);
139 if (FLAG_trace_deoptimization_verbose) { 153 if (FLAG_trace_deoptimization_verbose) {
140 OS::PrintErr(" null Field @ offset(%" Pd ") <- %s\n", 154 OS::PrintErr(" null Field @ offset(%" Pd ") <- %s\n",
141 offset.Value(), 155 offset.Value(),
142 value.ToCString()); 156 value.ToCString());
143 } 157 }
144 } 158 }
145 } 159 }
146
147 object_ = &obj;
148 } 160 }
149 161
150 } // namespace dart 162 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/deferred_objects.h ('k') | runtime/vm/deopt_instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698