Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: runtime/vm/dart_api_impl.cc

Issue 1318803002: Toward precompiled snapshots. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/dart.cc ('k') | runtime/vm/dart_entry.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
11 #include "vm/compiler.h" 11 #include "vm/compiler.h"
12 #include "vm/dart.h" 12 #include "vm/dart.h"
13 #include "vm/dart_api_impl.h" 13 #include "vm/dart_api_impl.h"
14 #include "vm/dart_api_message.h" 14 #include "vm/dart_api_message.h"
15 #include "vm/dart_api_state.h" 15 #include "vm/dart_api_state.h"
16 #include "vm/dart_entry.h" 16 #include "vm/dart_entry.h"
17 #include "vm/debugger.h" 17 #include "vm/debugger.h"
18 #include "vm/debuginfo.h" 18 #include "vm/debuginfo.h"
19 #include "vm/exceptions.h" 19 #include "vm/exceptions.h"
20 #include "vm/flags.h" 20 #include "vm/flags.h"
21 #include "vm/growable_array.h" 21 #include "vm/growable_array.h"
22 #include "vm/lockers.h" 22 #include "vm/lockers.h"
23 #include "vm/message.h" 23 #include "vm/message.h"
24 #include "vm/message_handler.h" 24 #include "vm/message_handler.h"
25 #include "vm/native_entry.h" 25 #include "vm/native_entry.h"
26 #include "vm/object.h" 26 #include "vm/object.h"
27 #include "vm/object_store.h" 27 #include "vm/object_store.h"
28 #include "vm/os_thread.h" 28 #include "vm/os_thread.h"
29 #include "vm/port.h" 29 #include "vm/port.h"
30 #include "vm/precompiler.h"
30 #include "vm/profiler.h" 31 #include "vm/profiler.h"
31 #include "vm/resolver.h" 32 #include "vm/resolver.h"
32 #include "vm/reusable_handles.h" 33 #include "vm/reusable_handles.h"
33 #include "vm/service_event.h" 34 #include "vm/service_event.h"
34 #include "vm/service_isolate.h" 35 #include "vm/service_isolate.h"
35 #include "vm/service.h" 36 #include "vm/service.h"
36 #include "vm/stack_frame.h" 37 #include "vm/stack_frame.h"
37 #include "vm/symbols.h" 38 #include "vm/symbols.h"
38 #include "vm/tags.h" 39 #include "vm/tags.h"
39 #include "vm/thread_registry.h" 40 #include "vm/thread_registry.h"
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 I->heap()->CollectAllGarbage(); 1522 I->heap()->CollectAllGarbage();
1522 #if defined(DEBUG) 1523 #if defined(DEBUG)
1523 FunctionVisitor check_canonical(I); 1524 FunctionVisitor check_canonical(I);
1524 I->heap()->IterateObjects(&check_canonical); 1525 I->heap()->IterateObjects(&check_canonical);
1525 #endif // #if defined(DEBUG). 1526 #endif // #if defined(DEBUG).
1526 1527
1527 // Since this is only a snapshot the root library should not be set. 1528 // Since this is only a snapshot the root library should not be set.
1528 I->object_store()->set_root_library(Library::Handle(Z)); 1529 I->object_store()->set_root_library(Library::Handle(Z));
1529 FullSnapshotWriter writer(vm_isolate_snapshot_buffer, 1530 FullSnapshotWriter writer(vm_isolate_snapshot_buffer,
1530 isolate_snapshot_buffer, 1531 isolate_snapshot_buffer,
1532 NULL, /* instructions_snapshot_buffer */
1531 ApiReallocate, 1533 ApiReallocate,
1532 false /* snapshot_code */); 1534 false, /* snapshot_code */
1535 true /* vm_isolate_is_symbolic */);
1533 writer.WriteFullSnapshot(); 1536 writer.WriteFullSnapshot();
1534 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); 1537 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize();
1535 *isolate_snapshot_size = writer.IsolateSnapshotSize(); 1538 *isolate_snapshot_size = writer.IsolateSnapshotSize();
1536 return Api::Success(); 1539 return Api::Success();
1537 } 1540 }
1538 1541
1539 1542
1540 static Dart_Handle createLibrarySnapshot(Dart_Handle library, 1543 static Dart_Handle createLibrarySnapshot(Dart_Handle library,
1541 uint8_t** buffer, 1544 uint8_t** buffer,
1542 intptr_t* size) { 1545 intptr_t* size) {
(...skipping 4317 matching lines...) Expand 10 before | Expand all | Expand 10 after
5860 TimelineStream* stream = isolate->GetEmbedderStream(); 5863 TimelineStream* stream = isolate->GetEmbedderStream();
5861 ASSERT(stream != NULL); 5864 ASSERT(stream != NULL);
5862 TimelineEvent* event = stream->StartEvent(); 5865 TimelineEvent* event = stream->StartEvent();
5863 if (event != NULL) { 5866 if (event != NULL) {
5864 event->AsyncEnd(label, async_id); 5867 event->AsyncEnd(label, async_id);
5865 event->Complete(); 5868 event->Complete();
5866 } 5869 }
5867 return Api::Success(); 5870 return Api::Success();
5868 } 5871 }
5869 5872
5873
5874 static void Precompile(Isolate* isolate, Dart_Handle* result) {
5875 ASSERT(isolate != NULL);
5876 const Error& error = Error::Handle(isolate, Precompiler::CompileAll());
5877 if (error.IsNull()) {
5878 *result = Api::Success();
5879 } else {
5880 *result = Api::NewHandle(isolate, error.raw());
5881 }
5882 }
5883
5884
5885 DART_EXPORT Dart_Handle Dart_Precompile() {
5886 DARTSCOPE(Thread::Current());
5887 Dart_Handle result = Api::CheckAndFinalizePendingClasses(I);
5888 if (::Dart_IsError(result)) {
5889 return result;
5890 }
5891 CHECK_CALLBACK_STATE(I);
5892 Precompile(I, &result);
5893 return result;
5894 }
5895
5896
5897 DART_EXPORT Dart_Handle Dart_CreatePrecompiledSnapshot(
5898 uint8_t** vm_isolate_snapshot_buffer,
5899 intptr_t* vm_isolate_snapshot_size,
5900 uint8_t** isolate_snapshot_buffer,
5901 intptr_t* isolate_snapshot_size,
5902 uint8_t** instructions_snapshot_buffer,
5903 intptr_t* instructions_snapshot_size) {
5904 ASSERT(FLAG_load_deferred_eagerly);
5905 DARTSCOPE(Thread::Current());
5906 if (vm_isolate_snapshot_buffer == NULL) {
5907 RETURN_NULL_ERROR(vm_isolate_snapshot_buffer);
5908 }
5909 if (vm_isolate_snapshot_size == NULL) {
5910 RETURN_NULL_ERROR(vm_isolate_snapshot_size);
5911 }
5912 if (isolate_snapshot_buffer == NULL) {
5913 RETURN_NULL_ERROR(isolate_snapshot_buffer);
5914 }
5915 if (isolate_snapshot_size == NULL) {
5916 RETURN_NULL_ERROR(isolate_snapshot_size);
5917 }
5918 if (instructions_snapshot_buffer == NULL) {
5919 RETURN_NULL_ERROR(instructions_snapshot_buffer);
5920 }
5921 if (instructions_snapshot_size == NULL) {
5922 RETURN_NULL_ERROR(instructions_snapshot_size);
5923 }
5924 // Finalize all classes if needed.
5925 Dart_Handle state = Api::CheckAndFinalizePendingClasses(I);
5926 if (::Dart_IsError(state)) {
5927 return state;
5928 }
5929 I->heap()->CollectAllGarbage();
5930 PrecompiledSnapshotWriter writer(vm_isolate_snapshot_buffer,
5931 isolate_snapshot_buffer,
5932 instructions_snapshot_buffer,
5933 ApiReallocate);
5934 writer.WriteFullSnapshot();
5935 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize();
5936 *isolate_snapshot_size = writer.IsolateSnapshotSize();
5937 *instructions_snapshot_size = writer.InstructionsSnapshotSize();
5938
5939 return Api::Success();
5940 }
5941
5870 } // namespace dart 5942 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart.cc ('k') | runtime/vm/dart_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698