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

Side by Side Diff: src/isolate.cc

Issue 2412263002: [promises] rename PromiseContainer to PromiseResolveThenableJobInfo (Closed)
Patch Set: fix build 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/isolate.h ('k') | src/objects.h » ('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 3118 matching lines...) Expand 10 before | Expand all | Expand 10 after
3129 } 3129 }
3130 } 3130 }
3131 } else { 3131 } else {
3132 Handle<Object> deferred(info->deferred(), this); 3132 Handle<Object> deferred(info->deferred(), this);
3133 Handle<Object> argv[] = {value, tasks, deferred}; 3133 Handle<Object> argv[] = {value, tasks, deferred};
3134 *result = Execution::TryCall(this, promise_handle_fn, undefined, 3134 *result = Execution::TryCall(this, promise_handle_fn, undefined,
3135 arraysize(argv), argv, maybe_exception); 3135 arraysize(argv), argv, maybe_exception);
3136 } 3136 }
3137 } 3137 }
3138 3138
3139 void Isolate::PromiseResolveThenableJob(Handle<PromiseContainer> container, 3139 void Isolate::PromiseResolveThenableJob(
3140 MaybeHandle<Object>* result, 3140 Handle<PromiseResolveThenableJobInfo> info, MaybeHandle<Object>* result,
3141 MaybeHandle<Object>* maybe_exception) { 3141 MaybeHandle<Object>* maybe_exception) {
3142 PromiseDebugEventScope helper(this, container->before_debug_event(), 3142 PromiseDebugEventScope helper(this, info->before_debug_event(),
3143 container->after_debug_event()); 3143 info->after_debug_event());
3144 3144
3145 Handle<JSReceiver> thenable(container->thenable(), this); 3145 Handle<JSReceiver> thenable(info->thenable(), this);
3146 Handle<JSFunction> resolve(container->resolve(), this); 3146 Handle<JSFunction> resolve(info->resolve(), this);
3147 Handle<JSFunction> reject(container->reject(), this); 3147 Handle<JSFunction> reject(info->reject(), this);
3148 Handle<JSReceiver> then(container->then(), this); 3148 Handle<JSReceiver> then(info->then(), this);
3149 Handle<Object> argv[] = {resolve, reject}; 3149 Handle<Object> argv[] = {resolve, reject};
3150 *result = Execution::TryCall(this, then, thenable, arraysize(argv), argv, 3150 *result = Execution::TryCall(this, then, thenable, arraysize(argv), argv,
3151 maybe_exception); 3151 maybe_exception);
3152 3152
3153 Handle<Object> reason; 3153 Handle<Object> reason;
3154 if (maybe_exception->ToHandle(&reason)) { 3154 if (maybe_exception->ToHandle(&reason)) {
3155 DCHECK(result->is_null()); 3155 DCHECK(result->is_null());
3156 Handle<Object> reason_arg[] = {reason}; 3156 Handle<Object> reason_arg[] = {reason};
3157 *result = 3157 *result =
3158 Execution::TryCall(this, reject, factory()->undefined_value(), 3158 Execution::TryCall(this, reject, factory()->undefined_value(),
3159 arraysize(reason_arg), reason_arg, maybe_exception); 3159 arraysize(reason_arg), reason_arg, maybe_exception);
3160 } 3160 }
3161 } 3161 }
3162 3162
3163 void Isolate::EnqueueMicrotask(Handle<Object> microtask) { 3163 void Isolate::EnqueueMicrotask(Handle<Object> microtask) {
3164 DCHECK(microtask->IsJSFunction() || microtask->IsCallHandlerInfo() || 3164 DCHECK(microtask->IsJSFunction() || microtask->IsCallHandlerInfo() ||
3165 microtask->IsPromiseContainer() || 3165 microtask->IsPromiseResolveThenableJobInfo() ||
3166 microtask->IsPromiseReactionJobInfo()); 3166 microtask->IsPromiseReactionJobInfo());
3167 Handle<FixedArray> queue(heap()->microtask_queue(), this); 3167 Handle<FixedArray> queue(heap()->microtask_queue(), this);
3168 int num_tasks = pending_microtask_count(); 3168 int num_tasks = pending_microtask_count();
3169 DCHECK(num_tasks <= queue->length()); 3169 DCHECK(num_tasks <= queue->length());
3170 if (num_tasks == 0) { 3170 if (num_tasks == 0) {
3171 queue = factory()->NewFixedArray(8); 3171 queue = factory()->NewFixedArray(8);
3172 heap()->set_microtask_queue(*queue); 3172 heap()->set_microtask_queue(*queue);
3173 } else if (num_tasks == queue->length()) { 3173 } else if (num_tasks == queue->length()) {
3174 queue = factory()->CopyFixedArrayAndGrow(queue, num_tasks); 3174 queue = factory()->CopyFixedArrayAndGrow(queue, num_tasks);
3175 heap()->set_microtask_queue(*queue); 3175 heap()->set_microtask_queue(*queue);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3211 Handle<CallHandlerInfo>::cast(microtask); 3211 Handle<CallHandlerInfo>::cast(microtask);
3212 v8::MicrotaskCallback callback = 3212 v8::MicrotaskCallback callback =
3213 v8::ToCData<v8::MicrotaskCallback>(callback_info->callback()); 3213 v8::ToCData<v8::MicrotaskCallback>(callback_info->callback());
3214 void* data = v8::ToCData<void*>(callback_info->data()); 3214 void* data = v8::ToCData<void*>(callback_info->data());
3215 callback(data); 3215 callback(data);
3216 } else { 3216 } else {
3217 SaveContext save(this); 3217 SaveContext save(this);
3218 Context* context; 3218 Context* context;
3219 if (microtask->IsJSFunction()) { 3219 if (microtask->IsJSFunction()) {
3220 context = Handle<JSFunction>::cast(microtask)->context(); 3220 context = Handle<JSFunction>::cast(microtask)->context();
3221 } else if (microtask->IsPromiseContainer()) { 3221 } else if (microtask->IsPromiseResolveThenableJobInfo()) {
3222 context = 3222 context = Handle<PromiseResolveThenableJobInfo>::cast(microtask)
3223 Handle<PromiseContainer>::cast(microtask)->resolve()->context(); 3223 ->resolve()
3224 ->context();
3224 } else { 3225 } else {
3225 context = Handle<PromiseReactionJobInfo>::cast(microtask)->context(); 3226 context = Handle<PromiseReactionJobInfo>::cast(microtask)->context();
3226 } 3227 }
3227 3228
3228 set_context(context->native_context()); 3229 set_context(context->native_context());
3229 handle_scope_implementer_->EnterMicrotaskContext( 3230 handle_scope_implementer_->EnterMicrotaskContext(
3230 Handle<Context>(context, this)); 3231 Handle<Context>(context, this));
3231 3232
3232 MaybeHandle<Object> result; 3233 MaybeHandle<Object> result;
3233 MaybeHandle<Object> maybe_exception; 3234 MaybeHandle<Object> maybe_exception;
3234 3235
3235 if (microtask->IsJSFunction()) { 3236 if (microtask->IsJSFunction()) {
3236 Handle<JSFunction> microtask_function = 3237 Handle<JSFunction> microtask_function =
3237 Handle<JSFunction>::cast(microtask); 3238 Handle<JSFunction>::cast(microtask);
3238 result = Execution::TryCall(this, microtask_function, 3239 result = Execution::TryCall(this, microtask_function,
3239 factory()->undefined_value(), 0, NULL, 3240 factory()->undefined_value(), 0, NULL,
3240 &maybe_exception); 3241 &maybe_exception);
3241 } else if (microtask->IsPromiseContainer()) { 3242 } else if (microtask->IsPromiseResolveThenableJobInfo()) {
3242 PromiseResolveThenableJob(Handle<PromiseContainer>::cast(microtask), 3243 PromiseResolveThenableJob(
3243 &result, &maybe_exception); 3244 Handle<PromiseResolveThenableJobInfo>::cast(microtask), &result,
3245 &maybe_exception);
3244 } else { 3246 } else {
3245 PromiseReactionJob(Handle<PromiseReactionJobInfo>::cast(microtask), 3247 PromiseReactionJob(Handle<PromiseReactionJobInfo>::cast(microtask),
3246 &result, &maybe_exception); 3248 &result, &maybe_exception);
3247 } 3249 }
3248 3250
3249 handle_scope_implementer_->LeaveMicrotaskContext(); 3251 handle_scope_implementer_->LeaveMicrotaskContext();
3250 3252
3251 // If execution is terminating, just bail out. 3253 // If execution is terminating, just bail out.
3252 if (result.is_null() && maybe_exception.is_null()) { 3254 if (result.is_null() && maybe_exception.is_null()) {
3253 // Clear out any remaining callbacks in the queue. 3255 // Clear out any remaining callbacks in the queue.
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
3449 // Then check whether this scope intercepts. 3451 // Then check whether this scope intercepts.
3450 if ((flag & intercept_mask_)) { 3452 if ((flag & intercept_mask_)) {
3451 intercepted_flags_ |= flag; 3453 intercepted_flags_ |= flag;
3452 return true; 3454 return true;
3453 } 3455 }
3454 return false; 3456 return false;
3455 } 3457 }
3456 3458
3457 } // namespace internal 3459 } // namespace internal
3458 } // namespace v8 3460 } // namespace v8
OLDNEW
« no previous file with comments | « src/isolate.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698