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

Side by Side Diff: src/js/promise.js

Issue 1531843003: Rename IS_SPEC_OBJECT macro to IS_RECEIVER. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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/js/object-observe.js ('k') | src/js/proxy.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 (function(global, utils, extrasUtils) { 5 (function(global, utils, extrasUtils) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 function PromiseDone(promise, status, value, promiseQueue) { 111 function PromiseDone(promise, status, value, promiseQueue) {
112 if (GET_PRIVATE(promise, promiseStatusSymbol) === 0) { 112 if (GET_PRIVATE(promise, promiseStatusSymbol) === 0) {
113 var tasks = GET_PRIVATE(promise, promiseQueue); 113 var tasks = GET_PRIVATE(promise, promiseQueue);
114 if (tasks.length) PromiseEnqueue(value, tasks, status); 114 if (tasks.length) PromiseEnqueue(value, tasks, status);
115 PromiseSet(promise, status, value); 115 PromiseSet(promise, status, value);
116 } 116 }
117 } 117 }
118 118
119 function PromiseCoerce(constructor, x) { 119 function PromiseCoerce(constructor, x) {
120 if (!IsPromise(x) && IS_SPEC_OBJECT(x)) { 120 if (!IsPromise(x) && IS_RECEIVER(x)) {
121 var then; 121 var then;
122 try { 122 try {
123 then = x.then; 123 then = x.then;
124 } catch(r) { 124 } catch(r) {
125 return %_Call(PromiseRejected, constructor, r); 125 return %_Call(PromiseRejected, constructor, r);
126 } 126 }
127 if (IS_CALLABLE(then)) { 127 if (IS_CALLABLE(then)) {
128 var deferred = NewPromiseCapability(constructor); 128 var deferred = NewPromiseCapability(constructor);
129 try { 129 try {
130 %_Call(then, x, deferred.resolve, deferred.reject); 130 %_Call(then, x, deferred.resolve, deferred.reject);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 function PromiseIdRejectHandler(r) { throw r } 178 function PromiseIdRejectHandler(r) { throw r }
179 179
180 function PromiseNopResolver() {} 180 function PromiseNopResolver() {}
181 181
182 // ------------------------------------------------------------------- 182 // -------------------------------------------------------------------
183 // Define exported functions. 183 // Define exported functions.
184 184
185 // For bootstrapper. 185 // For bootstrapper.
186 186
187 function IsPromise(x) { 187 function IsPromise(x) {
188 return IS_SPEC_OBJECT(x) && HAS_DEFINED_PRIVATE(x, promiseStatusSymbol); 188 return IS_RECEIVER(x) && HAS_DEFINED_PRIVATE(x, promiseStatusSymbol);
189 } 189 }
190 190
191 function PromiseCreate() { 191 function PromiseCreate() {
192 return new GlobalPromise(PromiseNopResolver) 192 return new GlobalPromise(PromiseNopResolver)
193 } 193 }
194 194
195 function PromiseResolve(promise, x) { 195 function PromiseResolve(promise, x) {
196 if (GET_PRIVATE(promise, promiseStatusSymbol) === 0) { 196 if (GET_PRIVATE(promise, promiseStatusSymbol) === 0) {
197 if (IS_SPEC_OBJECT(x)) { 197 if (IS_RECEIVER(x)) {
198 // 25.4.1.3.2 steps 8-12 198 // 25.4.1.3.2 steps 8-12
199 try { 199 try {
200 var then = x.then; 200 var then = x.then;
201 } catch (e) { 201 } catch (e) {
202 return PromiseReject(promise, e); 202 return PromiseReject(promise, e);
203 } 203 }
204 if (IS_CALLABLE(then)) { 204 if (IS_CALLABLE(then)) {
205 // PromiseResolveThenableJob 205 // PromiseResolveThenableJob
206 return %EnqueueMicrotask(function() { 206 return %EnqueueMicrotask(function() {
207 try { 207 try {
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 [PromiseChain, PromiseDeferred, PromiseResolved].forEach( 478 [PromiseChain, PromiseDeferred, PromiseResolved].forEach(
479 fn => %FunctionRemovePrototype(fn)); 479 fn => %FunctionRemovePrototype(fn));
480 480
481 utils.Export(function(to) { 481 utils.Export(function(to) {
482 to.PromiseChain = PromiseChain; 482 to.PromiseChain = PromiseChain;
483 to.PromiseDeferred = PromiseDeferred; 483 to.PromiseDeferred = PromiseDeferred;
484 to.PromiseResolved = PromiseResolved; 484 to.PromiseResolved = PromiseResolved;
485 }); 485 });
486 486
487 }) 487 })
OLDNEW
« no previous file with comments | « src/js/object-observe.js ('k') | src/js/proxy.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698