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

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

Issue 125103004: Move service into VM (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
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/bigint_operations.h" 10 #include "vm/bigint_operations.h"
11 #include "vm/class_finalizer.h" 11 #include "vm/class_finalizer.h"
12 #include "vm/compiler.h" 12 #include "vm/compiler.h"
13 #include "vm/dart.h" 13 #include "vm/dart.h"
14 #include "vm/dart_api_impl.h" 14 #include "vm/dart_api_impl.h"
15 #include "vm/dart_api_message.h" 15 #include "vm/dart_api_message.h"
16 #include "vm/dart_api_state.h" 16 #include "vm/dart_api_state.h"
17 #include "vm/dart_entry.h" 17 #include "vm/dart_entry.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/message.h" 22 #include "vm/message.h"
23 #include "vm/message_handler.h" 23 #include "vm/message_handler.h"
24 #include "vm/native_entry.h" 24 #include "vm/native_entry.h"
25 #include "vm/object.h" 25 #include "vm/object.h"
26 #include "vm/object_store.h" 26 #include "vm/object_store.h"
27 #include "vm/port.h" 27 #include "vm/port.h"
28 #include "vm/resolver.h" 28 #include "vm/resolver.h"
29 #include "vm/reusable_handles.h" 29 #include "vm/reusable_handles.h"
30 #include "vm/service.h"
30 #include "vm/stack_frame.h" 31 #include "vm/stack_frame.h"
31 #include "vm/symbols.h" 32 #include "vm/symbols.h"
32 #include "vm/timer.h" 33 #include "vm/timer.h"
33 #include "vm/unicode.h" 34 #include "vm/unicode.h"
34 #include "vm/verifier.h" 35 #include "vm/verifier.h"
35 #include "vm/version.h" 36 #include "vm/version.h"
36 37
37 namespace dart { 38 namespace dart {
38 39
39 DECLARE_FLAG(bool, print_class_table); 40 DECLARE_FLAG(bool, print_class_table);
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 787
787 DART_EXPORT bool Dart_Initialize( 788 DART_EXPORT bool Dart_Initialize(
788 Dart_IsolateCreateCallback create, 789 Dart_IsolateCreateCallback create,
789 Dart_IsolateInterruptCallback interrupt, 790 Dart_IsolateInterruptCallback interrupt,
790 Dart_IsolateUnhandledExceptionCallback unhandled, 791 Dart_IsolateUnhandledExceptionCallback unhandled,
791 Dart_IsolateShutdownCallback shutdown, 792 Dart_IsolateShutdownCallback shutdown,
792 Dart_FileOpenCallback file_open, 793 Dart_FileOpenCallback file_open,
793 Dart_FileReadCallback file_read, 794 Dart_FileReadCallback file_read,
794 Dart_FileWriteCallback file_write, 795 Dart_FileWriteCallback file_write,
795 Dart_FileCloseCallback file_close, 796 Dart_FileCloseCallback file_close,
796 Dart_EntropySource entropy_source) { 797 Dart_EntropySource entropy_source,
798 Dart_ServiceIsolateCreateCallback service_create) {
797 const char* err_msg = Dart::InitOnce(create, interrupt, unhandled, shutdown, 799 const char* err_msg = Dart::InitOnce(create, interrupt, unhandled, shutdown,
798 file_open, file_read, file_write, 800 file_open, file_read, file_write,
799 file_close, entropy_source); 801 file_close, entropy_source,
802 service_create);
800 if (err_msg != NULL) { 803 if (err_msg != NULL) {
801 OS::PrintErr("Dart_Initialize: %s\n", err_msg); 804 OS::PrintErr("Dart_Initialize: %s\n", err_msg);
802 return false; 805 return false;
803 } 806 }
804 return true; 807 return true;
805 } 808 }
806 809
807 810
808 DART_EXPORT bool Dart_Cleanup() { 811 DART_EXPORT bool Dart_Cleanup() {
809 CHECK_NO_ISOLATE(Isolate::Current()); 812 CHECK_NO_ISOLATE(Isolate::Current());
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 } 1165 }
1163 1166
1164 1167
1165 DART_EXPORT Dart_Port Dart_GetMainPortId() { 1168 DART_EXPORT Dart_Port Dart_GetMainPortId() {
1166 Isolate* isolate = Isolate::Current(); 1169 Isolate* isolate = Isolate::Current();
1167 CHECK_ISOLATE(isolate); 1170 CHECK_ISOLATE(isolate);
1168 return isolate->main_port(); 1171 return isolate->main_port();
1169 } 1172 }
1170 1173
1171 1174
1175 DART_EXPORT bool Dart_IsSendPort(Dart_Handle send_port) {
1176 Isolate* isolate = Isolate::Current();
1177 DARTSCOPE(isolate);
1178 Instance& port = Instance::Handle();
1179 port ^= Api::UnwrapHandle(send_port);
1180 return DartLibraryCalls::IsSendPort(port);
1181 }
1182
1183
1184 DART_EXPORT bool Dart_SendPortSend(Dart_Handle send_port, Dart_Handle object) {
siva 2014/01/10 00:01:54 Dart_Handle Dart_PostMessage(....) This function
1185 Isolate* isolate = Isolate::Current();
1186 DARTSCOPE(isolate);
1187 Instance& port_instance = Instance::Handle();
1188 port_instance ^= Api::UnwrapHandle(send_port);
1189 const Object& idObj = Object::Handle(
1190 DartLibraryCalls::PortGetId(port_instance));
1191 if (idObj.IsError()) {
1192 // Not a valid port.
1193 return false;
1194 }
1195 Integer& id = Integer::Handle();
1196 id ^= idObj.raw();
1197 Dart_Port port = static_cast<Dart_Port>(id.AsInt64Value());
1198 return Dart_Post(port, object);
1199 }
1200
1201
1172 // --- Scopes ---- 1202 // --- Scopes ----
1173 1203
1174 DART_EXPORT void Dart_EnterScope() { 1204 DART_EXPORT void Dart_EnterScope() {
1175 Isolate* isolate = Isolate::Current(); 1205 Isolate* isolate = Isolate::Current();
1176 CHECK_ISOLATE(isolate); 1206 CHECK_ISOLATE(isolate);
1177 ApiState* state = isolate->api_state(); 1207 ApiState* state = isolate->api_state();
1178 ASSERT(state != NULL); 1208 ASSERT(state != NULL);
1179 ApiLocalScope* new_scope = state->reusable_scope(); 1209 ApiLocalScope* new_scope = state->reusable_scope();
1180 if (new_scope == NULL) { 1210 if (new_scope == NULL) {
1181 new_scope = new ApiLocalScope(state->top_scope(), 1211 new_scope = new ApiLocalScope(state->top_scope(),
(...skipping 3306 matching lines...) Expand 10 before | Expand all | Expand 10 after
4488 return Api::NewError(msg, CURRENT_FUNC); 4518 return Api::NewError(msg, CURRENT_FUNC);
4489 } 4519 }
4490 { 4520 {
4491 NoGCScope no_gc; 4521 NoGCScope no_gc;
4492 RawObject* raw_obj = obj.raw(); 4522 RawObject* raw_obj = obj.raw();
4493 isolate->heap()->SetPeer(raw_obj, peer); 4523 isolate->heap()->SetPeer(raw_obj, peer);
4494 } 4524 }
4495 return Api::Success(); 4525 return Api::Success();
4496 } 4526 }
4497 4527
4528
4529 // --- Service support ---
4530
4531 DART_EXPORT Dart_Isolate Dart_GetServiceIsolate(void* callback_data) {
4532 return Api::CastIsolate(Service::GetServiceIsolate(callback_data));
4533 }
4534
4535
4536 DART_EXPORT void Dart_RegisterWithService() {
4537 CHECK_ISOLATE(Isolate::Current());
4538 Service::SendIsolateStartupMessage();
4539 }
4540
4541
4542 DART_EXPORT void Dart_UnregisterFromService() {
4543 CHECK_ISOLATE(Isolate::Current());
4544 Service::SendIsolateShutdownMessage();
4545 }
4546
4498 } // namespace dart 4547 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698