| 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 1582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1593 #if defined(DEBUG) | 1593 #if defined(DEBUG) |
| 1594 I->heap()->CollectAllGarbage(); | 1594 I->heap()->CollectAllGarbage(); |
| 1595 CheckFunctionTypesVisitor check_canonical(T); | 1595 CheckFunctionTypesVisitor check_canonical(T); |
| 1596 I->heap()->IterateObjects(&check_canonical); | 1596 I->heap()->IterateObjects(&check_canonical); |
| 1597 #endif // #if defined(DEBUG) | 1597 #endif // #if defined(DEBUG) |
| 1598 | 1598 |
| 1599 Symbols::Compact(I); | 1599 Symbols::Compact(I); |
| 1600 | 1600 |
| 1601 FullSnapshotWriter writer(Snapshot::kCore, vm_snapshot_data_buffer, | 1601 FullSnapshotWriter writer(Snapshot::kCore, vm_snapshot_data_buffer, |
| 1602 isolate_snapshot_data_buffer, ApiReallocate, | 1602 isolate_snapshot_data_buffer, ApiReallocate, |
| 1603 NULL /* vm_instructions_writer */, | 1603 NULL /* vm_image_writer */, |
| 1604 NULL /* isolate_instructions_writer */); | 1604 NULL /* isolate_image_writer */); |
| 1605 writer.WriteFullSnapshot(); | 1605 writer.WriteFullSnapshot(); |
| 1606 if (vm_snapshot_data_buffer != NULL) { | 1606 if (vm_snapshot_data_buffer != NULL) { |
| 1607 *vm_snapshot_data_size = writer.VmIsolateSnapshotSize(); | 1607 *vm_snapshot_data_size = writer.VmIsolateSnapshotSize(); |
| 1608 } | 1608 } |
| 1609 *isolate_snapshot_data_size = writer.IsolateSnapshotSize(); | 1609 *isolate_snapshot_data_size = writer.IsolateSnapshotSize(); |
| 1610 return Api::Success(); | 1610 return Api::Success(); |
| 1611 } | 1611 } |
| 1612 | 1612 |
| 1613 | 1613 |
| 1614 DART_EXPORT Dart_Handle | 1614 DART_EXPORT Dart_Handle |
| (...skipping 5036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6651 ASSERT(FLAG_load_deferred_eagerly); | 6651 ASSERT(FLAG_load_deferred_eagerly); |
| 6652 if (assembly_buffer == NULL) { | 6652 if (assembly_buffer == NULL) { |
| 6653 RETURN_NULL_ERROR(assembly_buffer); | 6653 RETURN_NULL_ERROR(assembly_buffer); |
| 6654 } | 6654 } |
| 6655 if (assembly_size == NULL) { | 6655 if (assembly_size == NULL) { |
| 6656 RETURN_NULL_ERROR(assembly_size); | 6656 RETURN_NULL_ERROR(assembly_size); |
| 6657 } | 6657 } |
| 6658 | 6658 |
| 6659 NOT_IN_PRODUCT(TimelineDurationScope tds2(T, Timeline::GetIsolateStream(), | 6659 NOT_IN_PRODUCT(TimelineDurationScope tds2(T, Timeline::GetIsolateStream(), |
| 6660 "WriteAppAOTSnapshot")); | 6660 "WriteAppAOTSnapshot")); |
| 6661 AssemblyInstructionsWriter instructions_writer(assembly_buffer, ApiReallocate, | 6661 AssemblyImageWriter image_writer(assembly_buffer, ApiReallocate, |
| 6662 2 * MB /* initial_size */); | 6662 2 * MB /* initial_size */); |
| 6663 uint8_t* vm_snapshot_data_buffer = NULL; | 6663 uint8_t* vm_snapshot_data_buffer = NULL; |
| 6664 uint8_t* isolate_snapshot_data_buffer = NULL; | 6664 uint8_t* isolate_snapshot_data_buffer = NULL; |
| 6665 FullSnapshotWriter writer(Snapshot::kAppAOT, &vm_snapshot_data_buffer, | 6665 FullSnapshotWriter writer(Snapshot::kAppAOT, &vm_snapshot_data_buffer, |
| 6666 &isolate_snapshot_data_buffer, ApiReallocate, | 6666 &isolate_snapshot_data_buffer, ApiReallocate, |
| 6667 &instructions_writer, &instructions_writer); | 6667 &image_writer, &image_writer); |
| 6668 | 6668 |
| 6669 writer.WriteFullSnapshot(); | 6669 writer.WriteFullSnapshot(); |
| 6670 *assembly_size = instructions_writer.AssemblySize(); | 6670 *assembly_size = image_writer.AssemblySize(); |
| 6671 | 6671 |
| 6672 return Api::Success(); | 6672 return Api::Success(); |
| 6673 #endif | 6673 #endif |
| 6674 } | 6674 } |
| 6675 | 6675 |
| 6676 | 6676 |
| 6677 DART_EXPORT Dart_Handle | 6677 DART_EXPORT Dart_Handle |
| 6678 Dart_CreateAppAOTSnapshotAsBlobs(uint8_t** vm_snapshot_data_buffer, | 6678 Dart_CreateAppAOTSnapshotAsBlobs(uint8_t** vm_snapshot_data_buffer, |
| 6679 intptr_t* vm_snapshot_data_size, | 6679 intptr_t* vm_snapshot_data_size, |
| 6680 uint8_t** vm_snapshot_instructions_buffer, | 6680 uint8_t** vm_snapshot_instructions_buffer, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6720 } | 6720 } |
| 6721 if (isolate_snapshot_instructions_buffer == NULL) { | 6721 if (isolate_snapshot_instructions_buffer == NULL) { |
| 6722 RETURN_NULL_ERROR(instructions_snapshot_blob_buffer); | 6722 RETURN_NULL_ERROR(instructions_snapshot_blob_buffer); |
| 6723 } | 6723 } |
| 6724 if (isolate_snapshot_instructions_buffer == NULL) { | 6724 if (isolate_snapshot_instructions_buffer == NULL) { |
| 6725 RETURN_NULL_ERROR(instructions_snapshot_blob_size); | 6725 RETURN_NULL_ERROR(instructions_snapshot_blob_size); |
| 6726 } | 6726 } |
| 6727 | 6727 |
| 6728 NOT_IN_PRODUCT(TimelineDurationScope tds2(T, Timeline::GetIsolateStream(), | 6728 NOT_IN_PRODUCT(TimelineDurationScope tds2(T, Timeline::GetIsolateStream(), |
| 6729 "WriteAppAOTSnapshot")); | 6729 "WriteAppAOTSnapshot")); |
| 6730 BlobInstructionsWriter vm_instructions_writer(vm_snapshot_instructions_buffer, | 6730 BlobImageWriter vm_image_writer(vm_snapshot_instructions_buffer, |
| 6731 ApiReallocate, | 6731 ApiReallocate, 2 * MB /* initial_size */); |
| 6732 2 * MB /* initial_size */); | 6732 BlobImageWriter isolate_image_writer(isolate_snapshot_instructions_buffer, |
| 6733 BlobInstructionsWriter isolate_instructions_writer( | 6733 ApiReallocate, |
| 6734 isolate_snapshot_instructions_buffer, ApiReallocate, | 6734 2 * MB /* initial_size */); |
| 6735 2 * MB /* initial_size */); | 6735 FullSnapshotWriter writer(Snapshot::kAppAOT, vm_snapshot_data_buffer, |
| 6736 FullSnapshotWriter writer( | 6736 isolate_snapshot_data_buffer, ApiReallocate, |
| 6737 Snapshot::kAppAOT, vm_snapshot_data_buffer, isolate_snapshot_data_buffer, | 6737 &vm_image_writer, &isolate_image_writer); |
| 6738 ApiReallocate, &vm_instructions_writer, &isolate_instructions_writer); | |
| 6739 | 6738 |
| 6740 writer.WriteFullSnapshot(); | 6739 writer.WriteFullSnapshot(); |
| 6741 *vm_snapshot_data_size = writer.VmIsolateSnapshotSize(); | 6740 *vm_snapshot_data_size = writer.VmIsolateSnapshotSize(); |
| 6742 *vm_snapshot_instructions_size = | 6741 *vm_snapshot_instructions_size = vm_image_writer.InstructionsBlobSize(); |
| 6743 vm_instructions_writer.InstructionsBlobSize(); | |
| 6744 *isolate_snapshot_data_size = writer.IsolateSnapshotSize(); | 6742 *isolate_snapshot_data_size = writer.IsolateSnapshotSize(); |
| 6745 *isolate_snapshot_instructions_size = | 6743 *isolate_snapshot_instructions_size = |
| 6746 isolate_instructions_writer.InstructionsBlobSize(); | 6744 isolate_image_writer.InstructionsBlobSize(); |
| 6747 | 6745 |
| 6748 return Api::Success(); | 6746 return Api::Success(); |
| 6749 #endif | 6747 #endif |
| 6750 } | 6748 } |
| 6751 | 6749 |
| 6752 | 6750 |
| 6753 DART_EXPORT Dart_Handle | 6751 DART_EXPORT Dart_Handle |
| 6754 Dart_CreateAppJITSnapshotAsBlobs(uint8_t** isolate_snapshot_data_buffer, | 6752 Dart_CreateAppJITSnapshotAsBlobs(uint8_t** isolate_snapshot_data_buffer, |
| 6755 intptr_t* isolate_snapshot_data_size, | 6753 intptr_t* isolate_snapshot_data_size, |
| 6756 uint8_t** isolate_snapshot_instructions_buffer, | 6754 uint8_t** isolate_snapshot_instructions_buffer, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 6785 Dart_Handle state = Api::CheckAndFinalizePendingClasses(T); | 6783 Dart_Handle state = Api::CheckAndFinalizePendingClasses(T); |
| 6786 if (::Dart_IsError(state)) { | 6784 if (::Dart_IsError(state)) { |
| 6787 return state; | 6785 return state; |
| 6788 } | 6786 } |
| 6789 I->StopBackgroundCompiler(); | 6787 I->StopBackgroundCompiler(); |
| 6790 | 6788 |
| 6791 Symbols::Compact(I); | 6789 Symbols::Compact(I); |
| 6792 | 6790 |
| 6793 NOT_IN_PRODUCT(TimelineDurationScope tds2(T, Timeline::GetIsolateStream(), | 6791 NOT_IN_PRODUCT(TimelineDurationScope tds2(T, Timeline::GetIsolateStream(), |
| 6794 "WriteAppJITSnapshot")); | 6792 "WriteAppJITSnapshot")); |
| 6795 BlobInstructionsWriter isolate_instructions_writer( | 6793 BlobImageWriter isolate_image_writer(isolate_snapshot_instructions_buffer, |
| 6796 isolate_snapshot_instructions_buffer, ApiReallocate, | 6794 ApiReallocate, |
| 6797 2 * MB /* initial_size */); | 6795 2 * MB /* initial_size */); |
| 6798 FullSnapshotWriter writer(Snapshot::kAppJIT, NULL, | 6796 FullSnapshotWriter writer(Snapshot::kAppJIT, NULL, |
| 6799 isolate_snapshot_data_buffer, ApiReallocate, NULL, | 6797 isolate_snapshot_data_buffer, ApiReallocate, NULL, |
| 6800 &isolate_instructions_writer); | 6798 &isolate_image_writer); |
| 6801 writer.WriteFullSnapshot(); | 6799 writer.WriteFullSnapshot(); |
| 6802 | 6800 |
| 6803 *isolate_snapshot_data_size = writer.IsolateSnapshotSize(); | 6801 *isolate_snapshot_data_size = writer.IsolateSnapshotSize(); |
| 6804 *isolate_snapshot_instructions_size = | 6802 *isolate_snapshot_instructions_size = |
| 6805 isolate_instructions_writer.InstructionsBlobSize(); | 6803 isolate_image_writer.InstructionsBlobSize(); |
| 6806 | 6804 |
| 6807 return Api::Success(); | 6805 return Api::Success(); |
| 6808 #endif | 6806 #endif |
| 6809 } | 6807 } |
| 6810 | 6808 |
| 6811 | 6809 |
| 6812 DART_EXPORT bool Dart_IsPrecompiledRuntime() { | 6810 DART_EXPORT bool Dart_IsPrecompiledRuntime() { |
| 6813 #if defined(DART_PRECOMPILED_RUNTIME) | 6811 #if defined(DART_PRECOMPILED_RUNTIME) |
| 6814 return true; | 6812 return true; |
| 6815 #else | 6813 #else |
| 6816 return false; | 6814 return false; |
| 6817 #endif | 6815 #endif |
| 6818 } | 6816 } |
| 6819 | 6817 |
| 6820 | 6818 |
| 6821 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { | 6819 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { |
| 6822 #ifndef PRODUCT | 6820 #ifndef PRODUCT |
| 6823 Profiler::DumpStackTrace(context); | 6821 Profiler::DumpStackTrace(context); |
| 6824 #endif | 6822 #endif |
| 6825 } | 6823 } |
| 6826 | 6824 |
| 6827 } // namespace dart | 6825 } // namespace dart |
| OLD | NEW |