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

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

Issue 510613002: Add passive handle types PassiveObject and PassiveInstance to allow (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 3 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/object.h ('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/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/stub_code.h" 9 #include "vm/stub_code.h"
10 #include "vm/symbols.h" 10 #include "vm/symbols.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 142
143 // Set all non object fields. 143 // Set all non object fields.
144 unresolved_class.set_token_pos(reader->Read<int32_t>()); 144 unresolved_class.set_token_pos(reader->Read<int32_t>());
145 145
146 // Set all the object fields. 146 // Set all the object fields.
147 // TODO(5411462): Need to assert No GC can happen here, even though 147 // TODO(5411462): Need to assert No GC can happen here, even though
148 // allocations may happen. 148 // allocations may happen.
149 intptr_t num_flds = (unresolved_class.raw()->to() - 149 intptr_t num_flds = (unresolved_class.raw()->to() -
150 unresolved_class.raw()->from()); 150 unresolved_class.raw()->from());
151 for (intptr_t i = 0; i <= num_flds; i++) { 151 for (intptr_t i = 0; i <= num_flds; i++) {
152 (*reader->ObjectHandle()) = reader->ReadObjectRef(); 152 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef();
153 unresolved_class.StorePointer((unresolved_class.raw()->from() + i), 153 unresolved_class.StorePointer((unresolved_class.raw()->from() + i),
154 reader->ObjectHandle()->raw()); 154 reader->PassiveObjectHandle()->raw());
155 } 155 }
156 return unresolved_class.raw(); 156 return unresolved_class.raw();
157 } 157 }
158 158
159 159
160 void RawUnresolvedClass::WriteTo(SnapshotWriter* writer, 160 void RawUnresolvedClass::WriteTo(SnapshotWriter* writer,
161 intptr_t object_id, 161 intptr_t object_id,
162 Snapshot::Kind kind) { 162 Snapshot::Kind kind) {
163 ASSERT(writer != NULL); 163 ASSERT(writer != NULL);
164 164
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 206
207 // Set all non object fields. 207 // Set all non object fields.
208 type.set_token_pos(reader->Read<int32_t>()); 208 type.set_token_pos(reader->Read<int32_t>());
209 type.set_type_state(reader->Read<int8_t>()); 209 type.set_type_state(reader->Read<int8_t>());
210 210
211 // Set all the object fields. 211 // Set all the object fields.
212 // TODO(5411462): Need to assert No GC can happen here, even though 212 // TODO(5411462): Need to assert No GC can happen here, even though
213 // allocations may happen. 213 // allocations may happen.
214 intptr_t num_flds = (type.raw()->to() - type.raw()->from()); 214 intptr_t num_flds = (type.raw()->to() - type.raw()->from());
215 for (intptr_t i = 0; i <= num_flds; i++) { 215 for (intptr_t i = 0; i <= num_flds; i++) {
216 (*reader->ObjectHandle()) = reader->ReadObjectImpl(); 216 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl();
217 type.StorePointer((type.raw()->from() + i), reader->ObjectHandle()->raw()); 217 type.StorePointer((type.raw()->from() + i),
218 reader->PassiveObjectHandle()->raw());
218 } 219 }
219 220
220 // If object needs to be a canonical object, Canonicalize it. 221 // If object needs to be a canonical object, Canonicalize it.
221 // When reading a full snapshot we don't need to canonicalize the object 222 // When reading a full snapshot we don't need to canonicalize the object
222 // as it would already be a canonical object. 223 // as it would already be a canonical object.
223 // When reading a script snapshot we need to canonicalize only those object 224 // When reading a script snapshot we need to canonicalize only those object
224 // references that are objects from the core library (loaded from a 225 // references that are objects from the core library (loaded from a
225 // full snapshot). Objects that are only in the script need not be 226 // full snapshot). Objects that are only in the script need not be
226 // canonicalized as they are already canonical. 227 // canonicalized as they are already canonical.
227 // When reading a message snapshot we always have to canonicalize the object. 228 // When reading a message snapshot we always have to canonicalize the object.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 reader->AddBackRef(object_id, &type_ref, kIsDeserialized); 280 reader->AddBackRef(object_id, &type_ref, kIsDeserialized);
280 281
281 // Set the object tags. 282 // Set the object tags.
282 type_ref.set_tags(tags); 283 type_ref.set_tags(tags);
283 284
284 // Set all the object fields. 285 // Set all the object fields.
285 // TODO(5411462): Need to assert No GC can happen here, even though 286 // TODO(5411462): Need to assert No GC can happen here, even though
286 // allocations may happen. 287 // allocations may happen.
287 intptr_t num_flds = (type_ref.raw()->to() - type_ref.raw()->from()); 288 intptr_t num_flds = (type_ref.raw()->to() - type_ref.raw()->from());
288 for (intptr_t i = 0; i <= num_flds; i++) { 289 for (intptr_t i = 0; i <= num_flds; i++) {
289 (*reader->ObjectHandle()) = reader->ReadObjectRef(); 290 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef();
290 type_ref.StorePointer((type_ref.raw()->from() + i), 291 type_ref.StorePointer((type_ref.raw()->from() + i),
291 reader->ObjectHandle()->raw()); 292 reader->PassiveObjectHandle()->raw());
292 } 293 }
293 294
294 return type_ref.raw(); 295 return type_ref.raw();
295 } 296 }
296 297
297 298
298 void RawTypeRef::WriteTo(SnapshotWriter* writer, 299 void RawTypeRef::WriteTo(SnapshotWriter* writer,
299 intptr_t object_id, 300 intptr_t object_id,
300 Snapshot::Kind kind) { 301 Snapshot::Kind kind) {
301 ASSERT(writer != NULL); 302 ASSERT(writer != NULL);
(...skipping 29 matching lines...) Expand all
331 type_parameter.set_index(reader->Read<int32_t>()); 332 type_parameter.set_index(reader->Read<int32_t>());
332 type_parameter.set_token_pos(reader->Read<int32_t>()); 333 type_parameter.set_token_pos(reader->Read<int32_t>());
333 type_parameter.set_type_state(reader->Read<int8_t>()); 334 type_parameter.set_type_state(reader->Read<int8_t>());
334 335
335 // Set all the object fields. 336 // Set all the object fields.
336 // TODO(5411462): Need to assert No GC can happen here, even though 337 // TODO(5411462): Need to assert No GC can happen here, even though
337 // allocations may happen. 338 // allocations may happen.
338 intptr_t num_flds = (type_parameter.raw()->to() - 339 intptr_t num_flds = (type_parameter.raw()->to() -
339 type_parameter.raw()->from()); 340 type_parameter.raw()->from());
340 for (intptr_t i = 0; i <= num_flds; i++) { 341 for (intptr_t i = 0; i <= num_flds; i++) {
341 (*reader->ObjectHandle()) = reader->ReadObjectRef(); 342 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef();
342 type_parameter.StorePointer((type_parameter.raw()->from() + i), 343 type_parameter.StorePointer((type_parameter.raw()->from() + i),
343 reader->ObjectHandle()->raw()); 344 reader->PassiveObjectHandle()->raw());
344 } 345 }
345 346
346 return type_parameter.raw(); 347 return type_parameter.raw();
347 } 348 }
348 349
349 350
350 void RawTypeParameter::WriteTo(SnapshotWriter* writer, 351 void RawTypeParameter::WriteTo(SnapshotWriter* writer,
351 intptr_t object_id, 352 intptr_t object_id,
352 Snapshot::Kind kind) { 353 Snapshot::Kind kind) {
353 ASSERT(writer != NULL); 354 ASSERT(writer != NULL);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 387
387 // Set the object tags. 388 // Set the object tags.
388 bounded_type.set_tags(tags); 389 bounded_type.set_tags(tags);
389 390
390 // Set all the object fields. 391 // Set all the object fields.
391 // TODO(5411462): Need to assert No GC can happen here, even though 392 // TODO(5411462): Need to assert No GC can happen here, even though
392 // allocations may happen. 393 // allocations may happen.
393 intptr_t num_flds = (bounded_type.raw()->to() - 394 intptr_t num_flds = (bounded_type.raw()->to() -
394 bounded_type.raw()->from()); 395 bounded_type.raw()->from());
395 for (intptr_t i = 0; i <= num_flds; i++) { 396 for (intptr_t i = 0; i <= num_flds; i++) {
396 (*reader->ObjectHandle()) = reader->ReadObjectRef(); 397 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef();
397 bounded_type.StorePointer((bounded_type.raw()->from() + i), 398 bounded_type.StorePointer((bounded_type.raw()->from() + i),
398 reader->ObjectHandle()->raw()); 399 reader->PassiveObjectHandle()->raw());
399 } 400 }
400 401
401 return bounded_type.raw(); 402 return bounded_type.raw();
402 } 403 }
403 404
404 405
405 void RawBoundedType::WriteTo(SnapshotWriter* writer, 406 void RawBoundedType::WriteTo(SnapshotWriter* writer,
406 intptr_t object_id, 407 intptr_t object_id,
407 Snapshot::Kind kind) { 408 Snapshot::Kind kind) {
408 ASSERT(writer != NULL); 409 ASSERT(writer != NULL);
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 reader->AddBackRef(object_id, &literal_token, kIsDeserialized); 826 reader->AddBackRef(object_id, &literal_token, kIsDeserialized);
826 827
827 // Set the object tags. 828 // Set the object tags.
828 literal_token.set_tags(tags); 829 literal_token.set_tags(tags);
829 830
830 // Read the token attributes. 831 // Read the token attributes.
831 Token::Kind token_kind = static_cast<Token::Kind>(reader->ReadIntptrValue()); 832 Token::Kind token_kind = static_cast<Token::Kind>(reader->ReadIntptrValue());
832 literal_token.set_kind(token_kind); 833 literal_token.set_kind(token_kind);
833 *reader->StringHandle() ^= reader->ReadObjectImpl(); 834 *reader->StringHandle() ^= reader->ReadObjectImpl();
834 literal_token.set_literal(*reader->StringHandle()); 835 literal_token.set_literal(*reader->StringHandle());
835 *reader->ObjectHandle() = reader->ReadObjectImpl(); 836 *reader->PassiveObjectHandle() = reader->ReadObjectImpl();
836 literal_token.set_value(*reader->ObjectHandle()); 837 literal_token.set_value(*reader->PassiveObjectHandle());
837 838
838 return literal_token.raw(); 839 return literal_token.raw();
839 } 840 }
840 841
841 842
842 void RawLiteralToken::WriteTo(SnapshotWriter* writer, 843 void RawLiteralToken::WriteTo(SnapshotWriter* writer,
843 intptr_t object_id, 844 intptr_t object_id,
844 Snapshot::Kind kind) { 845 Snapshot::Kind kind) {
845 ASSERT(writer != NULL); 846 ASSERT(writer != NULL);
846 ASSERT(kind != Snapshot::kMessage); 847 ASSERT(kind != Snapshot::kMessage);
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 context.set_tags(tags); 1336 context.set_tags(tags);
1336 1337
1337 // Set the isolate implicitly. 1338 // Set the isolate implicitly.
1338 context.set_isolate(reader->isolate()); 1339 context.set_isolate(reader->isolate());
1339 1340
1340 // Set all the object fields. 1341 // Set all the object fields.
1341 // TODO(5411462): Need to assert No GC can happen here, even though 1342 // TODO(5411462): Need to assert No GC can happen here, even though
1342 // allocations may happen. 1343 // allocations may happen.
1343 intptr_t num_flds = (context.raw()->to(num_vars) - context.raw()->from()); 1344 intptr_t num_flds = (context.raw()->to(num_vars) - context.raw()->from());
1344 for (intptr_t i = 0; i <= num_flds; i++) { 1345 for (intptr_t i = 0; i <= num_flds; i++) {
1345 (*reader->ObjectHandle()) = reader->ReadObjectRef(); 1346 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef();
1346 context.StorePointer((context.raw()->from() + i), 1347 context.StorePointer((context.raw()->from() + i),
1347 reader->ObjectHandle()->raw()); 1348 reader->PassiveObjectHandle()->raw());
1348 } 1349 }
1349 1350
1350 return context.raw(); 1351 return context.raw();
1351 } 1352 }
1352 1353
1353 1354
1354 void RawContext::WriteTo(SnapshotWriter* writer, 1355 void RawContext::WriteTo(SnapshotWriter* writer,
1355 intptr_t object_id, 1356 intptr_t object_id,
1356 Snapshot::Kind kind) { 1357 Snapshot::Kind kind) {
1357 ASSERT(writer != NULL); 1358 ASSERT(writer != NULL);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 reader->AddBackRef(object_id, &api_error, kIsDeserialized); 1467 reader->AddBackRef(object_id, &api_error, kIsDeserialized);
1467 1468
1468 // Set the object tags. 1469 // Set the object tags.
1469 api_error.set_tags(tags); 1470 api_error.set_tags(tags);
1470 1471
1471 // Set all the object fields. 1472 // Set all the object fields.
1472 // TODO(5411462): Need to assert No GC can happen here, even though 1473 // TODO(5411462): Need to assert No GC can happen here, even though
1473 // allocations may happen. 1474 // allocations may happen.
1474 intptr_t num_flds = (api_error.raw()->to() - api_error.raw()->from()); 1475 intptr_t num_flds = (api_error.raw()->to() - api_error.raw()->from());
1475 for (intptr_t i = 0; i <= num_flds; i++) { 1476 for (intptr_t i = 0; i <= num_flds; i++) {
1476 (*reader->ObjectHandle()) = reader->ReadObjectRef(); 1477 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef();
1477 api_error.StorePointer((api_error.raw()->from() + i), 1478 api_error.StorePointer((api_error.raw()->from() + i),
1478 reader->ObjectHandle()->raw()); 1479 reader->PassiveObjectHandle()->raw());
1479 } 1480 }
1480 1481
1481 return api_error.raw(); 1482 return api_error.raw();
1482 } 1483 }
1483 1484
1484 1485
1485 void RawApiError::WriteTo(SnapshotWriter* writer, 1486 void RawApiError::WriteTo(SnapshotWriter* writer,
1486 intptr_t object_id, 1487 intptr_t object_id,
1487 Snapshot::Kind kind) { 1488 Snapshot::Kind kind) {
1488 ASSERT(writer != NULL); 1489 ASSERT(writer != NULL);
(...skipping 28 matching lines...) Expand all
1517 // Set all non object fields. 1518 // Set all non object fields.
1518 language_error.set_token_pos(reader->Read<int32_t>()); 1519 language_error.set_token_pos(reader->Read<int32_t>());
1519 language_error.set_kind(reader->Read<uint8_t>()); 1520 language_error.set_kind(reader->Read<uint8_t>());
1520 1521
1521 // Set all the object fields. 1522 // Set all the object fields.
1522 // TODO(5411462): Need to assert No GC can happen here, even though 1523 // TODO(5411462): Need to assert No GC can happen here, even though
1523 // allocations may happen. 1524 // allocations may happen.
1524 intptr_t num_flds = 1525 intptr_t num_flds =
1525 (language_error.raw()->to() - language_error.raw()->from()); 1526 (language_error.raw()->to() - language_error.raw()->from());
1526 for (intptr_t i = 0; i <= num_flds; i++) { 1527 for (intptr_t i = 0; i <= num_flds; i++) {
1527 (*reader->ObjectHandle()) = reader->ReadObjectRef(); 1528 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef();
1528 language_error.StorePointer((language_error.raw()->from() + i), 1529 language_error.StorePointer((language_error.raw()->from() + i),
1529 reader->ObjectHandle()->raw()); 1530 reader->PassiveObjectHandle()->raw());
1530 } 1531 }
1531 1532
1532 return language_error.raw(); 1533 return language_error.raw();
1533 } 1534 }
1534 1535
1535 1536
1536 void RawLanguageError::WriteTo(SnapshotWriter* writer, 1537 void RawLanguageError::WriteTo(SnapshotWriter* writer,
1537 intptr_t object_id, 1538 intptr_t object_id,
1538 Snapshot::Kind kind) { 1539 Snapshot::Kind kind) {
1539 ASSERT(writer != NULL); 1540 ASSERT(writer != NULL);
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after
2868 // We do not allow objects with native fields in an isolate message. 2869 // We do not allow objects with native fields in an isolate message.
2869 writer->SetWriteException(Exceptions::kArgument, 2870 writer->SetWriteException(Exceptions::kArgument,
2870 "Illegal argument in isolate message" 2871 "Illegal argument in isolate message"
2871 " : (object is a UserTag)"); 2872 " : (object is a UserTag)");
2872 } else { 2873 } else {
2873 UNREACHABLE(); 2874 UNREACHABLE();
2874 } 2875 }
2875 } 2876 }
2876 2877
2877 } // namespace dart 2878 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698