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

Side by Side Diff: src/isolate.cc

Issue 2575313002: [promisehook] Implement PromiseHook (Closed)
Patch Set: rebase + add comments Created 4 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') | src/js/async-await.js » ('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 "src/isolate.h" 5 #include "src/isolate.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include <fstream> // NOLINT(readability/streams) 9 #include <fstream> // NOLINT(readability/streams)
10 #include <sstream> 10 #include <sstream>
(...skipping 2130 matching lines...) Expand 10 before | Expand all | Expand 10 after
2141 global_handles_(NULL), 2141 global_handles_(NULL),
2142 eternal_handles_(NULL), 2142 eternal_handles_(NULL),
2143 thread_manager_(NULL), 2143 thread_manager_(NULL),
2144 regexp_stack_(NULL), 2144 regexp_stack_(NULL),
2145 date_cache_(NULL), 2145 date_cache_(NULL),
2146 call_descriptor_data_(NULL), 2146 call_descriptor_data_(NULL),
2147 // TODO(bmeurer) Initialized lazily because it depends on flags; can 2147 // TODO(bmeurer) Initialized lazily because it depends on flags; can
2148 // be fixed once the default isolate cleanup is done. 2148 // be fixed once the default isolate cleanup is done.
2149 random_number_generator_(NULL), 2149 random_number_generator_(NULL),
2150 rail_mode_(PERFORMANCE_ANIMATION), 2150 rail_mode_(PERFORMANCE_ANIMATION),
2151 promise_hook_(NULL),
2151 load_start_time_ms_(0), 2152 load_start_time_ms_(0),
2152 serializer_enabled_(enable_serializer), 2153 serializer_enabled_(enable_serializer),
2153 has_fatal_error_(false), 2154 has_fatal_error_(false),
2154 initialized_from_snapshot_(false), 2155 initialized_from_snapshot_(false),
2155 is_promisehook_enabled_(false),
2156 is_tail_call_elimination_enabled_(true), 2156 is_tail_call_elimination_enabled_(true),
2157 is_isolate_in_background_(false), 2157 is_isolate_in_background_(false),
2158 cpu_profiler_(NULL), 2158 cpu_profiler_(NULL),
2159 heap_profiler_(NULL), 2159 heap_profiler_(NULL),
2160 code_event_dispatcher_(new CodeEventDispatcher()), 2160 code_event_dispatcher_(new CodeEventDispatcher()),
2161 function_entry_hook_(NULL), 2161 function_entry_hook_(NULL),
2162 deferred_handles_head_(NULL), 2162 deferred_handles_head_(NULL),
2163 optimizing_compile_dispatcher_(NULL), 2163 optimizing_compile_dispatcher_(NULL),
2164 stress_deopt_count_(0), 2164 stress_deopt_count_(0),
2165 next_optimization_id_(0), 2165 next_optimization_id_(0),
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after
3163 3163
3164 if (call_completed_callbacks_.is_empty()) return; 3164 if (call_completed_callbacks_.is_empty()) return;
3165 // Fire callbacks. Increase call depth to prevent recursive callbacks. 3165 // Fire callbacks. Increase call depth to prevent recursive callbacks.
3166 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this); 3166 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this);
3167 v8::Isolate::SuppressMicrotaskExecutionScope suppress(isolate); 3167 v8::Isolate::SuppressMicrotaskExecutionScope suppress(isolate);
3168 for (int i = 0; i < call_completed_callbacks_.length(); i++) { 3168 for (int i = 0; i < call_completed_callbacks_.length(); i++) {
3169 call_completed_callbacks_.at(i)(isolate); 3169 call_completed_callbacks_.at(i)(isolate);
3170 } 3170 }
3171 } 3171 }
3172 3172
3173 void Isolate::EnablePromiseHook() { is_promisehook_enabled_ = true; } 3173 void Isolate::SetPromiseHook(PromiseHook hook) { promise_hook_ = hook; }
3174 3174
3175 void Isolate::DisablePromiseHook() { is_promisehook_enabled_ = false; } 3175 void Isolate::RunPromiseHook(PromiseHookType type, Handle<JSPromise> promise,
3176 Handle<Object> parent) {
3177 if (promise_hook_ == nullptr) return;
3178 promise_hook_(type, v8::Utils::PromiseToLocal(promise),
3179 v8::Utils::ToLocal(parent));
3180 }
3176 3181
3177 void Isolate::SetPromiseRejectCallback(PromiseRejectCallback callback) { 3182 void Isolate::SetPromiseRejectCallback(PromiseRejectCallback callback) {
3178 promise_reject_callback_ = callback; 3183 promise_reject_callback_ = callback;
3179 } 3184 }
3180 3185
3181 3186
3182 void Isolate::ReportPromiseReject(Handle<JSObject> promise, 3187 void Isolate::ReportPromiseReject(Handle<JSObject> promise,
3183 Handle<Object> value, 3188 Handle<Object> value,
3184 v8::PromiseRejectEvent event) { 3189 v8::PromiseRejectEvent event) {
3185 if (promise_reject_callback_ == NULL) return; 3190 if (promise_reject_callback_ == NULL) return;
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
3583 // Then check whether this scope intercepts. 3588 // Then check whether this scope intercepts.
3584 if ((flag & intercept_mask_)) { 3589 if ((flag & intercept_mask_)) {
3585 intercepted_flags_ |= flag; 3590 intercepted_flags_ |= flag;
3586 return true; 3591 return true;
3587 } 3592 }
3588 return false; 3593 return false;
3589 } 3594 }
3590 3595
3591 } // namespace internal 3596 } // namespace internal
3592 } // namespace v8 3597 } // namespace v8
OLDNEW
« no previous file with comments | « src/isolate.h ('k') | src/js/async-await.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698