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

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

Issue 8851008: Add support for interrupting an isolate in the vm. Interrupts are (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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) 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 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 521
522 DART_EXPORT Dart_Handle Dart_MakePersistentHandle(Dart_Handle object) { 522 DART_EXPORT Dart_Handle Dart_MakePersistentHandle(Dart_Handle object) {
523 UNIMPLEMENTED(); 523 UNIMPLEMENTED();
524 return NULL; 524 return NULL;
525 } 525 }
526 526
527 527
528 // --- Initialization and Globals --- 528 // --- Initialization and Globals ---
529 529
530 530
531 // TODO(iposva): This is a placeholder for the eventual external Dart API. 531 DART_EXPORT bool Dart_Initialize(Dart_IsolateCreateCallback create,
532 DART_EXPORT bool Dart_Initialize(Dart_IsolateCreateCallback callback) { 532 Dart_IsolateInterruptCallback interrupt) {
533 return Dart::InitOnce(callback); 533 return Dart::InitOnce(create, interrupt);
534 } 534 }
535 535
536 DART_EXPORT bool Dart_SetVMFlags(int argc, const char** argv) { 536 DART_EXPORT bool Dart_SetVMFlags(int argc, const char** argv) {
537 return Flags::ProcessCommandLineFlags(argc, argv); 537 return Flags::ProcessCommandLineFlags(argc, argv);
538 } 538 }
539 539
540 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name) { 540 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name) {
541 if (Flags::Lookup(flag_name) != NULL) { 541 if (Flags::Lookup(flag_name) != NULL) {
542 return true; 542 return true;
543 } 543 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 if (msg != NULL) { 656 if (msg != NULL) {
657 return Api::Error(msg); 657 return Api::Error(msg);
658 } 658 }
659 ScriptSnapshotWriter writer(root_lib, buffer, ApiAllocator); 659 ScriptSnapshotWriter writer(root_lib, buffer, ApiAllocator);
660 writer.WriteScriptSnapshot(); 660 writer.WriteScriptSnapshot();
661 *size = writer.Size(); 661 *size = writer.Size();
662 return Api::Success(); 662 return Api::Success();
663 } 663 }
664 664
665 665
666 DART_EXPORT void Dart_InterruptIsolate(Dart_Isolate isolate) {
667 if (isolate == NULL) {
668 FATAL1("%s expects argument 'isolate' to be non-null.", CURRENT_FUNC);
669 }
670 Isolate* iso = reinterpret_cast<Isolate*>(isolate);
671 iso->ScheduleInterrupts(Isolate::kApiInterrupt);
672 }
673
674
666 // --- Messages and Ports --- 675 // --- Messages and Ports ---
667 676
668 677
669 DART_EXPORT void Dart_SetMessageCallbacks( 678 DART_EXPORT void Dart_SetMessageCallbacks(
670 Dart_PostMessageCallback post_message_callback, 679 Dart_PostMessageCallback post_message_callback,
671 Dart_ClosePortCallback close_port_callback) { 680 Dart_ClosePortCallback close_port_callback) {
672 Isolate* isolate = Isolate::Current(); 681 Isolate* isolate = Isolate::Current();
673 CHECK_ISOLATE(isolate); 682 CHECK_ISOLATE(isolate);
674 ASSERT(post_message_callback != NULL); 683 ASSERT(post_message_callback != NULL);
675 ASSERT(close_port_callback != NULL); 684 ASSERT(close_port_callback != NULL);
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 DARTSCOPE(Isolate::Current()); 1191 DARTSCOPE(Isolate::Current());
1183 const String& str = Api::UnwrapStringHandle(object); 1192 const String& str = Api::UnwrapStringHandle(object);
1184 if (str.IsNull()) { 1193 if (str.IsNull()) {
1185 RETURN_TYPE_ERROR(object, String); 1194 RETURN_TYPE_ERROR(object, String);
1186 } 1195 }
1187 if (!str.IsExternal()) { 1196 if (!str.IsExternal()) {
1188 return Api::Error("%s expects argument 'object' to be an external String.", 1197 return Api::Error("%s expects argument 'object' to be an external String.",
1189 CURRENT_FUNC); 1198 CURRENT_FUNC);
1190 } 1199 }
1191 if (peer == NULL) { 1200 if (peer == NULL) {
1192 return Api::Error("%s expects argument 'peer' to be non-NULL.", 1201 return Api::Error("%s expects argument 'peer' to be non-null.",
1193 CURRENT_FUNC); 1202 CURRENT_FUNC);
1194 } 1203 }
1195 *peer = str.GetPeer(); 1204 *peer = str.GetPeer();
1196 return Api::Success(); 1205 return Api::Success();
1197 } 1206 }
1198 1207
1199 1208
1200 DART_EXPORT Dart_Handle Dart_NewExternalString8(const uint8_t* codepoints, 1209 DART_EXPORT Dart_Handle Dart_NewExternalString8(const uint8_t* codepoints,
1201 intptr_t length, 1210 intptr_t length,
1202 void* peer, 1211 void* peer,
(...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after
2470 } 2479 }
2471 delete debug_region; 2480 delete debug_region;
2472 } else { 2481 } else {
2473 *buffer = NULL; 2482 *buffer = NULL;
2474 *buffer_size = 0; 2483 *buffer_size = 0;
2475 } 2484 }
2476 } 2485 }
2477 2486
2478 2487
2479 } // namespace dart 2488 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698