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

Side by Side Diff: src/isolate.cc

Issue 796623003: Support multiple interrupt requests in v8 API. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 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
« no previous file with comments | « src/isolate.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include <fstream> // NOLINT(readability/streams) 7 #include <fstream> // NOLINT(readability/streams)
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "src/v8.h" 10 #include "src/v8.h"
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 clear_pending_exception(); 910 clear_pending_exception();
911 } 911 }
912 if (has_scheduled_exception() && 912 if (has_scheduled_exception() &&
913 scheduled_exception() == heap_.termination_exception()) { 913 scheduled_exception() == heap_.termination_exception()) {
914 thread_local_top()->external_caught_exception_ = false; 914 thread_local_top()->external_caught_exception_ = false;
915 clear_scheduled_exception(); 915 clear_scheduled_exception();
916 } 916 }
917 } 917 }
918 918
919 919
920 void Isolate::InvokeApiInterruptCallback() { 920 void Isolate::RequestInterrupt(InterruptCallback callback, void* data) {
921 ExecutionAccess access(this);
922 api_interrupts_queue_.push(InterruptEntry(callback, data));
923 stack_guard()->RequestApiInterrupt();
924 }
925
926
927 void Isolate::InvokeApiInterruptCallbacks() {
921 // Note: callback below should be called outside of execution access lock. 928 // Note: callback below should be called outside of execution access lock.
922 InterruptCallback callback = NULL; 929 while (true) {
923 void* data = NULL; 930 InterruptEntry entry;
924 { 931 {
925 ExecutionAccess access(this); 932 ExecutionAccess access(this);
926 callback = api_interrupt_callback_; 933 if (api_interrupts_queue_.empty()) return;
927 data = api_interrupt_callback_data_; 934 entry = api_interrupts_queue_.front();
928 api_interrupt_callback_ = NULL; 935 api_interrupts_queue_.pop();
929 api_interrupt_callback_data_ = NULL; 936 }
930 }
931
932 if (callback != NULL) {
933 VMState<EXTERNAL> state(this); 937 VMState<EXTERNAL> state(this);
934 HandleScope handle_scope(this); 938 HandleScope handle_scope(this);
935 callback(reinterpret_cast<v8::Isolate*>(this), data); 939 entry.first(reinterpret_cast<v8::Isolate*>(this), entry.second);
936 } 940 }
937 } 941 }
938 942
939 943
940 Object* Isolate::Throw(Object* exception, MessageLocation* location) { 944 Object* Isolate::Throw(Object* exception, MessageLocation* location) {
941 DoThrow(exception, location); 945 DoThrow(exception, location);
942 return heap()->exception(); 946 return heap()->exception();
943 } 947 }
944 948
945 949
(...skipping 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after
2551 if (prev_ && prev_->Intercept(flag)) return true; 2555 if (prev_ && prev_->Intercept(flag)) return true;
2552 // Then check whether this scope intercepts. 2556 // Then check whether this scope intercepts.
2553 if ((flag & intercept_mask_)) { 2557 if ((flag & intercept_mask_)) {
2554 intercepted_flags_ |= flag; 2558 intercepted_flags_ |= flag;
2555 return true; 2559 return true;
2556 } 2560 }
2557 return false; 2561 return false;
2558 } 2562 }
2559 2563
2560 } } // namespace v8::internal 2564 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/isolate.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698