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 6586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6597 Precompiler::CompileAll(entry_points, jit_feedback, jit_feedback_length)); | 6597 Precompiler::CompileAll(entry_points, jit_feedback, jit_feedback_length)); |
6598 if (!error.IsNull()) { | 6598 if (!error.IsNull()) { |
6599 return Api::NewHandle(T, error.raw()); | 6599 return Api::NewHandle(T, error.raw()); |
6600 } | 6600 } |
6601 return Api::Success(); | 6601 return Api::Success(); |
6602 #endif | 6602 #endif |
6603 } | 6603 } |
6604 | 6604 |
6605 | 6605 |
6606 DART_EXPORT Dart_Handle | 6606 DART_EXPORT Dart_Handle |
6607 Dart_CreatePrecompiledSnapshotAssembly(uint8_t** assembly_buffer, | 6607 Dart_CreateAppAOTSnapshotAsAssembly(uint8_t** assembly_buffer, |
6608 intptr_t* assembly_size) { | 6608 intptr_t* assembly_size) { |
6609 #if defined(TARGET_ARCH_IA32) | 6609 #if defined(TARGET_ARCH_IA32) |
6610 return Api::NewError("AOT compilation is not supported on IA32."); | 6610 return Api::NewError("AOT compilation is not supported on IA32."); |
6611 #elif defined(TARGET_ARCH_DBC) | 6611 #elif defined(TARGET_ARCH_DBC) |
6612 return Api::NewError("AOT compilation is not supported on DBC."); | 6612 return Api::NewError("AOT compilation is not supported on DBC."); |
6613 #elif !defined(DART_PRECOMPILER) | 6613 #elif !defined(DART_PRECOMPILER) |
6614 return Api::NewError( | 6614 return Api::NewError( |
6615 "This VM was built without support for AOT compilation."); | 6615 "This VM was built without support for AOT compilation."); |
6616 #else | 6616 #else |
6617 API_TIMELINE_DURATION; | 6617 API_TIMELINE_DURATION; |
6618 DARTSCOPE(Thread::Current()); | 6618 DARTSCOPE(Thread::Current()); |
(...skipping 23 matching lines...) Expand all Loading... |
6642 | 6642 |
6643 writer.WriteFullSnapshot(); | 6643 writer.WriteFullSnapshot(); |
6644 *assembly_size = instructions_writer.AssemblySize(); | 6644 *assembly_size = instructions_writer.AssemblySize(); |
6645 | 6645 |
6646 return Api::Success(); | 6646 return Api::Success(); |
6647 #endif | 6647 #endif |
6648 } | 6648 } |
6649 | 6649 |
6650 | 6650 |
6651 DART_EXPORT Dart_Handle | 6651 DART_EXPORT Dart_Handle |
6652 Dart_CreatePrecompiledSnapshotBlob(uint8_t** vm_isolate_snapshot_buffer, | 6652 Dart_CreateAppAOTSnapshotAsBlobs(uint8_t** vm_isolate_snapshot_buffer, |
6653 intptr_t* vm_isolate_snapshot_size, | 6653 intptr_t* vm_isolate_snapshot_size, |
6654 uint8_t** isolate_snapshot_buffer, | 6654 uint8_t** isolate_snapshot_buffer, |
6655 intptr_t* isolate_snapshot_size, | 6655 intptr_t* isolate_snapshot_size, |
6656 uint8_t** instructions_blob_buffer, | 6656 uint8_t** instructions_blob_buffer, |
6657 intptr_t* instructions_blob_size, | 6657 intptr_t* instructions_blob_size, |
6658 uint8_t** rodata_blob_buffer, | 6658 uint8_t** rodata_blob_buffer, |
6659 intptr_t* rodata_blob_size) { | 6659 intptr_t* rodata_blob_size) { |
6660 #if defined(TARGET_ARCH_IA32) | 6660 #if defined(TARGET_ARCH_IA32) |
6661 return Api::NewError("AOT compilation is not supported on IA32."); | 6661 return Api::NewError("AOT compilation is not supported on IA32."); |
6662 #elif defined(TARGET_ARCH_DBC) | 6662 #elif defined(TARGET_ARCH_DBC) |
6663 return Api::NewError("AOT compilation is not supported on DBC."); | 6663 return Api::NewError("AOT compilation is not supported on DBC."); |
6664 #elif !defined(DART_PRECOMPILER) | 6664 #elif !defined(DART_PRECOMPILER) |
6665 return Api::NewError( | 6665 return Api::NewError( |
6666 "This VM was built without support for AOT compilation."); | 6666 "This VM was built without support for AOT compilation."); |
6667 #else | 6667 #else |
6668 API_TIMELINE_DURATION; | 6668 API_TIMELINE_DURATION; |
6669 DARTSCOPE(Thread::Current()); | 6669 DARTSCOPE(Thread::Current()); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6712 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); | 6712 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); |
6713 *isolate_snapshot_size = writer.IsolateSnapshotSize(); | 6713 *isolate_snapshot_size = writer.IsolateSnapshotSize(); |
6714 *instructions_blob_size = instructions_writer.InstructionsBlobSize(); | 6714 *instructions_blob_size = instructions_writer.InstructionsBlobSize(); |
6715 *rodata_blob_size = instructions_writer.RodataBlobSize(); | 6715 *rodata_blob_size = instructions_writer.RodataBlobSize(); |
6716 | 6716 |
6717 return Api::Success(); | 6717 return Api::Success(); |
6718 #endif | 6718 #endif |
6719 } | 6719 } |
6720 | 6720 |
6721 | 6721 |
6722 DART_EXPORT Dart_Handle Dart_PrecompileJIT() { | |
6723 API_TIMELINE_BEGIN_END; | |
6724 DARTSCOPE(Thread::Current()); | |
6725 Isolate* I = T->isolate(); | |
6726 Dart_Handle result = Api::CheckAndFinalizePendingClasses(T); | |
6727 if (::Dart_IsError(result)) { | |
6728 return result; | |
6729 } | |
6730 CHECK_CALLBACK_STATE(T); | |
6731 GrowableObjectArray& libraries = | |
6732 GrowableObjectArray::Handle(Z, I->object_store()->libraries()); | |
6733 Library& lib = Library::Handle(Z); | |
6734 Class& cls = Class::Handle(Z); | |
6735 Error& error = Error::Handle(Z); | |
6736 for (intptr_t i = 0; i < libraries.Length(); i++) { | |
6737 lib ^= libraries.At(i); | |
6738 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate); | |
6739 while (it.HasNext()) { | |
6740 cls = it.GetNextClass(); | |
6741 if (cls.IsDynamicClass()) { | |
6742 continue; // class 'dynamic' is in the read-only VM isolate. | |
6743 } | |
6744 error = cls.EnsureIsFinalized(T); | |
6745 if (!error.IsNull()) { | |
6746 return Api::NewHandle(T, error.raw()); | |
6747 } | |
6748 } | |
6749 } | |
6750 return Api::Success(); | |
6751 } | |
6752 | |
6753 | |
6754 DART_EXPORT Dart_Handle | 6722 DART_EXPORT Dart_Handle |
6755 Dart_CreateAppJITSnapshot(uint8_t** isolate_snapshot_buffer, | 6723 Dart_CreateAppJITSnapshotAsBlobs(uint8_t** isolate_snapshot_buffer, |
6756 intptr_t* isolate_snapshot_size, | 6724 intptr_t* isolate_snapshot_size, |
6757 uint8_t** instructions_blob_buffer, | 6725 uint8_t** instructions_blob_buffer, |
6758 intptr_t* instructions_blob_size, | 6726 intptr_t* instructions_blob_size, |
6759 uint8_t** rodata_blob_buffer, | 6727 uint8_t** rodata_blob_buffer, |
6760 intptr_t* rodata_blob_size) { | 6728 intptr_t* rodata_blob_size) { |
6761 #if defined(TARGET_ARCH_IA32) | 6729 #if defined(TARGET_ARCH_IA32) |
6762 return Api::NewError("Snapshots with code are not supported on IA32."); | 6730 return Api::NewError("Snapshots with code are not supported on IA32."); |
6763 #elif defined(TARGET_ARCH_DBC) | 6731 #elif defined(TARGET_ARCH_DBC) |
6764 return Api::NewError("Snapshots with code are not supported on DBC."); | 6732 return Api::NewError("Snapshots with code are not supported on DBC."); |
| 6733 #elif defined(DART_PRECOMPILED_RUNTIME) |
| 6734 return Api::NewError("JIT app snapshots cannot be taken from an AOT runtime"); |
6765 #else | 6735 #else |
6766 API_TIMELINE_DURATION; | 6736 API_TIMELINE_DURATION; |
6767 DARTSCOPE(Thread::Current()); | 6737 DARTSCOPE(Thread::Current()); |
6768 Isolate* I = T->isolate(); | 6738 Isolate* I = T->isolate(); |
6769 if (!FLAG_load_deferred_eagerly) { | 6739 if (!FLAG_load_deferred_eagerly) { |
6770 return Api::NewError( | 6740 return Api::NewError( |
6771 "Creating full snapshots requires --load_deferred_eagerly"); | 6741 "Creating full snapshots requires --load_deferred_eagerly"); |
6772 } | 6742 } |
6773 if (isolate_snapshot_buffer == NULL) { | 6743 if (isolate_snapshot_buffer == NULL) { |
6774 RETURN_NULL_ERROR(isolate_snapshot_buffer); | 6744 RETURN_NULL_ERROR(isolate_snapshot_buffer); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6821 } | 6791 } |
6822 | 6792 |
6823 | 6793 |
6824 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { | 6794 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { |
6825 #ifndef PRODUCT | 6795 #ifndef PRODUCT |
6826 Profiler::DumpStackTrace(context); | 6796 Profiler::DumpStackTrace(context); |
6827 #endif | 6797 #endif |
6828 } | 6798 } |
6829 | 6799 |
6830 } // namespace dart | 6800 } // namespace dart |
OLD | NEW |