OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 #include "include/dart_mirrors_api.h" | 6 #include "include/dart_mirrors_api.h" |
7 #include "include/dart_native_api.h" | 7 #include "include/dart_native_api.h" |
8 | 8 |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "lib/stacktrace.h" | 10 #include "lib/stacktrace.h" |
(...skipping 1568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1579 FullSnapshotWriter writer(Snapshot::kCore, vm_isolate_snapshot_buffer, | 1579 FullSnapshotWriter writer(Snapshot::kCore, vm_isolate_snapshot_buffer, |
1580 isolate_snapshot_buffer, ApiReallocate, | 1580 isolate_snapshot_buffer, ApiReallocate, |
1581 NULL /* instructions_writer */); | 1581 NULL /* instructions_writer */); |
1582 writer.WriteFullSnapshot(); | 1582 writer.WriteFullSnapshot(); |
1583 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); | 1583 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); |
1584 *isolate_snapshot_size = writer.IsolateSnapshotSize(); | 1584 *isolate_snapshot_size = writer.IsolateSnapshotSize(); |
1585 return Api::Success(); | 1585 return Api::Success(); |
1586 } | 1586 } |
1587 | 1587 |
1588 | 1588 |
1589 static Dart_Handle createLibrarySnapshot(Dart_Handle library, | 1589 DART_EXPORT Dart_Handle Dart_CreateScriptSnapshot(uint8_t** buffer, |
1590 uint8_t** buffer, | 1590 intptr_t* size) { |
1591 intptr_t* size) { | 1591 API_TIMELINE_DURATION; |
1592 DARTSCOPE(Thread::Current()); | 1592 DARTSCOPE(Thread::Current()); |
1593 Isolate* I = T->isolate(); | 1593 Isolate* I = T->isolate(); |
1594 if (buffer == NULL) { | 1594 if (buffer == NULL) { |
1595 RETURN_NULL_ERROR(buffer); | 1595 RETURN_NULL_ERROR(buffer); |
1596 } | 1596 } |
1597 if (size == NULL) { | 1597 if (size == NULL) { |
1598 RETURN_NULL_ERROR(size); | 1598 RETURN_NULL_ERROR(size); |
1599 } | 1599 } |
1600 // Finalize all classes if needed. | 1600 // Finalize all classes if needed. |
1601 Dart_Handle state = Api::CheckAndFinalizePendingClasses(T); | 1601 Dart_Handle state = Api::CheckAndFinalizePendingClasses(T); |
1602 if (::Dart_IsError(state)) { | 1602 if (::Dart_IsError(state)) { |
1603 return state; | 1603 return state; |
1604 } | 1604 } |
1605 Library& lib = Library::Handle(Z); | 1605 Library& lib = Library::Handle(Z, I->object_store()->root_library()); |
1606 if (library == Dart_Null()) { | |
1607 lib ^= I->object_store()->root_library(); | |
1608 } else { | |
1609 lib ^= Api::UnwrapHandle(library); | |
1610 } | |
1611 | 1606 |
1612 #if defined(DEBUG) | 1607 #if defined(DEBUG) |
1613 I->heap()->CollectAllGarbage(); | 1608 I->heap()->CollectAllGarbage(); |
1614 FunctionVisitor check_canonical(T); | 1609 FunctionVisitor check_canonical(T); |
1615 I->heap()->IterateObjects(&check_canonical); | 1610 I->heap()->IterateObjects(&check_canonical); |
1616 #endif // #if defined(DEBUG) | 1611 #endif // #if defined(DEBUG) |
1617 | 1612 |
1618 ScriptSnapshotWriter writer(buffer, ApiReallocate); | 1613 ScriptSnapshotWriter writer(buffer, ApiReallocate); |
1619 writer.WriteScriptSnapshot(lib); | 1614 writer.WriteScriptSnapshot(lib); |
1620 *size = writer.BytesWritten(); | 1615 *size = writer.BytesWritten(); |
1621 return Api::Success(); | 1616 return Api::Success(); |
1622 } | 1617 } |
1623 | 1618 |
1624 | 1619 |
1625 DART_EXPORT Dart_Handle Dart_CreateScriptSnapshot(uint8_t** buffer, | |
1626 intptr_t* size) { | |
1627 API_TIMELINE_DURATION; | |
1628 return createLibrarySnapshot(Dart_Null(), buffer, size); | |
1629 } | |
1630 | |
1631 | |
1632 DART_EXPORT Dart_Handle Dart_CreateLibrarySnapshot(Dart_Handle library, | |
1633 uint8_t** buffer, | |
1634 intptr_t* size) { | |
1635 API_TIMELINE_DURATION; | |
1636 return createLibrarySnapshot(library, buffer, size); | |
1637 } | |
1638 | |
1639 | |
1640 DART_EXPORT void Dart_InterruptIsolate(Dart_Isolate isolate) { | 1620 DART_EXPORT void Dart_InterruptIsolate(Dart_Isolate isolate) { |
1641 if (isolate == NULL) { | 1621 if (isolate == NULL) { |
1642 FATAL1("%s expects argument 'isolate' to be non-null.", CURRENT_FUNC); | 1622 FATAL1("%s expects argument 'isolate' to be non-null.", CURRENT_FUNC); |
1643 } | 1623 } |
1644 // TODO(16615): Validate isolate parameter. | 1624 // TODO(16615): Validate isolate parameter. |
1645 TransitionNativeToVM transition(Thread::Current()); | 1625 TransitionNativeToVM transition(Thread::Current()); |
1646 Isolate* iso = reinterpret_cast<Isolate*>(isolate); | 1626 Isolate* iso = reinterpret_cast<Isolate*>(isolate); |
1647 iso->SendInternalLibMessage(Isolate::kInterruptMsg, iso->pause_capability()); | 1627 iso->SendInternalLibMessage(Isolate::kInterruptMsg, iso->pause_capability()); |
1648 } | 1628 } |
1649 | 1629 |
(...skipping 5061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6711 } | 6691 } |
6712 | 6692 |
6713 | 6693 |
6714 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { | 6694 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { |
6715 #ifndef PRODUCT | 6695 #ifndef PRODUCT |
6716 Profiler::DumpStackTrace(context); | 6696 Profiler::DumpStackTrace(context); |
6717 #endif | 6697 #endif |
6718 } | 6698 } |
6719 | 6699 |
6720 } // namespace dart | 6700 } // namespace dart |
OLD | NEW |