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

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

Issue 1558113002: Add UseCounters for various standards-related code paths (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix accidental redefinition Created 4 years, 11 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/js/macros.py ('k') | src/js/regexp.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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 239
240 if (!IS_CALLABLE(result.resolve)) 240 if (!IS_CALLABLE(result.resolve))
241 throw MakeTypeError(kCalledNonCallable, "promiseCapability.[[Resolve]]"); 241 throw MakeTypeError(kCalledNonCallable, "promiseCapability.[[Resolve]]");
242 if (!IS_CALLABLE(result.reject)) 242 if (!IS_CALLABLE(result.reject))
243 throw MakeTypeError(kCalledNonCallable, "promiseCapability.[[Reject]]"); 243 throw MakeTypeError(kCalledNonCallable, "promiseCapability.[[Reject]]");
244 244
245 return result; 245 return result;
246 } 246 }
247 247
248 function PromiseDeferred() { 248 function PromiseDeferred() {
249 %IncrementUseCounter(kPromiseDefer);
249 return NewPromiseCapability(this); 250 return NewPromiseCapability(this);
250 } 251 }
251 252
252 function PromiseResolved(x) { 253 function PromiseResolved(x) {
254 %IncrementUseCounter(kPromiseAccept);
253 return %_Call(PromiseCast, this, x); 255 return %_Call(PromiseCast, this, x);
254 } 256 }
255 257
256 function PromiseRejected(r) { 258 function PromiseRejected(r) {
257 if (!IS_RECEIVER(this)) { 259 if (!IS_RECEIVER(this)) {
258 throw MakeTypeError(kCalledOnNonObject, PromiseRejected); 260 throw MakeTypeError(kCalledOnNonObject, PromiseRejected);
259 } 261 }
260 if (this === GlobalPromise) { 262 if (this === GlobalPromise) {
261 // Optimized case, avoid extra closure. 263 // Optimized case, avoid extra closure.
262 var promise = PromiseCreateAndSet(-1, r); 264 var promise = PromiseCreateAndSet(-1, r);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 // Mark this promise as having handler. 309 // Mark this promise as having handler.
308 SET_PRIVATE(this, promiseHasHandlerSymbol, true); 310 SET_PRIVATE(this, promiseHasHandlerSymbol, true);
309 if (DEBUG_IS_ACTIVE) { 311 if (DEBUG_IS_ACTIVE) {
310 %DebugPromiseEvent({ promise: deferred.promise, parentPromise: this }); 312 %DebugPromiseEvent({ promise: deferred.promise, parentPromise: this });
311 } 313 }
312 return deferred.promise; 314 return deferred.promise;
313 } 315 }
314 316
315 // Chain is left around for now as an alias for then 317 // Chain is left around for now as an alias for then
316 function PromiseChain(onResolve, onReject) { 318 function PromiseChain(onResolve, onReject) {
319 %IncrementUseCounter(kPromiseChain);
317 return %_Call(PromiseThen, this, onResolve, onReject); 320 return %_Call(PromiseThen, this, onResolve, onReject);
318 } 321 }
319 322
320 function PromiseCatch(onReject) { 323 function PromiseCatch(onReject) {
321 return this.then(UNDEFINED, onReject); 324 return this.then(UNDEFINED, onReject);
322 } 325 }
323 326
324 // Combinators. 327 // Combinators.
325 328
326 function PromiseCast(x) { 329 function PromiseCast(x) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 [PromiseChain, PromiseDeferred, PromiseResolved].forEach( 458 [PromiseChain, PromiseDeferred, PromiseResolved].forEach(
456 fn => %FunctionRemovePrototype(fn)); 459 fn => %FunctionRemovePrototype(fn));
457 460
458 utils.Export(function(to) { 461 utils.Export(function(to) {
459 to.PromiseChain = PromiseChain; 462 to.PromiseChain = PromiseChain;
460 to.PromiseDeferred = PromiseDeferred; 463 to.PromiseDeferred = PromiseDeferred;
461 to.PromiseResolved = PromiseResolved; 464 to.PromiseResolved = PromiseResolved;
462 }); 465 });
463 466
464 }) 467 })
OLDNEW
« no previous file with comments | « src/js/macros.py ('k') | src/js/regexp.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698