| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 | 6 |
| 7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
| (...skipping 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1613 intptr_t* snapshot_size) { | 1613 intptr_t* snapshot_size) { |
| 1614 Zone zone; // Setup a VM zone as we are creating some handles. | 1614 Zone zone; // Setup a VM zone as we are creating some handles. |
| 1615 HandleScope scope; // Setup a VM handle scope. | 1615 HandleScope scope; // Setup a VM handle scope. |
| 1616 if (snapshot_buffer == NULL || snapshot_size == NULL) { | 1616 if (snapshot_buffer == NULL || snapshot_size == NULL) { |
| 1617 return Api::Error("Invalid input parameters to Dart_CreateSnapshot"); | 1617 return Api::Error("Invalid input parameters to Dart_CreateSnapshot"); |
| 1618 } | 1618 } |
| 1619 const char* msg = CheckIsolateState(); | 1619 const char* msg = CheckIsolateState(); |
| 1620 if (msg != NULL) { | 1620 if (msg != NULL) { |
| 1621 return Api::Error(msg); | 1621 return Api::Error(msg); |
| 1622 } | 1622 } |
| 1623 // Since this is only a snapshot the root library should not be set. |
| 1624 Isolate* isolate = Isolate::Current(); |
| 1625 isolate->object_store()->set_root_library(Library::Handle()); |
| 1623 SnapshotWriter writer(true, snapshot_buffer, ApiAllocator); | 1626 SnapshotWriter writer(true, snapshot_buffer, ApiAllocator); |
| 1624 writer.WriteFullSnapshot(); | 1627 writer.WriteFullSnapshot(); |
| 1625 *snapshot_size = writer.Size(); | 1628 *snapshot_size = writer.Size(); |
| 1626 return Api::Success(); | 1629 return Api::Success(); |
| 1627 } | 1630 } |
| 1628 | 1631 |
| 1629 | 1632 |
| 1630 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { | 1633 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { |
| 1631 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); | 1634 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); |
| 1632 return reinterpret_cast<uint8_t*>(new_ptr); | 1635 return reinterpret_cast<uint8_t*>(new_ptr); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1773 ASSERT(isolate != NULL); | 1776 ASSERT(isolate != NULL); |
| 1774 ApiState* state = isolate->api_state(); | 1777 ApiState* state = isolate->api_state(); |
| 1775 ASSERT(state != NULL); | 1778 ASSERT(state != NULL); |
| 1776 ApiLocalScope* scope = state->top_scope(); | 1779 ApiLocalScope* scope = state->top_scope(); |
| 1777 ASSERT(scope != NULL); | 1780 ASSERT(scope != NULL); |
| 1778 return scope->zone().Reallocate(ptr, old_size, new_size); | 1781 return scope->zone().Reallocate(ptr, old_size, new_size); |
| 1779 } | 1782 } |
| 1780 | 1783 |
| 1781 | 1784 |
| 1782 } // namespace dart | 1785 } // namespace dart |
| OLD | NEW |