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_native_api.h" | 5 #include "include/dart_native_api.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
9 #include "vm/dart_api_message.h" | 9 #include "vm/dart_api_message.h" |
10 #include "vm/dart_api_state.h" | 10 #include "vm/dart_api_state.h" |
11 #include "vm/message.h" | 11 #include "vm/message.h" |
12 #include "vm/native_message_handler.h" | 12 #include "vm/native_message_handler.h" |
13 #include "vm/port.h" | 13 #include "vm/port.h" |
| 14 #include "vm/precompiler.h" |
14 | 15 |
15 namespace dart { | 16 namespace dart { |
16 | 17 |
17 // --- Message sending/receiving from native code --- | 18 // --- Message sending/receiving from native code --- |
18 | 19 |
19 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { | 20 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { |
20 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); | 21 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); |
21 return reinterpret_cast<uint8_t*>(new_ptr); | 22 return reinterpret_cast<uint8_t*>(new_ptr); |
22 } | 23 } |
23 | 24 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 static void CompileAll(Isolate* isolate, Dart_Handle* result) { | 73 static void CompileAll(Isolate* isolate, Dart_Handle* result) { |
73 ASSERT(isolate != NULL); | 74 ASSERT(isolate != NULL); |
74 const Error& error = Error::Handle(isolate, Library::CompileAll()); | 75 const Error& error = Error::Handle(isolate, Library::CompileAll()); |
75 if (error.IsNull()) { | 76 if (error.IsNull()) { |
76 *result = Api::Success(); | 77 *result = Api::Success(); |
77 } else { | 78 } else { |
78 *result = Api::NewHandle(isolate, error.raw()); | 79 *result = Api::NewHandle(isolate, error.raw()); |
79 } | 80 } |
80 } | 81 } |
81 | 82 |
| 83 static void Precompile(Isolate* isolate, Dart_Handle* result) { |
| 84 ASSERT(isolate != NULL); |
| 85 const Error& error = Error::Handle(isolate, Precompiler::CompileAll()); |
| 86 if (error.IsNull()) { |
| 87 *result = Api::Success(); |
| 88 } else { |
| 89 *result = Api::NewHandle(isolate, error.raw()); |
| 90 } |
| 91 } |
| 92 |
82 | 93 |
83 DART_EXPORT Dart_Handle Dart_CompileAll() { | 94 DART_EXPORT Dart_Handle Dart_CompileAll() { |
84 Isolate* isolate = Isolate::Current(); | 95 Isolate* isolate = Isolate::Current(); |
85 DARTSCOPE(isolate); | 96 DARTSCOPE(isolate); |
86 Dart_Handle result = Api::CheckAndFinalizePendingClasses(isolate); | 97 Dart_Handle result = Api::CheckAndFinalizePendingClasses(isolate); |
87 if (::Dart_IsError(result)) { | 98 if (::Dart_IsError(result)) { |
88 return result; | 99 return result; |
89 } | 100 } |
90 CHECK_CALLBACK_STATE(isolate); | 101 CHECK_CALLBACK_STATE(isolate); |
91 CompileAll(isolate, &result); | 102 CompileAll(isolate, &result); |
92 return result; | 103 return result; |
93 } | 104 } |
94 | 105 |
| 106 |
| 107 DART_EXPORT Dart_Handle Dart_Precompile() { |
| 108 Isolate* isolate = Isolate::Current(); |
| 109 DARTSCOPE(isolate); |
| 110 Dart_Handle result = Api::CheckAndFinalizePendingClasses(isolate); |
| 111 if (::Dart_IsError(result)) { |
| 112 return result; |
| 113 } |
| 114 CHECK_CALLBACK_STATE(isolate); |
| 115 Precompile(isolate, &result); |
| 116 return result; |
| 117 } |
| 118 |
95 } // namespace dart | 119 } // namespace dart |
OLD | NEW |