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" |
11 #include "vm/class_finalizer.h" | 11 #include "vm/class_finalizer.h" |
12 #include "vm/clustered_snapshot.h" | 12 #include "vm/clustered_snapshot.h" |
13 #include "vm/compiler.h" | 13 #include "vm/compiler.h" |
14 #include "vm/dart.h" | 14 #include "vm/dart.h" |
15 #include "vm/dart_api_impl.h" | 15 #include "vm/dart_api_impl.h" |
16 #include "vm/dart_api_message.h" | 16 #include "vm/dart_api_message.h" |
17 #include "vm/dart_api_state.h" | 17 #include "vm/dart_api_state.h" |
18 #include "vm/dart_entry.h" | 18 #include "vm/dart_entry.h" |
19 #include "vm/debugger.h" | 19 #include "vm/debugger.h" |
| 20 #include "vm/dil_reader.h" |
20 #include "vm/exceptions.h" | 21 #include "vm/exceptions.h" |
21 #include "vm/flags.h" | 22 #include "vm/flags.h" |
22 #include "vm/growable_array.h" | 23 #include "vm/growable_array.h" |
23 #include "vm/lockers.h" | 24 #include "vm/lockers.h" |
24 #include "vm/isolate_reload.h" | 25 #include "vm/isolate_reload.h" |
25 #include "vm/message.h" | 26 #include "vm/message.h" |
26 #include "vm/message_handler.h" | 27 #include "vm/message_handler.h" |
27 #include "vm/native_entry.h" | 28 #include "vm/native_entry.h" |
28 #include "vm/object.h" | 29 #include "vm/object.h" |
29 #include "vm/object_store.h" | 30 #include "vm/object_store.h" |
(...skipping 5355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5385 tds2.FormatArgument(1, "heapSize", "%" Pd64, | 5386 tds2.FormatArgument(1, "heapSize", "%" Pd64, |
5386 I->heap()->UsedInWords(Heap::kOld) * kWordSize); | 5387 I->heap()->UsedInWords(Heap::kOld) * kWordSize); |
5387 }); | 5388 }); |
5388 library ^= tmp.raw(); | 5389 library ^= tmp.raw(); |
5389 library.set_debuggable(true); | 5390 library.set_debuggable(true); |
5390 I->object_store()->set_root_library(library); | 5391 I->object_store()->set_root_library(library); |
5391 return Api::NewHandle(T, library.raw()); | 5392 return Api::NewHandle(T, library.raw()); |
5392 } | 5393 } |
5393 | 5394 |
5394 | 5395 |
| 5396 DART_EXPORT Dart_Handle Dart_LoadKernel(const uint8_t* buffer, |
| 5397 intptr_t buffer_len) { |
| 5398 API_TIMELINE_DURATION; |
| 5399 DARTSCOPE(Thread::Current()); |
| 5400 Isolate* I = T->isolate(); |
| 5401 StackZone zone(T); |
| 5402 |
| 5403 Library& library = Library::Handle(Z, I->object_store()->root_library()); |
| 5404 if (!library.IsNull()) { |
| 5405 const String& library_url = String::Handle(Z, library.url()); |
| 5406 return Api::NewError("%s: A script has already been loaded from '%s'.", |
| 5407 CURRENT_FUNC, library_url.ToCString()); |
| 5408 } |
| 5409 CHECK_CALLBACK_STATE(T); |
| 5410 CHECK_COMPILATION_ALLOWED(I); |
| 5411 |
| 5412 // TODO(kustermann): Memory leak! |
| 5413 dil::DilReader* reader = new dil::DilReader(buffer, buffer_len); |
| 5414 const Object& tmp = reader->ReadProgram(); |
| 5415 if (tmp.IsError()) { |
| 5416 return Api::NewHandle(T, tmp.raw()); |
| 5417 } |
| 5418 library ^= tmp.raw(); |
| 5419 library.set_debuggable(false); |
| 5420 I->object_store()->set_root_library(library); |
| 5421 return Api::NewHandle(T, library.raw()); |
| 5422 } |
| 5423 |
| 5424 |
5395 DART_EXPORT Dart_Handle Dart_RootLibrary() { | 5425 DART_EXPORT Dart_Handle Dart_RootLibrary() { |
5396 Thread* thread = Thread::Current(); | 5426 Thread* thread = Thread::Current(); |
5397 Isolate* isolate = thread->isolate(); | 5427 Isolate* isolate = thread->isolate(); |
5398 CHECK_ISOLATE(isolate); | 5428 CHECK_ISOLATE(isolate); |
5399 return Api::NewHandle(thread, isolate->object_store()->root_library()); | 5429 return Api::NewHandle(thread, isolate->object_store()->root_library()); |
5400 } | 5430 } |
5401 | 5431 |
5402 | 5432 |
5403 DART_EXPORT Dart_Handle Dart_SetRootLibrary(Dart_Handle library) { | 5433 DART_EXPORT Dart_Handle Dart_SetRootLibrary(Dart_Handle library) { |
5404 DARTSCOPE(Thread::Current()); | 5434 DARTSCOPE(Thread::Current()); |
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6621 | 6651 |
6622 DART_EXPORT bool Dart_IsPrecompiledRuntime() { | 6652 DART_EXPORT bool Dart_IsPrecompiledRuntime() { |
6623 #if defined(DART_PRECOMPILED_RUNTIME) | 6653 #if defined(DART_PRECOMPILED_RUNTIME) |
6624 return true; | 6654 return true; |
6625 #else | 6655 #else |
6626 return false; | 6656 return false; |
6627 #endif | 6657 #endif |
6628 } | 6658 } |
6629 | 6659 |
6630 } // namespace dart | 6660 } // namespace dart |
OLD | NEW |