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

Side by Side Diff: src/promise.js

Issue 1318043002: Native context: do not put public symbols and flags on the js builtins object. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix and rebase Created 5 years, 3 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/prologue.js ('k') | src/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) { 5 (function(global, utils) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
11 // ------------------------------------------------------------------- 11 // -------------------------------------------------------------------
12 // Imports 12 // Imports
13 13
14 var InternalArray = utils.InternalArray; 14 var InternalArray = utils.InternalArray;
15 var promiseHasHandlerSymbol = 15 var promiseHasHandlerSymbol =
16 utils.GetPrivateSymbol("promise_has_handler_symbol"); 16 utils.ImportNow("promise_has_handler_symbol");
17 var promiseOnRejectSymbol = utils.GetPrivateSymbol("promise_on_reject_symbol"); 17 var promiseOnRejectSymbol = utils.ImportNow("promise_on_reject_symbol");
18 var promiseOnResolveSymbol = 18 var promiseOnResolveSymbol =
19 utils.GetPrivateSymbol("promise_on_resolve_symbol"); 19 utils.ImportNow("promise_on_resolve_symbol");
20 var promiseRawSymbol = utils.GetPrivateSymbol("promise_raw_symbol"); 20 var promiseRawSymbol = utils.ImportNow("promise_raw_symbol");
21 var promiseStatusSymbol = utils.GetPrivateSymbol("promise_status_symbol"); 21 var promiseStatusSymbol = utils.ImportNow("promise_status_symbol");
22 var promiseValueSymbol = utils.GetPrivateSymbol("promise_value_symbol"); 22 var promiseValueSymbol = utils.ImportNow("promise_value_symbol");
23 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
23 24
24 // ------------------------------------------------------------------- 25 // -------------------------------------------------------------------
25 26
26 // Status values: 0 = pending, +1 = resolved, -1 = rejected 27 // Status values: 0 = pending, +1 = resolved, -1 = rejected
27 var lastMicrotaskId = 0; 28 var lastMicrotaskId = 0;
28 29
29 var GlobalPromise = function Promise(resolver) { 30 var GlobalPromise = function Promise(resolver) {
30 if (resolver === promiseRawSymbol) return; 31 if (resolver === promiseRawSymbol) return;
31 if (!%_IsConstructCall()) throw MakeTypeError(kNotAPromise, this); 32 if (!%_IsConstructCall()) throw MakeTypeError(kNotAPromise, this);
32 if (!IS_SPEC_FUNCTION(resolver)) 33 if (!IS_SPEC_FUNCTION(resolver))
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 // handler somewhere down the promise chain. For this, we do a depth-first 355 // handler somewhere down the promise chain. For this, we do a depth-first
355 // search for a reject handler that's not the default PromiseIdRejectHandler. 356 // search for a reject handler that's not the default PromiseIdRejectHandler.
356 function PromiseHasUserDefinedRejectHandler() { 357 function PromiseHasUserDefinedRejectHandler() {
357 return PromiseHasUserDefinedRejectHandlerRecursive(this); 358 return PromiseHasUserDefinedRejectHandlerRecursive(this);
358 }; 359 };
359 360
360 // ------------------------------------------------------------------- 361 // -------------------------------------------------------------------
361 // Install exported functions. 362 // Install exported functions.
362 363
363 %AddNamedProperty(global, 'Promise', GlobalPromise, DONT_ENUM); 364 %AddNamedProperty(global, 'Promise', GlobalPromise, DONT_ENUM);
364 %AddNamedProperty(GlobalPromise.prototype, symbolToStringTag, "Promise", 365 %AddNamedProperty(GlobalPromise.prototype, toStringTagSymbol, "Promise",
365 DONT_ENUM | READ_ONLY); 366 DONT_ENUM | READ_ONLY);
366 367
367 utils.InstallFunctions(GlobalPromise, DONT_ENUM, [ 368 utils.InstallFunctions(GlobalPromise, DONT_ENUM, [
368 "defer", PromiseDeferred, 369 "defer", PromiseDeferred,
369 "accept", PromiseResolved, 370 "accept", PromiseResolved,
370 "reject", PromiseRejected, 371 "reject", PromiseRejected,
371 "all", PromiseAll, 372 "all", PromiseAll,
372 "race", PromiseRace, 373 "race", PromiseRace,
373 "resolve", PromiseCast 374 "resolve", PromiseCast
374 ]); 375 ]);
375 376
376 utils.InstallFunctions(GlobalPromise.prototype, DONT_ENUM, [ 377 utils.InstallFunctions(GlobalPromise.prototype, DONT_ENUM, [
377 "chain", PromiseChain, 378 "chain", PromiseChain,
378 "then", PromiseThen, 379 "then", PromiseThen,
379 "catch", PromiseCatch 380 "catch", PromiseCatch
380 ]); 381 ]);
381 382
382 %InstallToContext([ 383 %InstallToContext([
383 "promise_catch", PromiseCatch, 384 "promise_catch", PromiseCatch,
384 "promise_chain", PromiseChain, 385 "promise_chain", PromiseChain,
385 "promise_create", PromiseCreate, 386 "promise_create", PromiseCreate,
386 "promise_has_user_defined_reject_handler", PromiseHasUserDefinedRejectHandler, 387 "promise_has_user_defined_reject_handler", PromiseHasUserDefinedRejectHandler,
387 "promise_reject", PromiseReject, 388 "promise_reject", PromiseReject,
388 "promise_resolve", PromiseResolve, 389 "promise_resolve", PromiseResolve,
389 "promise_then", PromiseThen, 390 "promise_then", PromiseThen,
390 ]); 391 ]);
391 392
392 }) 393 })
OLDNEW
« no previous file with comments | « src/prologue.js ('k') | src/regexp.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698