Commit d8967c55 authored by littledan's avatar littledan Committed by Commit bot

Renaming cleanup of Promises

The Promise code previously used many names which were gratuitiously
different from the specification. This patch swaps in names from the
ES2015 spec, and inserts crossreferences to the spec. The patch
leaves mirrors over Promises unchanged for now, as these changes
could have compatibility risk.

R=cbruni@chromium.org

Review-Url: https://codereview.chromium.org/1919143004
Cr-Commit-Position: refs/heads/master@{#35962}
parent 8d018a39
......@@ -16,8 +16,8 @@ var MakeError;
var MapEntries;
var MapIteratorNext;
var MathMin = global.Math.min;
var promiseStatusSymbol = utils.ImportNow("promise_status_symbol");
var promiseValueSymbol = utils.ImportNow("promise_value_symbol");
var promiseStateSymbol = utils.ImportNow("promise_state_symbol");
var promiseResultSymbol = utils.ImportNow("promise_result_symbol");
var SetIteratorNext;
var SetValues;
var SymbolToString;
......@@ -115,7 +115,7 @@ function ClearMirrorCache(value) {
function ObjectIsPromise(value) {
return IS_RECEIVER(value) &&
!IS_UNDEFINED(%DebugGetProperty(value, promiseStatusSymbol));
!IS_UNDEFINED(%DebugGetProperty(value, promiseStateSymbol));
}
......@@ -1272,7 +1272,7 @@ inherits(PromiseMirror, ObjectMirror);
function PromiseGetStatus_(value) {
var status = %DebugGetProperty(value, promiseStatusSymbol);
var status = %DebugGetProperty(value, promiseStateSymbol);
if (status == 0) return "pending";
if (status == 1) return "resolved";
return "rejected";
......@@ -1280,7 +1280,7 @@ function PromiseGetStatus_(value) {
function PromiseGetValue_(value) {
return %DebugGetProperty(value, promiseValueSymbol);
return %DebugGetProperty(value, promiseResultSymbol);
}
......
......@@ -166,11 +166,11 @@
V(promise_combined_deferred_symbol) \
V(promise_debug_marker_symbol) \
V(promise_has_handler_symbol) \
V(promise_on_resolve_symbol) \
V(promise_on_reject_symbol) \
V(promise_fulfill_reactions_symbol) \
V(promise_reject_reactions_symbol) \
V(promise_raw_symbol) \
V(promise_status_symbol) \
V(promise_value_symbol) \
V(promise_state_symbol) \
V(promise_result_symbol) \
V(sealed_symbol) \
V(stack_trace_symbol) \
V(strict_function_transition_symbol) \
......
......@@ -196,8 +196,8 @@ function PostNatives(utils) {
"MinSimple",
"NumberIsInteger",
"PromiseChain",
"PromiseDeferred",
"PromiseResolved",
"PromiseDefer",
"PromiseAccept",
"RegExpSubclassExecJS",
"RegExpSubclassMatch",
"RegExpSubclassReplace",
......@@ -212,8 +212,8 @@ function PostNatives(utils) {
// From runtime:
"is_concat_spreadable_symbol",
"iterator_symbol",
"promise_status_symbol",
"promise_value_symbol",
"promise_result_symbol",
"promise_state_symbol",
"object_freeze",
"object_is_frozen",
"object_is_sealed",
......
......@@ -11,16 +11,16 @@
var GlobalPromise = global.Promise;
var PromiseChain = utils.ImportNow("PromiseChain");
var PromiseDeferred = utils.ImportNow("PromiseDeferred");
var PromiseResolved = utils.ImportNow("PromiseResolved");
var PromiseDefer = utils.ImportNow("PromiseDefer");
var PromiseAccept = utils.ImportNow("PromiseAccept");
utils.InstallFunctions(GlobalPromise.prototype, DONT_ENUM, [
"chain", PromiseChain,
]);
utils.InstallFunctions(GlobalPromise, DONT_ENUM, [
"defer", PromiseDeferred,
"accept", PromiseResolved,
"defer", PromiseDefer,
"accept", PromiseAccept,
]);
})
This diff is collapsed.
......@@ -595,7 +595,7 @@ bool Object::IsPromise(Handle<Object> object) {
auto isolate = js_object->GetIsolate();
// TODO(dcarney): this should just be read from the symbol registry so as not
// to be context dependent.
auto key = isolate->factory()->promise_status_symbol();
auto key = isolate->factory()->promise_state_symbol();
// Shouldn't be possible to throw here.
return JSObject::HasRealNamedProperty(js_object, key).FromJust();
}
......
......@@ -244,7 +244,7 @@ MaybeHandle<JSArray> Runtime::GetInternalProperties(Isolate* isolate,
Handle<JSObject> promise = Handle<JSObject>::cast(object);
Handle<Object> status_obj =
DebugGetProperty(promise, isolate->factory()->promise_status_symbol());
DebugGetProperty(promise, isolate->factory()->promise_state_symbol());
RUNTIME_ASSERT_HANDLIFIED(status_obj->IsSmi(), JSArray);
const char* status = "rejected";
int status_val = Handle<Smi>::cast(status_obj)->value();
......@@ -267,7 +267,7 @@ MaybeHandle<JSArray> Runtime::GetInternalProperties(Isolate* isolate,
result->set(1, *status_str);
Handle<Object> value_obj =
DebugGetProperty(promise, isolate->factory()->promise_value_symbol());
DebugGetProperty(promise, isolate->factory()->promise_result_symbol());
Handle<String> promise_value =
factory->NewStringFromAsciiChecked("[[PromiseValue]]");
result->set(2, *promise_value);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment