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

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

Issue 12123002: Fix class patching involving type parameters: type parameters of patched classes (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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/parser.cc ('k') | runtime/vm/snapshot.cc » ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/bigint_operations.h" 5 #include "vm/bigint_operations.h"
6 #include "vm/object.h" 6 #include "vm/object.h"
7 #include "vm/object_store.h" 7 #include "vm/object_store.h"
8 #include "vm/snapshot.h" 8 #include "vm/snapshot.h"
9 #include "vm/symbols.h" 9 #include "vm/symbols.h"
10 #include "vm/visitor.h" 10 #include "vm/visitor.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } else { 109 } else {
110 writer->WriteClassId(this); 110 writer->WriteClassId(this);
111 } 111 }
112 } 112 }
113 113
114 114
115 RawUnresolvedClass* UnresolvedClass::ReadFrom(SnapshotReader* reader, 115 RawUnresolvedClass* UnresolvedClass::ReadFrom(SnapshotReader* reader,
116 intptr_t object_id, 116 intptr_t object_id,
117 intptr_t tags, 117 intptr_t tags,
118 Snapshot::Kind kind) { 118 Snapshot::Kind kind) {
119 ASSERT(reader != NULL); 119 UNREACHABLE(); // Only finalized types are written to a snapshot.
120 120 return NULL;
121 // Allocate parameterized type object.
122 UnresolvedClass& unresolved_class = UnresolvedClass::ZoneHandle(
123 reader->isolate(), NEW_OBJECT(UnresolvedClass));
124 reader->AddBackRef(object_id, &unresolved_class, kIsDeserialized);
125
126 // Set the object tags.
127 unresolved_class.set_tags(tags);
128
129 // Set all non object fields.
130 unresolved_class.set_token_pos(reader->ReadIntptrValue());
131
132 // Set all the object fields.
133 // TODO(5411462): Need to assert No GC can happen here, even though
134 // allocations may happen.
135 intptr_t num_flds = (unresolved_class.raw()->to() -
136 unresolved_class.raw()->from());
137 for (intptr_t i = 0; i <= num_flds; i++) {
138 unresolved_class.StorePointer((unresolved_class.raw()->from() + i),
139 reader->ReadObjectRef());
140 }
141 return unresolved_class.raw();
142 } 121 }
143 122
144 123
145 void RawUnresolvedClass::WriteTo(SnapshotWriter* writer, 124 void RawUnresolvedClass::WriteTo(SnapshotWriter* writer,
146 intptr_t object_id, 125 intptr_t object_id,
147 Snapshot::Kind kind) { 126 Snapshot::Kind kind) {
148 ASSERT(writer != NULL); 127 UNREACHABLE(); // Only finalized types are written to a snapshot.
149 128 // Specify --error_on_malformed_type flag for details.
150 // Write out the serialization header value for this object.
151 writer->WriteInlinedObjectHeader(object_id);
152
153 // Write out the class and tags information.
154 writer->WriteVMIsolateObject(kUnresolvedClassCid);
155 writer->WriteIntptrValue(writer->GetObjectTags(this));
156
157 // Write out all the non object pointer fields.
158 writer->WriteIntptrValue(ptr()->token_pos_);
159
160 // Write out all the object pointer fields.
161 SnapshotWriterVisitor visitor(writer);
162 visitor.VisitPointers(from(), to());
163 } 129 }
164 130
165 131
166 RawAbstractType* AbstractType::ReadFrom(SnapshotReader* reader, 132 RawAbstractType* AbstractType::ReadFrom(SnapshotReader* reader,
167 intptr_t object_id, 133 intptr_t object_id,
168 intptr_t tags, 134 intptr_t tags,
169 Snapshot::Kind kind) { 135 Snapshot::Kind kind) {
170 UNREACHABLE(); // AbstractType is an abstract class. 136 UNREACHABLE(); // AbstractType is an abstract class.
171 return NULL; 137 return NULL;
172 } 138 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 178
213 return type.raw(); 179 return type.raw();
214 } 180 }
215 181
216 182
217 void RawType::WriteTo(SnapshotWriter* writer, 183 void RawType::WriteTo(SnapshotWriter* writer,
218 intptr_t object_id, 184 intptr_t object_id,
219 Snapshot::Kind kind) { 185 Snapshot::Kind kind) {
220 ASSERT(writer != NULL); 186 ASSERT(writer != NULL);
221 187
188 // Check that the type is finalized.
189 // Specify --error_on_malformed_type flag for details in case of error.
190 ASSERT((ptr()->type_state_ == RawType::kFinalizedInstantiated) ||
191 (ptr()->type_state_ == RawType::kFinalizedUninstantiated));
192
222 // Write out the serialization header value for this object. 193 // Write out the serialization header value for this object.
223 writer->WriteInlinedObjectHeader(object_id); 194 writer->WriteInlinedObjectHeader(object_id);
224 195
225 // Write out the class and tags information. 196 // Write out the class and tags information.
226 writer->WriteIndexedObject(kTypeCid); 197 writer->WriteIndexedObject(kTypeCid);
227 writer->WriteIntptrValue(writer->GetObjectTags(this)); 198 writer->WriteIntptrValue(writer->GetObjectTags(this));
228 199
229 // Write out all the non object pointer fields. 200 // Write out all the non object pointer fields.
230 writer->WriteIntptrValue(ptr()->token_pos_); 201 writer->WriteIntptrValue(ptr()->token_pos_);
231 writer->Write<int8_t>(ptr()->type_state_); 202 writer->Write<int8_t>(ptr()->type_state_);
232 203
233 // Write out all the object pointer fields. 204 // Write out all the object pointer fields.
234 SnapshotWriterVisitor visitor(writer); 205 SnapshotWriterVisitor visitor(writer);
235 visitor.VisitPointers(from(), to()); 206 visitor.VisitPointers(from(), to());
236 } 207 }
237 208
238 209
239 RawTypeParameter* TypeParameter::ReadFrom(SnapshotReader* reader, 210 RawTypeParameter* TypeParameter::ReadFrom(SnapshotReader* reader,
240 intptr_t object_id, 211 intptr_t object_id,
241 intptr_t tags, 212 intptr_t tags,
242 Snapshot::Kind kind) { 213 Snapshot::Kind kind) {
243 ASSERT(reader != NULL); 214 ASSERT(reader != NULL);
244 215
245 // Allocate type parameter object. 216 // Allocate type parameter object.
246 TypeParameter& type_parameter = TypeParameter::ZoneHandle( 217 TypeParameter& type_parameter = TypeParameter::ZoneHandle(
247 reader->isolate(), NEW_OBJECT(TypeParameter)); 218 reader->isolate(), NEW_OBJECT(TypeParameter));
248 reader->AddBackRef(object_id, &type_parameter, kIsDeserialized); 219 reader->AddBackRef(object_id, &type_parameter, kIsDeserialized);
249 220
250 // Set the object tags. 221 // Set the object tags.
251 type_parameter.set_tags(tags); 222 type_parameter.set_tags(tags);
252 223
253 // Set all non object fields. 224 // Set all non object fields.
254 type_parameter.set_index(reader->ReadIntptrValue()); 225 type_parameter.set_index(reader->ReadIntptrValue());
255 type_parameter.set_token_pos(reader->ReadIntptrValue()); 226 type_parameter.set_token_pos(reader->ReadIntptrValue());
256 type_parameter.set_type_state(reader->Read<int8_t>()); 227 type_parameter.set_type_state(reader->Read<int8_t>());
257 228
258 // Set all the object fields. 229 // Set all the object fields.
259 // TODO(5411462): Need to assert No GC can happen here, even though 230 // TODO(5411462): Need to assert No GC can happen here, even though
260 // allocations may happen. 231 // allocations may happen.
261 intptr_t num_flds = (type_parameter.raw()->to() - 232 intptr_t num_flds = (type_parameter.raw()->to() -
262 type_parameter.raw()->from()); 233 type_parameter.raw()->from());
263 for (intptr_t i = 0; i <= num_flds; i++) { 234 for (intptr_t i = 0; i <= num_flds; i++) {
264 type_parameter.StorePointer((type_parameter.raw()->from() + i), 235 type_parameter.StorePointer((type_parameter.raw()->from() + i),
265 reader->ReadObjectRef()); 236 reader->ReadObjectRef());
266 } 237 }
267 238
268 return type_parameter.raw(); 239 return type_parameter.raw();
269 } 240 }
270 241
271 242
272 void RawTypeParameter::WriteTo(SnapshotWriter* writer, 243 void RawTypeParameter::WriteTo(SnapshotWriter* writer,
273 intptr_t object_id, 244 intptr_t object_id,
274 Snapshot::Kind kind) { 245 Snapshot::Kind kind) {
275 ASSERT(writer != NULL); 246 ASSERT(writer != NULL);
276 247
248 // Check that the type parameter is finalized.
249 // Specify --error_on_malformed_type flag for details in case of error.
250 ASSERT(ptr()->type_state_ == RawTypeParameter::kFinalizedUninstantiated);
251
277 // Write out the serialization header value for this object. 252 // Write out the serialization header value for this object.
278 writer->WriteInlinedObjectHeader(object_id); 253 writer->WriteInlinedObjectHeader(object_id);
279 254
280 // Write out the class and tags information. 255 // Write out the class and tags information.
281 writer->WriteIndexedObject(kTypeParameterCid); 256 writer->WriteIndexedObject(kTypeParameterCid);
282 writer->WriteIntptrValue(writer->GetObjectTags(this)); 257 writer->WriteIntptrValue(writer->GetObjectTags(this));
283 258
284 // Write out all the non object pointer fields. 259 // Write out all the non object pointer fields.
285 writer->WriteIntptrValue(ptr()->index_); 260 writer->WriteIntptrValue(ptr()->index_);
286 writer->WriteIntptrValue(ptr()->token_pos_); 261 writer->WriteIntptrValue(ptr()->token_pos_);
(...skipping 1957 matching lines...) Expand 10 before | Expand all | Expand 10 after
2244 // Write out the class and tags information. 2219 // Write out the class and tags information.
2245 writer->WriteIndexedObject(kWeakPropertyCid); 2220 writer->WriteIndexedObject(kWeakPropertyCid);
2246 writer->WriteIntptrValue(writer->GetObjectTags(this)); 2221 writer->WriteIntptrValue(writer->GetObjectTags(this));
2247 2222
2248 // Write out all the other fields. 2223 // Write out all the other fields.
2249 writer->Write<RawObject*>(ptr()->key_); 2224 writer->Write<RawObject*>(ptr()->key_);
2250 writer->Write<RawObject*>(ptr()->value_); 2225 writer->Write<RawObject*>(ptr()->value_);
2251 } 2226 }
2252 2227
2253 } // namespace dart 2228 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/parser.cc ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698