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

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

Issue 15383002: Use handles to save the object being read before calling StorePointer to make (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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.cc ('k') | no next file » | 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 131
132 // Set all non object fields. 132 // Set all non object fields.
133 unresolved_class.set_token_pos(reader->ReadIntptrValue()); 133 unresolved_class.set_token_pos(reader->ReadIntptrValue());
134 134
135 // Set all the object fields. 135 // Set all the object fields.
136 // TODO(5411462): Need to assert No GC can happen here, even though 136 // TODO(5411462): Need to assert No GC can happen here, even though
137 // allocations may happen. 137 // allocations may happen.
138 intptr_t num_flds = (unresolved_class.raw()->to() - 138 intptr_t num_flds = (unresolved_class.raw()->to() -
139 unresolved_class.raw()->from()); 139 unresolved_class.raw()->from());
140 for (intptr_t i = 0; i <= num_flds; i++) { 140 for (intptr_t i = 0; i <= num_flds; i++) {
141 (*reader->ObjectHandle()) = reader->ReadObjectRef();
141 unresolved_class.StorePointer((unresolved_class.raw()->from() + i), 142 unresolved_class.StorePointer((unresolved_class.raw()->from() + i),
142 reader->ReadObjectRef()); 143 reader->ObjectHandle()->raw());
143 } 144 }
144 return unresolved_class.raw(); 145 return unresolved_class.raw();
145 } 146 }
146 147
147 148
148 void RawUnresolvedClass::WriteTo(SnapshotWriter* writer, 149 void RawUnresolvedClass::WriteTo(SnapshotWriter* writer,
149 intptr_t object_id, 150 intptr_t object_id,
150 Snapshot::Kind kind) { 151 Snapshot::Kind kind) {
151 ASSERT(writer != NULL); 152 ASSERT(writer != NULL);
152 153
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 195
195 // Set all non object fields. 196 // Set all non object fields.
196 type.set_token_pos(reader->ReadIntptrValue()); 197 type.set_token_pos(reader->ReadIntptrValue());
197 type.set_type_state(reader->Read<int8_t>()); 198 type.set_type_state(reader->Read<int8_t>());
198 199
199 // Set all the object fields. 200 // Set all the object fields.
200 // TODO(5411462): Need to assert No GC can happen here, even though 201 // TODO(5411462): Need to assert No GC can happen here, even though
201 // allocations may happen. 202 // allocations may happen.
202 intptr_t num_flds = (type.raw()->to() - type.raw()->from()); 203 intptr_t num_flds = (type.raw()->to() - type.raw()->from());
203 for (intptr_t i = 0; i <= num_flds; i++) { 204 for (intptr_t i = 0; i <= num_flds; i++) {
204 type.StorePointer((type.raw()->from() + i), reader->ReadObjectRef()); 205 (*reader->ObjectHandle()) = reader->ReadObjectRef();
206 type.StorePointer((type.raw()->from() + i), reader->ObjectHandle()->raw());
205 } 207 }
206 208
207 // If object needs to be a canonical object, Canonicalize it. 209 // If object needs to be a canonical object, Canonicalize it.
208 // When reading a full snapshot we don't need to canonicalize the object 210 // When reading a full snapshot we don't need to canonicalize the object
209 // as it would already be a canonical object. 211 // as it would already be a canonical object.
210 // When reading a script snapshot we need to canonicalize only those object 212 // When reading a script snapshot we need to canonicalize only those object
211 // references that are objects from the core library (loaded from a 213 // references that are objects from the core library (loaded from a
212 // full snapshot). Objects that are only in the script need not be 214 // full snapshot). Objects that are only in the script need not be
213 // canonicalized as they are already canonical. 215 // canonicalized as they are already canonical.
214 // When reading a message snapshot we always have to canonicalize the object. 216 // When reading a message snapshot we always have to canonicalize the object.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 type_parameter.set_index(reader->ReadIntptrValue()); 310 type_parameter.set_index(reader->ReadIntptrValue());
309 type_parameter.set_token_pos(reader->ReadIntptrValue()); 311 type_parameter.set_token_pos(reader->ReadIntptrValue());
310 type_parameter.set_type_state(reader->Read<int8_t>()); 312 type_parameter.set_type_state(reader->Read<int8_t>());
311 313
312 // Set all the object fields. 314 // Set all the object fields.
313 // TODO(5411462): Need to assert No GC can happen here, even though 315 // TODO(5411462): Need to assert No GC can happen here, even though
314 // allocations may happen. 316 // allocations may happen.
315 intptr_t num_flds = (type_parameter.raw()->to() - 317 intptr_t num_flds = (type_parameter.raw()->to() -
316 type_parameter.raw()->from()); 318 type_parameter.raw()->from());
317 for (intptr_t i = 0; i <= num_flds; i++) { 319 for (intptr_t i = 0; i <= num_flds; i++) {
320 (*reader->ObjectHandle()) = reader->ReadObjectRef();
318 type_parameter.StorePointer((type_parameter.raw()->from() + i), 321 type_parameter.StorePointer((type_parameter.raw()->from() + i),
319 reader->ReadObjectRef()); 322 reader->ObjectHandle()->raw());
320 } 323 }
321 324
322 return type_parameter.raw(); 325 return type_parameter.raw();
323 } 326 }
324 327
325 328
326 void RawTypeParameter::WriteTo(SnapshotWriter* writer, 329 void RawTypeParameter::WriteTo(SnapshotWriter* writer,
327 intptr_t object_id, 330 intptr_t object_id,
328 Snapshot::Kind kind) { 331 Snapshot::Kind kind) {
329 ASSERT(writer != NULL); 332 ASSERT(writer != NULL);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 382
380 // Set the object tags. 383 // Set the object tags.
381 bounded_type.set_tags(tags); 384 bounded_type.set_tags(tags);
382 385
383 // Set all the object fields. 386 // Set all the object fields.
384 // TODO(5411462): Need to assert No GC can happen here, even though 387 // TODO(5411462): Need to assert No GC can happen here, even though
385 // allocations may happen. 388 // allocations may happen.
386 intptr_t num_flds = (bounded_type.raw()->to() - 389 intptr_t num_flds = (bounded_type.raw()->to() -
387 bounded_type.raw()->from()); 390 bounded_type.raw()->from());
388 for (intptr_t i = 0; i <= num_flds; i++) { 391 for (intptr_t i = 0; i <= num_flds; i++) {
392 (*reader->ObjectHandle()) = reader->ReadObjectRef();
389 bounded_type.StorePointer((bounded_type.raw()->from() + i), 393 bounded_type.StorePointer((bounded_type.raw()->from() + i),
390 reader->ReadObjectRef()); 394 reader->ObjectHandle()->raw());
391 } 395 }
392 396
393 bounded_type.set_is_being_checked(false); 397 bounded_type.set_is_being_checked(false);
394 398
395 return bounded_type.raw(); 399 return bounded_type.raw();
396 } 400 }
397 401
398 402
399 void RawBoundedType::WriteTo(SnapshotWriter* writer, 403 void RawBoundedType::WriteTo(SnapshotWriter* writer,
400 intptr_t object_id, 404 intptr_t object_id,
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 533
530 // Set the object tags. 534 // Set the object tags.
531 instantiated_type_arguments.set_tags(tags); 535 instantiated_type_arguments.set_tags(tags);
532 536
533 // Set all the object fields. 537 // Set all the object fields.
534 // TODO(5411462): Need to assert No GC can happen here, even though 538 // TODO(5411462): Need to assert No GC can happen here, even though
535 // allocations may happen. 539 // allocations may happen.
536 intptr_t num_flds = (instantiated_type_arguments.raw()->to() - 540 intptr_t num_flds = (instantiated_type_arguments.raw()->to() -
537 instantiated_type_arguments.raw()->from()); 541 instantiated_type_arguments.raw()->from());
538 for (intptr_t i = 0; i <= num_flds; i++) { 542 for (intptr_t i = 0; i <= num_flds; i++) {
543 (*reader->ObjectHandle()) = reader->ReadObjectRef();
539 instantiated_type_arguments.StorePointer( 544 instantiated_type_arguments.StorePointer(
540 (instantiated_type_arguments.raw()->from() + i), 545 (instantiated_type_arguments.raw()->from() + i),
541 reader->ReadObjectRef()); 546 reader->ObjectHandle()->raw());
542 } 547 }
543 return instantiated_type_arguments.raw(); 548 return instantiated_type_arguments.raw();
544 } 549 }
545 550
546 551
547 void RawInstantiatedTypeArguments::WriteTo(SnapshotWriter* writer, 552 void RawInstantiatedTypeArguments::WriteTo(SnapshotWriter* writer,
548 intptr_t object_id, 553 intptr_t object_id,
549 Snapshot::Kind kind) { 554 Snapshot::Kind kind) {
550 ASSERT(writer != NULL); 555 ASSERT(writer != NULL);
551 ASSERT(kind == Snapshot::kMessage); 556 ASSERT(kind == Snapshot::kMessage);
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 context.set_tags(tags); 1350 context.set_tags(tags);
1346 1351
1347 // Set the isolate implicitly. 1352 // Set the isolate implicitly.
1348 context.set_isolate(Isolate::Current()); 1353 context.set_isolate(Isolate::Current());
1349 1354
1350 // Set all the object fields. 1355 // Set all the object fields.
1351 // TODO(5411462): Need to assert No GC can happen here, even though 1356 // TODO(5411462): Need to assert No GC can happen here, even though
1352 // allocations may happen. 1357 // allocations may happen.
1353 intptr_t num_flds = (context.raw()->to(num_vars) - context.raw()->from()); 1358 intptr_t num_flds = (context.raw()->to(num_vars) - context.raw()->from());
1354 for (intptr_t i = 0; i <= num_flds; i++) { 1359 for (intptr_t i = 0; i <= num_flds; i++) {
1355 context.StorePointer((context.raw()->from() + i), reader->ReadObjectRef()); 1360 (*reader->ObjectHandle()) = reader->ReadObjectRef();
1361 context.StorePointer((context.raw()->from() + i),
1362 reader->ObjectHandle()->raw());
1356 } 1363 }
1357 1364
1358 return context.raw(); 1365 return context.raw();
1359 } 1366 }
1360 1367
1361 1368
1362 void RawContext::WriteTo(SnapshotWriter* writer, 1369 void RawContext::WriteTo(SnapshotWriter* writer,
1363 intptr_t object_id, 1370 intptr_t object_id,
1364 Snapshot::Kind kind) { 1371 Snapshot::Kind kind) {
1365 ASSERT(writer != NULL); 1372 ASSERT(writer != NULL);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1474 reader->AddBackRef(object_id, &api_error, kIsDeserialized); 1481 reader->AddBackRef(object_id, &api_error, kIsDeserialized);
1475 1482
1476 // Set the object tags. 1483 // Set the object tags.
1477 api_error.set_tags(tags); 1484 api_error.set_tags(tags);
1478 1485
1479 // Set all the object fields. 1486 // Set all the object fields.
1480 // TODO(5411462): Need to assert No GC can happen here, even though 1487 // TODO(5411462): Need to assert No GC can happen here, even though
1481 // allocations may happen. 1488 // allocations may happen.
1482 intptr_t num_flds = (api_error.raw()->to() - api_error.raw()->from()); 1489 intptr_t num_flds = (api_error.raw()->to() - api_error.raw()->from());
1483 for (intptr_t i = 0; i <= num_flds; i++) { 1490 for (intptr_t i = 0; i <= num_flds; i++) {
1491 (*reader->ObjectHandle()) = reader->ReadObjectRef();
1484 api_error.StorePointer((api_error.raw()->from() + i), 1492 api_error.StorePointer((api_error.raw()->from() + i),
1485 reader->ReadObjectRef()); 1493 reader->ObjectHandle()->raw());
1486 } 1494 }
1487 1495
1488 return api_error.raw(); 1496 return api_error.raw();
1489 } 1497 }
1490 1498
1491 1499
1492 void RawApiError::WriteTo(SnapshotWriter* writer, 1500 void RawApiError::WriteTo(SnapshotWriter* writer,
1493 intptr_t object_id, 1501 intptr_t object_id,
1494 Snapshot::Kind kind) { 1502 Snapshot::Kind kind) {
1495 ASSERT(writer != NULL); 1503 ASSERT(writer != NULL);
(...skipping 24 matching lines...) Expand all
1520 1528
1521 // Set the object tags. 1529 // Set the object tags.
1522 language_error.set_tags(tags); 1530 language_error.set_tags(tags);
1523 1531
1524 // Set all the object fields. 1532 // Set all the object fields.
1525 // TODO(5411462): Need to assert No GC can happen here, even though 1533 // TODO(5411462): Need to assert No GC can happen here, even though
1526 // allocations may happen. 1534 // allocations may happen.
1527 intptr_t num_flds = 1535 intptr_t num_flds =
1528 (language_error.raw()->to() - language_error.raw()->from()); 1536 (language_error.raw()->to() - language_error.raw()->from());
1529 for (intptr_t i = 0; i <= num_flds; i++) { 1537 for (intptr_t i = 0; i <= num_flds; i++) {
1538 (*reader->ObjectHandle()) = reader->ReadObjectRef();
1530 language_error.StorePointer((language_error.raw()->from() + i), 1539 language_error.StorePointer((language_error.raw()->from() + i),
1531 reader->ReadObjectRef()); 1540 reader->ObjectHandle()->raw());
1532 } 1541 }
1533 1542
1534 return language_error.raw(); 1543 return language_error.raw();
1535 } 1544 }
1536 1545
1537 1546
1538 void RawLanguageError::WriteTo(SnapshotWriter* writer, 1547 void RawLanguageError::WriteTo(SnapshotWriter* writer,
1539 intptr_t object_id, 1548 intptr_t object_id,
1540 Snapshot::Kind kind) { 1549 Snapshot::Kind kind) {
1541 ASSERT(writer != NULL); 1550 ASSERT(writer != NULL);
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after
2612 // Write out the class and tags information. 2621 // Write out the class and tags information.
2613 writer->WriteIndexedObject(kWeakPropertyCid); 2622 writer->WriteIndexedObject(kWeakPropertyCid);
2614 writer->WriteIntptrValue(writer->GetObjectTags(this)); 2623 writer->WriteIntptrValue(writer->GetObjectTags(this));
2615 2624
2616 // Write out all the other fields. 2625 // Write out all the other fields.
2617 writer->Write<RawObject*>(ptr()->key_); 2626 writer->Write<RawObject*>(ptr()->key_);
2618 writer->Write<RawObject*>(ptr()->value_); 2627 writer->Write<RawObject*>(ptr()->value_);
2619 } 2628 }
2620 2629
2621 } // namespace dart 2630 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698