| OLD | NEW |
| 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/object.h" | 5 #include "vm/object.h" |
| 6 #include "vm/object_store.h" | 6 #include "vm/object_store.h" |
| 7 #include "vm/snapshot.h" | 7 #include "vm/snapshot.h" |
| 8 #include "vm/stub_code.h" | 8 #include "vm/stub_code.h" |
| 9 #include "vm/symbols.h" | 9 #include "vm/symbols.h" |
| 10 #include "vm/visitor.h" | 10 #include "vm/visitor.h" |
| (...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1359 | 1359 |
| 1360 | 1360 |
| 1361 RawContext* Context::ReadFrom(SnapshotReader* reader, | 1361 RawContext* Context::ReadFrom(SnapshotReader* reader, |
| 1362 intptr_t object_id, | 1362 intptr_t object_id, |
| 1363 intptr_t tags, | 1363 intptr_t tags, |
| 1364 Snapshot::Kind kind) { | 1364 Snapshot::Kind kind) { |
| 1365 ASSERT(reader != NULL); | 1365 ASSERT(reader != NULL); |
| 1366 | 1366 |
| 1367 // Allocate context object. | 1367 // Allocate context object. |
| 1368 int32_t num_vars = reader->Read<int32_t>(); | 1368 int32_t num_vars = reader->Read<int32_t>(); |
| 1369 Context& context = Context::ZoneHandle(reader->isolate(), Context::null()); | 1369 Context& context = Context::ZoneHandle( |
| 1370 if (kind == Snapshot::kFull) { | 1370 reader->isolate(), NEW_OBJECT_WITH_LEN(Context, num_vars)); |
| 1371 context = reader->NewContext(num_vars); | |
| 1372 } else { | |
| 1373 context = Context::New(num_vars, HEAP_SPACE(kind)); | |
| 1374 } | |
| 1375 reader->AddBackRef(object_id, &context, kIsDeserialized); | 1371 reader->AddBackRef(object_id, &context, kIsDeserialized); |
| 1376 | 1372 |
| 1377 // Set the object tags. | 1373 // Set the object tags. |
| 1378 context.set_tags(tags); | 1374 context.set_tags(tags); |
| 1379 | 1375 |
| 1380 // Set all the object fields. | 1376 // Set all the object fields. |
| 1381 // TODO(5411462): Need to assert No GC can happen here, even though | 1377 // TODO(5411462): Need to assert No GC can happen here, even though |
| 1382 // allocations may happen. | 1378 // allocations may happen. |
| 1383 intptr_t num_flds = (context.raw()->to(num_vars) - context.raw()->from()); | 1379 intptr_t num_flds = (context.raw()->to(num_vars) - context.raw()->from()); |
| 1384 for (intptr_t i = 0; i <= num_flds; i++) { | 1380 for (intptr_t i = 0; i <= num_flds; i++) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1399 // Write out the serialization header value for this object. | 1395 // Write out the serialization header value for this object. |
| 1400 writer->WriteInlinedObjectHeader(object_id); | 1396 writer->WriteInlinedObjectHeader(object_id); |
| 1401 | 1397 |
| 1402 // Write out the class and tags information. | 1398 // Write out the class and tags information. |
| 1403 writer->WriteVMIsolateObject(kContextCid); | 1399 writer->WriteVMIsolateObject(kContextCid); |
| 1404 writer->WriteTags(writer->GetObjectTags(this)); | 1400 writer->WriteTags(writer->GetObjectTags(this)); |
| 1405 | 1401 |
| 1406 // Write out num of variables in the context. | 1402 // Write out num of variables in the context. |
| 1407 writer->Write<int32_t>(ptr()->num_variables_); | 1403 writer->Write<int32_t>(ptr()->num_variables_); |
| 1408 | 1404 |
| 1409 // Can't serialize the isolate pointer, we set it implicitly on read. | |
| 1410 | |
| 1411 // Write out all the object pointer fields. | 1405 // Write out all the object pointer fields. |
| 1412 SnapshotWriterVisitor visitor(writer); | 1406 SnapshotWriterVisitor visitor(writer); |
| 1413 visitor.VisitPointers(from(), to(ptr()->num_variables_)); | 1407 visitor.VisitPointers(from(), to(ptr()->num_variables_)); |
| 1414 } | 1408 } |
| 1415 | 1409 |
| 1416 | 1410 |
| 1417 RawContextScope* ContextScope::ReadFrom(SnapshotReader* reader, | 1411 RawContextScope* ContextScope::ReadFrom(SnapshotReader* reader, |
| 1418 intptr_t object_id, | 1412 intptr_t object_id, |
| 1419 intptr_t tags, | 1413 intptr_t tags, |
| 1420 Snapshot::Kind kind) { | 1414 Snapshot::Kind kind) { |
| (...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2901 // We do not allow objects with native fields in an isolate message. | 2895 // We do not allow objects with native fields in an isolate message. |
| 2902 writer->SetWriteException(Exceptions::kArgument, | 2896 writer->SetWriteException(Exceptions::kArgument, |
| 2903 "Illegal argument in isolate message" | 2897 "Illegal argument in isolate message" |
| 2904 " : (object is a UserTag)"); | 2898 " : (object is a UserTag)"); |
| 2905 } else { | 2899 } else { |
| 2906 UNREACHABLE(); | 2900 UNREACHABLE(); |
| 2907 } | 2901 } |
| 2908 } | 2902 } |
| 2909 | 2903 |
| 2910 } // namespace dart | 2904 } // namespace dart |
| OLD | NEW |