Commit 620410a1 authored by Mathias Bynens's avatar Mathias Bynens Committed by Commit Bot

Implement global proposal

The proposal is currently at Stage 3 of the TC39 process.
Repository: https://github.com/tc39/proposal-global

Bug: v8:5537
Change-Id: I36c39fdab049497f50685c6672655b67ec4d8ce9
Reviewed-on: https://chromium-review.googlesource.com/1174113
Commit-Queue: Mathias Bynens <mathias@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarSathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55159}
parent 8d7fb514
......@@ -4244,6 +4244,17 @@ EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_numeric_separator)
#undef EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE
void Genesis::InitializeGlobal_harmony_global() {
if (!FLAG_harmony_global) return;
Factory* factory = isolate()->factory();
Handle<JSGlobalObject> global(native_context()->global_object(), isolate());
Handle<JSGlobalProxy> global_proxy(native_context()->global_proxy(),
isolate());
JSObject::AddProperty(isolate_, global, factory->globalThis_string(),
global_proxy, DONT_ENUM);
}
void Genesis::InitializeGlobal_harmony_sharedarraybuffer() {
if (!FLAG_harmony_sharedarraybuffer) return;
......
......@@ -230,7 +230,8 @@ DEFINE_IMPLICATION(harmony_class_fields, harmony_private_fields)
V(harmony_public_fields, "harmony public fields in class literals") \
V(harmony_private_fields, "harmony private fields in class literals") \
V(harmony_numeric_separator, "harmony numeric separator between digits") \
V(harmony_string_matchall, "harmony String.prototype.matchAll")
V(harmony_string_matchall, "harmony String.prototype.matchAll") \
V(harmony_global, "harmony global")
// Features that are shipping (turned on by default, but internal flag remains).
#define HARMONY_SHIPPING(V) \
......
......@@ -96,6 +96,7 @@
V(getOwnPropertyDescriptors_string, "getOwnPropertyDescriptors") \
V(getPrototypeOf_string, "getPrototypeOf") \
V(global_string, "global") \
V(globalThis_string, "globalThis") \
V(group_string, "group") \
V(groups_string, "groups") \
V(has_string, "has") \
......
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-global
assertTrue(delete globalThis);
assertEquals(this.globalThis, undefined);
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-global
globalThis = '[[Writable]]';
assertEquals(globalThis, '[[Writable]]');
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-global
assertEquals(globalThis, this);
assertEquals(this.globalThis, this);
assertEquals(globalThis.globalThis, this);
assertEquals(globalThis.globalThis.globalThis, this);
assertEquals(globalThis.globalThis.globalThis.globalThis, this);
{
const realm = Realm.create();
assertEquals(Realm.global(realm), Realm.eval(realm, 'globalThis'));
assertTrue(Realm.global(realm) !== globalThis);
}
{
const descriptor = Object.getOwnPropertyDescriptor(
this,
'globalThis'
);
assertEquals(descriptor.value, this);
assertEquals(descriptor.writable, true);
assertEquals(descriptor.enumerable, false);
assertEquals(descriptor.configurable, true);
}
......@@ -16,7 +16,7 @@
namespace v8 {
static const char* kHeader =
"# Copyright 2017 the V8 project authors. All rights reserved.\n"
"# Copyright 2018 the V8 project authors. All rights reserved.\n"
"# Use of this source code is governed by a BSD-style license that can\n"
"# be found in the LICENSE file.\n"
"\n"
......
# Copyright 2017 the V8 project authors. All rights reserved.
# Copyright 2018 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can
# be found in the LICENSE file.
......@@ -283,33 +283,33 @@ KNOWN_MAPS = {
("RO_SPACE", 0x04771): (171, "Tuple2Map"),
("RO_SPACE", 0x04a99): (161, "InterceptorInfoMap"),
("RO_SPACE", 0x04b91): (169, "ScriptMap"),
("RO_SPACE", 0x09a11): (154, "AccessorInfoMap"),
("RO_SPACE", 0x09a61): (153, "AccessCheckInfoMap"),
("RO_SPACE", 0x09ab1): (155, "AccessorPairMap"),
("RO_SPACE", 0x09b01): (156, "AliasedArgumentsEntryMap"),
("RO_SPACE", 0x09b51): (157, "AllocationMementoMap"),
("RO_SPACE", 0x09ba1): (158, "AsyncGeneratorRequestMap"),
("RO_SPACE", 0x09bf1): (159, "DebugInfoMap"),
("RO_SPACE", 0x09c41): (160, "FunctionTemplateInfoMap"),
("RO_SPACE", 0x09c91): (162, "InterpreterDataMap"),
("RO_SPACE", 0x09ce1): (163, "ModuleInfoEntryMap"),
("RO_SPACE", 0x09d31): (164, "ModuleMap"),
("RO_SPACE", 0x09d81): (165, "ObjectTemplateInfoMap"),
("RO_SPACE", 0x09dd1): (166, "PromiseCapabilityMap"),
("RO_SPACE", 0x09e21): (167, "PromiseReactionMap"),
("RO_SPACE", 0x09e71): (168, "PrototypeInfoMap"),
("RO_SPACE", 0x09ec1): (170, "StackFrameInfoMap"),
("RO_SPACE", 0x09f11): (172, "Tuple3Map"),
("RO_SPACE", 0x09f61): (173, "ArrayBoilerplateDescriptionMap"),
("RO_SPACE", 0x09fb1): (174, "WasmDebugInfoMap"),
("RO_SPACE", 0x0a001): (175, "WasmExportedFunctionDataMap"),
("RO_SPACE", 0x0a051): (176, "CallableTaskMap"),
("RO_SPACE", 0x0a0a1): (177, "CallbackTaskMap"),
("RO_SPACE", 0x0a0f1): (178, "PromiseFulfillReactionJobTaskMap"),
("RO_SPACE", 0x0a141): (179, "PromiseRejectReactionJobTaskMap"),
("RO_SPACE", 0x0a191): (180, "PromiseResolveThenableJobTaskMap"),
("RO_SPACE", 0x0a1e1): (181, "AllocationSiteMap"),
("RO_SPACE", 0x0a231): (181, "AllocationSiteMap"),
("RO_SPACE", 0x09a39): (154, "AccessorInfoMap"),
("RO_SPACE", 0x09a89): (153, "AccessCheckInfoMap"),
("RO_SPACE", 0x09ad9): (155, "AccessorPairMap"),
("RO_SPACE", 0x09b29): (156, "AliasedArgumentsEntryMap"),
("RO_SPACE", 0x09b79): (157, "AllocationMementoMap"),
("RO_SPACE", 0x09bc9): (158, "AsyncGeneratorRequestMap"),
("RO_SPACE", 0x09c19): (159, "DebugInfoMap"),
("RO_SPACE", 0x09c69): (160, "FunctionTemplateInfoMap"),
("RO_SPACE", 0x09cb9): (162, "InterpreterDataMap"),
("RO_SPACE", 0x09d09): (163, "ModuleInfoEntryMap"),
("RO_SPACE", 0x09d59): (164, "ModuleMap"),
("RO_SPACE", 0x09da9): (165, "ObjectTemplateInfoMap"),
("RO_SPACE", 0x09df9): (166, "PromiseCapabilityMap"),
("RO_SPACE", 0x09e49): (167, "PromiseReactionMap"),
("RO_SPACE", 0x09e99): (168, "PrototypeInfoMap"),
("RO_SPACE", 0x09ee9): (170, "StackFrameInfoMap"),
("RO_SPACE", 0x09f39): (172, "Tuple3Map"),
("RO_SPACE", 0x09f89): (173, "ArrayBoilerplateDescriptionMap"),
("RO_SPACE", 0x09fd9): (174, "WasmDebugInfoMap"),
("RO_SPACE", 0x0a029): (175, "WasmExportedFunctionDataMap"),
("RO_SPACE", 0x0a079): (176, "CallableTaskMap"),
("RO_SPACE", 0x0a0c9): (177, "CallbackTaskMap"),
("RO_SPACE", 0x0a119): (178, "PromiseFulfillReactionJobTaskMap"),
("RO_SPACE", 0x0a169): (179, "PromiseRejectReactionJobTaskMap"),
("RO_SPACE", 0x0a1b9): (180, "PromiseResolveThenableJobTaskMap"),
("RO_SPACE", 0x0a209): (181, "AllocationSiteMap"),
("RO_SPACE", 0x0a259): (181, "AllocationSiteMap"),
("MAP_SPACE", 0x02201): (1057, "ExternalMap"),
("MAP_SPACE", 0x02251): (1072, "JSMessageObjectMap"),
}
......
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