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

Side by Side Diff: src/isolate.cc

Issue 2554013002: Revert of Create JSPromise (Closed)
Patch Set: 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/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 3142 matching lines...) Expand 10 before | Expand all | Expand 10 after
3153 3153
3154 void Isolate::PromiseReactionJob(Handle<PromiseReactionJobInfo> info, 3154 void Isolate::PromiseReactionJob(Handle<PromiseReactionJobInfo> info,
3155 MaybeHandle<Object>* result, 3155 MaybeHandle<Object>* result,
3156 MaybeHandle<Object>* maybe_exception) { 3156 MaybeHandle<Object>* maybe_exception) {
3157 PromiseDebugEventScope helper(this, info->debug_id(), info->debug_name()); 3157 PromiseDebugEventScope helper(this, info->debug_id(), info->debug_name());
3158 3158
3159 Handle<Object> value(info->value(), this); 3159 Handle<Object> value(info->value(), this);
3160 Handle<Object> tasks(info->tasks(), this); 3160 Handle<Object> tasks(info->tasks(), this);
3161 Handle<JSFunction> promise_handle_fn = promise_handle(); 3161 Handle<JSFunction> promise_handle_fn = promise_handle();
3162 Handle<Object> undefined = factory()->undefined_value(); 3162 Handle<Object> undefined = factory()->undefined_value();
3163 Handle<Object> deferred(info->deferred(), this);
3164 3163
3165 if (deferred->IsFixedArray()) { 3164 // If tasks is an array we have multiple onFulfilled/onRejected callbacks
3166 DCHECK(tasks->IsFixedArray()); 3165 // associated with the promise. The deferred object for each callback
3167 Handle<FixedArray> deferred_arr = Handle<FixedArray>::cast(deferred); 3166 // is attached to this array as well.
3168 Handle<FixedArray> tasks_arr = Handle<FixedArray>::cast(tasks); 3167 // Otherwise, there is a single callback and the deferred object is attached
3169 for (int i = 0; i < deferred_arr->length(); i++) { 3168 // directly to PromiseReactionJobInfo.
3170 Handle<Object> argv[] = {value, handle(tasks_arr->get(i), this), 3169 if (tasks->IsJSArray()) {
3171 handle(deferred_arr->get(i), this)}; 3170 Handle<JSArray> array = Handle<JSArray>::cast(tasks);
3171 DCHECK(array->length()->IsSmi());
3172 int length = Smi::cast(array->length())->value();
3173 ElementsAccessor* accessor = array->GetElementsAccessor();
3174 DCHECK(length % 2 == 0);
3175 for (int i = 0; i < length; i += 2) {
3176 DCHECK(accessor->HasElement(array, i));
3177 DCHECK(accessor->HasElement(array, i + 1));
3178 Handle<Object> argv[] = {value, accessor->Get(array, i),
3179 accessor->Get(array, i + 1)};
3172 *result = Execution::TryCall(this, promise_handle_fn, undefined, 3180 *result = Execution::TryCall(this, promise_handle_fn, undefined,
3173 arraysize(argv), argv, maybe_exception); 3181 arraysize(argv), argv, maybe_exception);
3174 // If execution is terminating, just bail out. 3182 // If execution is terminating, just bail out.
3175 if (result->is_null() && maybe_exception->is_null()) { 3183 if (result->is_null() && maybe_exception->is_null()) {
3176 return; 3184 return;
3177 } 3185 }
3178 } 3186 }
3179 } else { 3187 } else {
3188 Handle<Object> deferred(info->deferred(), this);
3180 Handle<Object> argv[] = {value, tasks, deferred}; 3189 Handle<Object> argv[] = {value, tasks, deferred};
3181 *result = Execution::TryCall(this, promise_handle_fn, undefined, 3190 *result = Execution::TryCall(this, promise_handle_fn, undefined,
3182 arraysize(argv), argv, maybe_exception); 3191 arraysize(argv), argv, maybe_exception);
3183 } 3192 }
3184 } 3193 }
3185 3194
3186 void Isolate::PromiseResolveThenableJob( 3195 void Isolate::PromiseResolveThenableJob(
3187 Handle<PromiseResolveThenableJobInfo> info, MaybeHandle<Object>* result, 3196 Handle<PromiseResolveThenableJobInfo> info, MaybeHandle<Object>* result,
3188 MaybeHandle<Object>* maybe_exception) { 3197 MaybeHandle<Object>* maybe_exception) {
3189 PromiseDebugEventScope helper(this, info->debug_id(), info->debug_name()); 3198 PromiseDebugEventScope helper(this, info->debug_id(), info->debug_name());
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
3495 // Then check whether this scope intercepts. 3504 // Then check whether this scope intercepts.
3496 if ((flag & intercept_mask_)) { 3505 if ((flag & intercept_mask_)) {
3497 intercepted_flags_ |= flag; 3506 intercepted_flags_ |= flag;
3498 return true; 3507 return true;
3499 } 3508 }
3500 return false; 3509 return false;
3501 } 3510 }
3502 3511
3503 } // namespace internal 3512 } // namespace internal
3504 } // namespace v8 3513 } // 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