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

Side by Side Diff: src/isolate.cc

Issue 2415023002: [promises] Move async debug event creation to c++ (Closed)
Patch Set: rebase Created 4 years, 2 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
« no previous file with comments | « src/heap-symbols.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 3058 matching lines...) Expand 10 before | Expand all | Expand 10 after
3069 stack_trace = GetDetailedStackTrace(Handle<JSObject>::cast(value)); 3069 stack_trace = GetDetailedStackTrace(Handle<JSObject>::cast(value));
3070 } 3070 }
3071 promise_reject_callback_(v8::PromiseRejectMessage( 3071 promise_reject_callback_(v8::PromiseRejectMessage(
3072 v8::Utils::PromiseToLocal(promise), event, v8::Utils::ToLocal(value), 3072 v8::Utils::PromiseToLocal(promise), event, v8::Utils::ToLocal(value),
3073 v8::Utils::StackTraceToLocal(stack_trace))); 3073 v8::Utils::StackTraceToLocal(stack_trace)));
3074 } 3074 }
3075 3075
3076 namespace { 3076 namespace {
3077 class PromiseDebugEventScope { 3077 class PromiseDebugEventScope {
3078 public: 3078 public:
3079 PromiseDebugEventScope(Isolate* isolate, Object* before, Object* after) 3079 PromiseDebugEventScope(Isolate* isolate, Object* id, Object* name)
3080 : isolate_(isolate), 3080 : isolate_(isolate),
3081 after_(after, isolate_), 3081 id_(id, isolate_),
3082 is_debug_active_(isolate_->debug()->is_active() && 3082 name_(name, isolate_),
3083 before->IsJSObject() && after->IsJSObject()) { 3083 is_debug_active_(isolate_->debug()->is_active() && id_->IsNumber() &&
3084 name_->IsString()) {
3084 if (is_debug_active_) { 3085 if (is_debug_active_) {
3085 isolate_->debug()->OnAsyncTaskEvent( 3086 isolate_->debug()->OnAsyncTaskEvent(
3086 handle(JSObject::cast(before), isolate_)); 3087 isolate_->factory()->will_handle_string(), id_,
3088 Handle<String>::cast(name_));
3087 } 3089 }
3088 } 3090 }
3089 3091
3090 ~PromiseDebugEventScope() { 3092 ~PromiseDebugEventScope() {
3091 if (is_debug_active_) { 3093 if (is_debug_active_) {
3092 isolate_->debug()->OnAsyncTaskEvent(Handle<JSObject>::cast(after_)); 3094 isolate_->debug()->OnAsyncTaskEvent(
3095 isolate_->factory()->did_handle_string(), id_,
3096 Handle<String>::cast(name_));
3093 } 3097 }
3094 } 3098 }
3095 3099
3096 private: 3100 private:
3097 Isolate* isolate_; 3101 Isolate* isolate_;
3098 Handle<Object> after_; 3102 Handle<Object> id_;
3103 Handle<Object> name_;
3099 bool is_debug_active_; 3104 bool is_debug_active_;
3100 }; 3105 };
3101 } // namespace 3106 } // namespace
3102 3107
3103 void Isolate::PromiseReactionJob(Handle<PromiseReactionJobInfo> info, 3108 void Isolate::PromiseReactionJob(Handle<PromiseReactionJobInfo> info,
3104 MaybeHandle<Object>* result, 3109 MaybeHandle<Object>* result,
3105 MaybeHandle<Object>* maybe_exception) { 3110 MaybeHandle<Object>* maybe_exception) {
3106 PromiseDebugEventScope helper(this, info->before_debug_event(), 3111 PromiseDebugEventScope helper(this, info->debug_id(), info->debug_name());
3107 info->after_debug_event());
3108 3112
3109 Handle<Object> value(info->value(), this); 3113 Handle<Object> value(info->value(), this);
3110 Handle<Object> tasks(info->tasks(), this); 3114 Handle<Object> tasks(info->tasks(), this);
3111 Handle<JSFunction> promise_handle_fn = promise_handle(); 3115 Handle<JSFunction> promise_handle_fn = promise_handle();
3112 Handle<Object> undefined = factory()->undefined_value(); 3116 Handle<Object> undefined = factory()->undefined_value();
3113 3117
3114 // If tasks is an array we have multiple onFulfilled/onRejected callbacks 3118 // If tasks is an array we have multiple onFulfilled/onRejected callbacks
3115 // associated with the promise. The deferred object for each callback 3119 // associated with the promise. The deferred object for each callback
3116 // is attached to this array as well. 3120 // is attached to this array as well.
3117 // Otherwise, there is a single callback and the deferred object is attached 3121 // Otherwise, there is a single callback and the deferred object is attached
(...skipping 20 matching lines...) Expand all
3138 Handle<Object> deferred(info->deferred(), this); 3142 Handle<Object> deferred(info->deferred(), this);
3139 Handle<Object> argv[] = {value, tasks, deferred}; 3143 Handle<Object> argv[] = {value, tasks, deferred};
3140 *result = Execution::TryCall(this, promise_handle_fn, undefined, 3144 *result = Execution::TryCall(this, promise_handle_fn, undefined,
3141 arraysize(argv), argv, maybe_exception); 3145 arraysize(argv), argv, maybe_exception);
3142 } 3146 }
3143 } 3147 }
3144 3148
3145 void Isolate::PromiseResolveThenableJob( 3149 void Isolate::PromiseResolveThenableJob(
3146 Handle<PromiseResolveThenableJobInfo> info, MaybeHandle<Object>* result, 3150 Handle<PromiseResolveThenableJobInfo> info, MaybeHandle<Object>* result,
3147 MaybeHandle<Object>* maybe_exception) { 3151 MaybeHandle<Object>* maybe_exception) {
3148 PromiseDebugEventScope helper(this, info->before_debug_event(), 3152 PromiseDebugEventScope helper(this, info->debug_id(), info->debug_name());
3149 info->after_debug_event());
3150 3153
3151 Handle<JSReceiver> thenable(info->thenable(), this); 3154 Handle<JSReceiver> thenable(info->thenable(), this);
3152 Handle<JSFunction> resolve(info->resolve(), this); 3155 Handle<JSFunction> resolve(info->resolve(), this);
3153 Handle<JSFunction> reject(info->reject(), this); 3156 Handle<JSFunction> reject(info->reject(), this);
3154 Handle<JSReceiver> then(info->then(), this); 3157 Handle<JSReceiver> then(info->then(), this);
3155 Handle<Object> argv[] = {resolve, reject}; 3158 Handle<Object> argv[] = {resolve, reject};
3156 *result = Execution::TryCall(this, then, thenable, arraysize(argv), argv, 3159 *result = Execution::TryCall(this, then, thenable, arraysize(argv), argv,
3157 maybe_exception); 3160 maybe_exception);
3158 3161
3159 Handle<Object> reason; 3162 Handle<Object> reason;
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
3457 // Then check whether this scope intercepts. 3460 // Then check whether this scope intercepts.
3458 if ((flag & intercept_mask_)) { 3461 if ((flag & intercept_mask_)) {
3459 intercepted_flags_ |= flag; 3462 intercepted_flags_ |= flag;
3460 return true; 3463 return true;
3461 } 3464 }
3462 return false; 3465 return false;
3463 } 3466 }
3464 3467
3465 } // namespace internal 3468 } // namespace internal
3466 } // namespace v8 3469 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap-symbols.h ('k') | src/js/async-await.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698