| 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 6614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6625 if (!error.IsNull()) { | 6625 if (!error.IsNull()) { |
| 6626 return Api::NewHandle(T, error.raw()); | 6626 return Api::NewHandle(T, error.raw()); |
| 6627 } | 6627 } |
| 6628 } | 6628 } |
| 6629 } | 6629 } |
| 6630 return Api::Success(); | 6630 return Api::Success(); |
| 6631 } | 6631 } |
| 6632 | 6632 |
| 6633 | 6633 |
| 6634 DART_EXPORT Dart_Handle | 6634 DART_EXPORT Dart_Handle |
| 6635 Dart_CreateAppJITSnapshot(uint8_t** vm_isolate_snapshot_buffer, | 6635 Dart_CreateAppJITSnapshot(uint8_t** isolate_snapshot_buffer, |
| 6636 intptr_t* vm_isolate_snapshot_size, | |
| 6637 uint8_t** isolate_snapshot_buffer, | |
| 6638 intptr_t* isolate_snapshot_size, | 6636 intptr_t* isolate_snapshot_size, |
| 6639 uint8_t** instructions_blob_buffer, | 6637 uint8_t** instructions_blob_buffer, |
| 6640 intptr_t* instructions_blob_size, | 6638 intptr_t* instructions_blob_size, |
| 6641 uint8_t** rodata_blob_buffer, | 6639 uint8_t** rodata_blob_buffer, |
| 6642 intptr_t* rodata_blob_size) { | 6640 intptr_t* rodata_blob_size) { |
| 6643 #if defined(TARGET_ARCH_IA32) | 6641 #if defined(TARGET_ARCH_IA32) |
| 6644 return Api::NewError("Snapshots with code are not supported on IA32."); | 6642 return Api::NewError("Snapshots with code are not supported on IA32."); |
| 6645 #elif defined(TARGET_ARCH_DBC) | 6643 #elif defined(TARGET_ARCH_DBC) |
| 6646 return Api::NewError("Snapshots with code are not supported on DBC."); | 6644 return Api::NewError("Snapshots with code are not supported on DBC."); |
| 6647 #else | 6645 #else |
| 6648 API_TIMELINE_DURATION; | 6646 API_TIMELINE_DURATION; |
| 6649 DARTSCOPE(Thread::Current()); | 6647 DARTSCOPE(Thread::Current()); |
| 6650 Isolate* I = T->isolate(); | 6648 Isolate* I = T->isolate(); |
| 6651 if (!FLAG_load_deferred_eagerly) { | 6649 if (!FLAG_load_deferred_eagerly) { |
| 6652 return Api::NewError( | 6650 return Api::NewError( |
| 6653 "Creating full snapshots requires --load_deferred_eagerly"); | 6651 "Creating full snapshots requires --load_deferred_eagerly"); |
| 6654 } | 6652 } |
| 6655 if (vm_isolate_snapshot_buffer == NULL) { | |
| 6656 RETURN_NULL_ERROR(vm_isolate_snapshot_buffer); | |
| 6657 } | |
| 6658 if (vm_isolate_snapshot_size == NULL) { | |
| 6659 RETURN_NULL_ERROR(vm_isolate_snapshot_size); | |
| 6660 } | |
| 6661 if (isolate_snapshot_buffer == NULL) { | 6653 if (isolate_snapshot_buffer == NULL) { |
| 6662 RETURN_NULL_ERROR(isolate_snapshot_buffer); | 6654 RETURN_NULL_ERROR(isolate_snapshot_buffer); |
| 6663 } | 6655 } |
| 6664 if (isolate_snapshot_size == NULL) { | 6656 if (isolate_snapshot_size == NULL) { |
| 6665 RETURN_NULL_ERROR(isolate_snapshot_size); | 6657 RETURN_NULL_ERROR(isolate_snapshot_size); |
| 6666 } | 6658 } |
| 6667 if (instructions_blob_buffer == NULL) { | 6659 if (instructions_blob_buffer == NULL) { |
| 6668 RETURN_NULL_ERROR(instructions_blob_buffer); | 6660 RETURN_NULL_ERROR(instructions_blob_buffer); |
| 6669 } | 6661 } |
| 6670 if (instructions_blob_size == NULL) { | 6662 if (instructions_blob_size == NULL) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 6681 if (::Dart_IsError(state)) { | 6673 if (::Dart_IsError(state)) { |
| 6682 return state; | 6674 return state; |
| 6683 } | 6675 } |
| 6684 I->StopBackgroundCompiler(); | 6676 I->StopBackgroundCompiler(); |
| 6685 | 6677 |
| 6686 NOT_IN_PRODUCT(TimelineDurationScope tds2(T, Timeline::GetIsolateStream(), | 6678 NOT_IN_PRODUCT(TimelineDurationScope tds2(T, Timeline::GetIsolateStream(), |
| 6687 "WriteAppJITSnapshot")); | 6679 "WriteAppJITSnapshot")); |
| 6688 BlobInstructionsWriter instructions_writer(instructions_blob_buffer, | 6680 BlobInstructionsWriter instructions_writer(instructions_blob_buffer, |
| 6689 rodata_blob_buffer, ApiReallocate, | 6681 rodata_blob_buffer, ApiReallocate, |
| 6690 2 * MB /* initial_size */); | 6682 2 * MB /* initial_size */); |
| 6691 FullSnapshotWriter writer(Snapshot::kAppJIT, vm_isolate_snapshot_buffer, | 6683 FullSnapshotWriter writer(Snapshot::kAppJIT, NULL, isolate_snapshot_buffer, |
| 6692 isolate_snapshot_buffer, ApiReallocate, | 6684 ApiReallocate, &instructions_writer); |
| 6693 &instructions_writer); | |
| 6694 writer.WriteFullSnapshot(); | 6685 writer.WriteFullSnapshot(); |
| 6695 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); | |
| 6696 *isolate_snapshot_size = writer.IsolateSnapshotSize(); | 6686 *isolate_snapshot_size = writer.IsolateSnapshotSize(); |
| 6697 *instructions_blob_size = instructions_writer.InstructionsBlobSize(); | 6687 *instructions_blob_size = instructions_writer.InstructionsBlobSize(); |
| 6698 *rodata_blob_size = instructions_writer.RodataBlobSize(); | 6688 *rodata_blob_size = instructions_writer.RodataBlobSize(); |
| 6699 | 6689 |
| 6700 return Api::Success(); | 6690 return Api::Success(); |
| 6701 #endif | 6691 #endif |
| 6702 } | 6692 } |
| 6703 | 6693 |
| 6704 | 6694 |
| 6705 DART_EXPORT bool Dart_IsPrecompiledRuntime() { | 6695 DART_EXPORT bool Dart_IsPrecompiledRuntime() { |
| 6706 #if defined(DART_PRECOMPILED_RUNTIME) | 6696 #if defined(DART_PRECOMPILED_RUNTIME) |
| 6707 return true; | 6697 return true; |
| 6708 #else | 6698 #else |
| 6709 return false; | 6699 return false; |
| 6710 #endif | 6700 #endif |
| 6711 } | 6701 } |
| 6712 | 6702 |
| 6713 | 6703 |
| 6714 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { | 6704 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { |
| 6715 #ifndef PRODUCT | 6705 #ifndef PRODUCT |
| 6716 Profiler::DumpStackTrace(context); | 6706 Profiler::DumpStackTrace(context); |
| 6717 #endif | 6707 #endif |
| 6718 } | 6708 } |
| 6719 | 6709 |
| 6720 } // namespace dart | 6710 } // namespace dart |
| OLD | NEW |