OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 | 6 |
7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 namespace dart { | 28 namespace dart { |
29 | 29 |
30 // TODO(iposva): This is a placeholder for the eventual external Dart API. | 30 // TODO(iposva): This is a placeholder for the eventual external Dart API. |
31 DART_EXPORT bool Dart_Initialize(int argc, | 31 DART_EXPORT bool Dart_Initialize(int argc, |
32 char** argv, | 32 char** argv, |
33 Dart_IsolateInitCallback callback) { | 33 Dart_IsolateInitCallback callback) { |
34 return Dart::InitOnce(argc, argv, callback); | 34 return Dart::InitOnce(argc, argv, callback); |
35 } | 35 } |
36 | 36 |
37 | 37 |
38 DART_EXPORT Dart_Isolate Dart_CreateIsolate(void* snapshot, void* data) { | 38 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const Dart_Snapshot* snapshot, |
| 39 void* data) { |
39 ASSERT(Isolate::Current() == NULL); | 40 ASSERT(Isolate::Current() == NULL); |
40 Isolate* isolate = Dart::CreateIsolate(snapshot, data); | 41 Isolate* isolate = Dart::CreateIsolate(snapshot, data); |
41 START_TIMER(time_total_runtime); | 42 START_TIMER(time_total_runtime); |
42 return reinterpret_cast<Dart_Isolate>(isolate); | 43 return reinterpret_cast<Dart_Isolate>(isolate); |
43 } | 44 } |
44 | 45 |
45 | 46 |
46 DART_EXPORT void Dart_ShutdownIsolate() { | 47 DART_EXPORT void Dart_ShutdownIsolate() { |
47 ASSERT(Isolate::Current() != NULL); | 48 ASSERT(Isolate::Current() != NULL); |
48 STOP_TIMER(time_total_runtime); | 49 STOP_TIMER(time_total_runtime); |
(...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1474 RETURN_CBOOLEAN(true); | 1475 RETURN_CBOOLEAN(true); |
1475 } | 1476 } |
1476 | 1477 |
1477 | 1478 |
1478 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { | 1479 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { |
1479 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); | 1480 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); |
1480 return reinterpret_cast<uint8_t*>(new_ptr); | 1481 return reinterpret_cast<uint8_t*>(new_ptr); |
1481 } | 1482 } |
1482 | 1483 |
1483 | 1484 |
1484 DART_EXPORT Dart_Result Dart_PostIntArray(Dart_Port port, intptr_t field_count, | 1485 DART_EXPORT Dart_Result Dart_PostIntArray(Dart_Port port, |
| 1486 int field_count, |
1485 intptr_t* data) { | 1487 intptr_t* data) { |
1486 uint8_t* buffer = NULL; | 1488 uint8_t* buffer = NULL; |
1487 MessageWriter writer(&buffer, &allocator); | 1489 MessageWriter writer(&buffer, &allocator); |
1488 | 1490 |
1489 writer.WriteMessage(field_count, data); | 1491 writer.WriteMessage(field_count, data); |
1490 | 1492 |
1491 // Post the message at the given port. The allocated message and | 1493 // Post the message at the given port. The allocated message and |
1492 // buffer are deallocated after the message is processed. | 1494 // buffer are deallocated after the message is processed. |
1493 PortMessage* portMessage = new PortMessage(port, 0, buffer); | 1495 PortMessage* portMessage = new PortMessage(port, 0, buffer); |
1494 bool result = PortMap::PostMessage(portMessage); | 1496 bool result = PortMap::PostMessage(portMessage); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1606 ASSERT(isolate != NULL); | 1608 ASSERT(isolate != NULL); |
1607 ApiState* state = isolate->api_state(); | 1609 ApiState* state = isolate->api_state(); |
1608 ASSERT(state != NULL); | 1610 ASSERT(state != NULL); |
1609 ApiLocalScope* scope = state->top_scope(); | 1611 ApiLocalScope* scope = state->top_scope(); |
1610 ASSERT(scope != NULL); | 1612 ASSERT(scope != NULL); |
1611 return scope->zone().Reallocate(ptr, old_size, new_size); | 1613 return scope->zone().Reallocate(ptr, old_size, new_size); |
1612 } | 1614 } |
1613 | 1615 |
1614 | 1616 |
1615 } // namespace dart | 1617 } // namespace dart |
OLD | NEW |