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

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

Issue 1815733003: Remove recently introduced FunctionType vm class by merging it into class Type. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address comment Created 4 years, 9 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 | « runtime/vm/raw_object.cc ('k') | runtime/vm/snapshot.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) 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/native_entry.h" 5 #include "vm/native_entry.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/stub_code.h" 9 #include "vm/stub_code.h"
10 #include "vm/symbols.h" 10 #include "vm/symbols.h"
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 writer->Write<int32_t>(ptr()->token_pos_.SnapshotEncode()); 274 writer->Write<int32_t>(ptr()->token_pos_.SnapshotEncode());
275 writer->Write<int8_t>(ptr()->type_state_); 275 writer->Write<int8_t>(ptr()->type_state_);
276 276
277 // Write out all the object pointer fields. 277 // Write out all the object pointer fields.
278 ASSERT(ptr()->type_class_ != Object::null()); 278 ASSERT(ptr()->type_class_ != Object::null());
279 SnapshotWriterVisitor visitor(writer, kAsReference); 279 SnapshotWriterVisitor visitor(writer, kAsReference);
280 visitor.VisitPointers(from(), to()); 280 visitor.VisitPointers(from(), to());
281 } 281 }
282 282
283 283
284 RawFunctionType* FunctionType::ReadFrom(SnapshotReader* reader,
285 intptr_t object_id,
286 intptr_t tags,
287 Snapshot::Kind kind,
288 bool as_reference) {
289 ASSERT(reader != NULL);
290
291 // Determine if the scope class of this function type is in the full snapshot.
292 bool scopeclass_is_in_fullsnapshot = reader->Read<bool>();
293
294 // Allocate function type object.
295 FunctionType& function_type =
296 FunctionType::ZoneHandle(reader->zone(), NEW_OBJECT(FunctionType));
297 bool is_canonical = RawObject::IsCanonical(tags);
298 bool defer_canonicalization = is_canonical &&
299 (kind != Snapshot::kFull && scopeclass_is_in_fullsnapshot);
300 reader->AddBackRef(object_id,
301 &function_type,
302 kIsDeserialized,
303 defer_canonicalization);
304
305 // Set all non object fields.
306 function_type.set_token_pos(
307 TokenPosition::SnapshotDecode(reader->Read<int32_t>()));
308 function_type.set_type_state(reader->Read<int8_t>());
309
310 // Set all the object fields.
311 READ_OBJECT_FIELDS(function_type,
312 function_type.raw()->from(), function_type.raw()->to(),
313 kAsReference);
314
315 // Set the canonical bit.
316 if (!defer_canonicalization && is_canonical) {
317 function_type.SetCanonical();
318 }
319
320 return function_type.raw();
321 }
322
323
324 void RawFunctionType::WriteTo(SnapshotWriter* writer,
325 intptr_t object_id,
326 Snapshot::Kind kind,
327 bool as_reference) {
328 ASSERT(writer != NULL);
329
330 // Only resolved and finalized function types should be written to a snapshot.
331 ASSERT((ptr()->type_state_ == RawFunctionType::kFinalizedInstantiated) ||
332 (ptr()->type_state_ == RawFunctionType::kFinalizedUninstantiated));
333 ASSERT(ptr()->scope_class_ != Object::null());
334
335 // Write out the serialization header value for this object.
336 writer->WriteInlinedObjectHeader(object_id);
337
338 // Write out the class and tags information.
339 writer->WriteIndexedObject(kFunctionTypeCid);
340 writer->WriteTags(writer->GetObjectTags(this));
341
342 // Write out scopeclass_is_in_fullsnapshot first as this will
343 // help the reader decide on how to canonicalize the type object.
344 intptr_t tags = writer->GetObjectTags(ptr()->scope_class_);
345 bool scopeclass_is_in_fullsnapshot =
346 (ClassIdTag::decode(tags) == kClassCid) &&
347 Class::IsInFullSnapshot(reinterpret_cast<RawClass*>(ptr()->scope_class_));
348 writer->Write<bool>(scopeclass_is_in_fullsnapshot);
349
350 // Write out all the non object pointer fields.
351 writer->Write<int32_t>(ptr()->token_pos_.SnapshotEncode());
352 writer->Write<int8_t>(ptr()->type_state_);
353
354 // Write out all the object pointer fields.
355 ASSERT(ptr()->scope_class_ != Object::null());
356 SnapshotWriterVisitor visitor(writer, kAsReference);
357 visitor.VisitPointers(from(), to());
358 }
359
360
361 RawTypeRef* TypeRef::ReadFrom(SnapshotReader* reader, 284 RawTypeRef* TypeRef::ReadFrom(SnapshotReader* reader,
362 intptr_t object_id, 285 intptr_t object_id,
363 intptr_t tags, 286 intptr_t tags,
364 Snapshot::Kind kind, 287 Snapshot::Kind kind,
365 bool as_reference) { 288 bool as_reference) {
366 ASSERT(reader != NULL); 289 ASSERT(reader != NULL);
367 290
368 // Allocate type ref object. 291 // Allocate type ref object.
369 TypeRef& type_ref = TypeRef::ZoneHandle( 292 TypeRef& type_ref = TypeRef::ZoneHandle(
370 reader->zone(), NEW_OBJECT(TypeRef)); 293 reader->zone(), NEW_OBJECT(TypeRef));
(...skipping 3359 matching lines...) Expand 10 before | Expand all | Expand 10 after
3730 // We do not allow objects with native fields in an isolate message. 3653 // We do not allow objects with native fields in an isolate message.
3731 writer->SetWriteException(Exceptions::kArgument, 3654 writer->SetWriteException(Exceptions::kArgument,
3732 "Illegal argument in isolate message" 3655 "Illegal argument in isolate message"
3733 " : (object is a UserTag)"); 3656 " : (object is a UserTag)");
3734 } else { 3657 } else {
3735 UNREACHABLE(); 3658 UNREACHABLE();
3736 } 3659 }
3737 } 3660 }
3738 3661
3739 } // namespace dart 3662 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object.cc ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698