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 "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
(...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1193 } | 1193 } |
1194 | 1194 |
1195 | 1195 |
1196 // --- Initialization and Globals --- | 1196 // --- Initialization and Globals --- |
1197 | 1197 |
1198 DART_EXPORT const char* Dart_VersionString() { | 1198 DART_EXPORT const char* Dart_VersionString() { |
1199 return Version::String(); | 1199 return Version::String(); |
1200 } | 1200 } |
1201 | 1201 |
1202 DART_EXPORT bool Dart_Initialize( | 1202 DART_EXPORT bool Dart_Initialize( |
| 1203 const uint8_t* vm_isolate_snapshot, |
1203 Dart_IsolateCreateCallback create, | 1204 Dart_IsolateCreateCallback create, |
1204 Dart_IsolateInterruptCallback interrupt, | 1205 Dart_IsolateInterruptCallback interrupt, |
1205 Dart_IsolateUnhandledExceptionCallback unhandled, | 1206 Dart_IsolateUnhandledExceptionCallback unhandled, |
1206 Dart_IsolateShutdownCallback shutdown, | 1207 Dart_IsolateShutdownCallback shutdown, |
1207 Dart_FileOpenCallback file_open, | 1208 Dart_FileOpenCallback file_open, |
1208 Dart_FileReadCallback file_read, | 1209 Dart_FileReadCallback file_read, |
1209 Dart_FileWriteCallback file_write, | 1210 Dart_FileWriteCallback file_write, |
1210 Dart_FileCloseCallback file_close, | 1211 Dart_FileCloseCallback file_close, |
1211 Dart_EntropySource entropy_source) { | 1212 Dart_EntropySource entropy_source) { |
1212 const char* err_msg = Dart::InitOnce(create, interrupt, unhandled, shutdown, | 1213 const char* err_msg = Dart::InitOnce(vm_isolate_snapshot, |
| 1214 create, interrupt, unhandled, shutdown, |
1213 file_open, file_read, file_write, | 1215 file_open, file_read, file_write, |
1214 file_close, entropy_source); | 1216 file_close, entropy_source); |
1215 if (err_msg != NULL) { | 1217 if (err_msg != NULL) { |
1216 OS::PrintErr("Dart_Initialize: %s\n", err_msg); | 1218 OS::PrintErr("Dart_Initialize: %s\n", err_msg); |
1217 return false; | 1219 return false; |
1218 } | 1220 } |
1219 return true; | 1221 return true; |
1220 } | 1222 } |
1221 | 1223 |
1222 | 1224 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 | 1403 |
1402 | 1404 |
1403 static uint8_t* ApiReallocate(uint8_t* ptr, | 1405 static uint8_t* ApiReallocate(uint8_t* ptr, |
1404 intptr_t old_size, | 1406 intptr_t old_size, |
1405 intptr_t new_size) { | 1407 intptr_t new_size) { |
1406 return Api::TopScope(Isolate::Current())->zone()->Realloc<uint8_t>( | 1408 return Api::TopScope(Isolate::Current())->zone()->Realloc<uint8_t>( |
1407 ptr, old_size, new_size); | 1409 ptr, old_size, new_size); |
1408 } | 1410 } |
1409 | 1411 |
1410 | 1412 |
1411 DART_EXPORT Dart_Handle Dart_CreateSnapshot(uint8_t** buffer, | 1413 DART_EXPORT Dart_Handle Dart_CreateSnapshot( |
1412 intptr_t* size) { | 1414 uint8_t** vm_isolate_snapshot_buffer, |
| 1415 intptr_t* vm_isolate_snapshot_size, |
| 1416 uint8_t** isolate_snapshot_buffer, |
| 1417 intptr_t* isolate_snapshot_size) { |
1413 Isolate* isolate = Isolate::Current(); | 1418 Isolate* isolate = Isolate::Current(); |
1414 DARTSCOPE(isolate); | 1419 DARTSCOPE(isolate); |
1415 TIMERSCOPE(isolate, time_creating_snapshot); | 1420 TIMERSCOPE(isolate, time_creating_snapshot); |
1416 if (buffer == NULL) { | 1421 if (vm_isolate_snapshot_buffer == NULL) { |
1417 RETURN_NULL_ERROR(buffer); | 1422 RETURN_NULL_ERROR(vm_isolate_snapshot_buffer); |
1418 } | 1423 } |
1419 if (size == NULL) { | 1424 if (vm_isolate_snapshot_size == NULL) { |
1420 RETURN_NULL_ERROR(size); | 1425 RETURN_NULL_ERROR(vm_isolate_snapshot_size); |
| 1426 } |
| 1427 if (isolate_snapshot_buffer == NULL) { |
| 1428 RETURN_NULL_ERROR(isolate_snapshot_buffer); |
| 1429 } |
| 1430 if (isolate_snapshot_size == NULL) { |
| 1431 RETURN_NULL_ERROR(isolate_snapshot_size); |
1421 } | 1432 } |
1422 // Finalize all classes if needed. | 1433 // Finalize all classes if needed. |
1423 Dart_Handle state = Api::CheckAndFinalizePendingClasses(isolate); | 1434 Dart_Handle state = Api::CheckAndFinalizePendingClasses(isolate); |
1424 if (::Dart_IsError(state)) { | 1435 if (::Dart_IsError(state)) { |
1425 return state; | 1436 return state; |
1426 } | 1437 } |
1427 // Since this is only a snapshot the root library should not be set. | 1438 // Since this is only a snapshot the root library should not be set. |
1428 isolate->object_store()->set_root_library(Library::Handle(isolate)); | 1439 isolate->object_store()->set_root_library(Library::Handle(isolate)); |
1429 FullSnapshotWriter writer(buffer, ApiReallocate); | 1440 FullSnapshotWriter writer(vm_isolate_snapshot_buffer, |
| 1441 isolate_snapshot_buffer, |
| 1442 ApiReallocate); |
1430 writer.WriteFullSnapshot(); | 1443 writer.WriteFullSnapshot(); |
1431 *size = writer.BytesWritten(); | 1444 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); |
| 1445 *isolate_snapshot_size = writer.IsolateSnapshotSize(); |
1432 return Api::Success(); | 1446 return Api::Success(); |
1433 } | 1447 } |
1434 | 1448 |
1435 | 1449 |
1436 DART_EXPORT Dart_Handle Dart_CreateScriptSnapshot(uint8_t** buffer, | 1450 DART_EXPORT Dart_Handle Dart_CreateScriptSnapshot(uint8_t** buffer, |
1437 intptr_t* size) { | 1451 intptr_t* size) { |
1438 Isolate* isolate = Isolate::Current(); | 1452 Isolate* isolate = Isolate::Current(); |
1439 DARTSCOPE(isolate); | 1453 DARTSCOPE(isolate); |
1440 TIMERSCOPE(isolate, time_creating_snapshot); | 1454 TIMERSCOPE(isolate, time_creating_snapshot); |
1441 if (buffer == NULL) { | 1455 if (buffer == NULL) { |
(...skipping 4078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5520 | 5534 |
5521 | 5535 |
5522 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( | 5536 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( |
5523 const char* name, | 5537 const char* name, |
5524 Dart_ServiceRequestCallback callback, | 5538 Dart_ServiceRequestCallback callback, |
5525 void* user_data) { | 5539 void* user_data) { |
5526 Service::RegisterRootEmbedderCallback(name, callback, user_data); | 5540 Service::RegisterRootEmbedderCallback(name, callback, user_data); |
5527 } | 5541 } |
5528 | 5542 |
5529 } // namespace dart | 5543 } // namespace dart |
OLD | NEW |