| 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/snapshot.h" | 5 #include "vm/snapshot.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/bootstrap.h" | 8 #include "vm/bootstrap.h" |
| 9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
| 10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
| (...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1430 } | 1430 } |
| 1431 | 1431 |
| 1432 const Object& obj = Object::Handle(rawobj); | 1432 const Object& obj = Object::Handle(rawobj); |
| 1433 FATAL1("Unexpected reference to object in VM isolate: %s\n", obj.ToCString()); | 1433 FATAL1("Unexpected reference to object in VM isolate: %s\n", obj.ToCString()); |
| 1434 return false; | 1434 return false; |
| 1435 } | 1435 } |
| 1436 | 1436 |
| 1437 #undef VM_OBJECT_WRITE | 1437 #undef VM_OBJECT_WRITE |
| 1438 | 1438 |
| 1439 | 1439 |
| 1440 // An object visitor which will iterate over all the script objects in the heap | |
| 1441 // and either count them or collect them into an array. This is used during | |
| 1442 // full snapshot generation of the VM isolate to write out all script | |
| 1443 // objects and their accompanying token streams. | |
| 1444 class ScriptVisitor : public ObjectVisitor { | |
| 1445 public: | |
| 1446 explicit ScriptVisitor(Thread* thread) | |
| 1447 : objHandle_(Object::Handle(thread->zone())), count_(0), scripts_(NULL) {} | |
| 1448 | |
| 1449 ScriptVisitor(Thread* thread, const Array* scripts) | |
| 1450 : objHandle_(Object::Handle(thread->zone())), | |
| 1451 count_(0), | |
| 1452 scripts_(scripts) {} | |
| 1453 | |
| 1454 void VisitObject(RawObject* obj) { | |
| 1455 if (obj->IsScript()) { | |
| 1456 if (scripts_ != NULL) { | |
| 1457 objHandle_ = obj; | |
| 1458 scripts_->SetAt(count_, objHandle_); | |
| 1459 } | |
| 1460 count_ += 1; | |
| 1461 } | |
| 1462 } | |
| 1463 | |
| 1464 intptr_t count() const { return count_; } | |
| 1465 | |
| 1466 private: | |
| 1467 Object& objHandle_; | |
| 1468 intptr_t count_; | |
| 1469 const Array* scripts_; | |
| 1470 }; | |
| 1471 | |
| 1472 | |
| 1473 ForwardList::ForwardList(Thread* thread, intptr_t first_object_id) | 1440 ForwardList::ForwardList(Thread* thread, intptr_t first_object_id) |
| 1474 : thread_(thread), | 1441 : thread_(thread), |
| 1475 first_object_id_(first_object_id), | 1442 first_object_id_(first_object_id), |
| 1476 nodes_(), | 1443 nodes_(), |
| 1477 first_unprocessed_object_id_(first_object_id) { | 1444 first_unprocessed_object_id_(first_object_id) { |
| 1478 ASSERT(first_object_id > 0); | 1445 ASSERT(first_object_id > 0); |
| 1479 } | 1446 } |
| 1480 | 1447 |
| 1481 | 1448 |
| 1482 ForwardList::~ForwardList() { | 1449 ForwardList::~ForwardList() { |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2052 *buffer_len_ = BytesWritten(); | 2019 *buffer_len_ = BytesWritten(); |
| 2053 } | 2020 } |
| 2054 } else { | 2021 } else { |
| 2055 FreeBuffer(); | 2022 FreeBuffer(); |
| 2056 ThrowException(exception_type(), exception_msg()); | 2023 ThrowException(exception_type(), exception_msg()); |
| 2057 } | 2024 } |
| 2058 } | 2025 } |
| 2059 | 2026 |
| 2060 | 2027 |
| 2061 } // namespace dart | 2028 } // namespace dart |
| OLD | NEW |