Commit 93489e76 authored by dslomov@chromium.org's avatar dslomov@chromium.org

Make all global private symbols own symbols.

R=arv@chromium.org, rossberg@chromium.org, wingo@igalia.com, yangguo@chromium.org

Review URL: https://codereview.chromium.org/486763002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23252 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 61446ed0
......@@ -50,7 +50,7 @@ function ArrayIteratorIterator() {
function ArrayIteratorNext() {
var iterator = ToObject(this);
if (!HAS_PRIVATE(iterator, arrayIteratorObjectSymbol)) {
if (!HAS_DEFINED_PRIVATE(iterator, arrayIteratorNextIndexSymbol)) {
throw MakeTypeError('incompatible_method_receiver',
['Array Iterator.prototype.next']);
}
......
......@@ -170,10 +170,11 @@ macro JSON_NUMBER_TO_STRING(arg) = ((%_IsSmi(%IS_VAR(arg)) || arg - arg == 0) ?
# Private names.
# GET_PRIVATE should only be used if the property is known to exists on obj
# itself (it should really use %GetOwnProperty, but that would be way slower).
macro GLOBAL_PRIVATE(name) = (%CreateGlobalPrivateSymbol(name));
macro GLOBAL_PRIVATE(name) = (%CreateGlobalPrivateOwnSymbol(name));
macro NEW_PRIVATE(name) = (%CreatePrivateSymbol(name));
macro IS_PRIVATE(sym) = (%SymbolIsPrivate(sym));
macro HAS_PRIVATE(obj, sym) = (%HasOwnProperty(obj, sym));
macro HAS_DEFINED_PRIVATE(obj, sym) = (!IS_UNDEFINED(obj[sym]));
macro GET_PRIVATE(obj, sym) = (obj[sym]);
macro SET_PRIVATE(obj, sym, val) = (obj[sym] = val);
macro DELETE_PRIVATE(obj, sym) = (delete obj[sym]);
......
......@@ -146,7 +146,7 @@ var lastMicrotaskId = 0;
// For bootstrapper.
IsPromise = function IsPromise(x) {
return IS_SPEC_OBJECT(x) && HAS_PRIVATE(x, promiseStatus);
return IS_SPEC_OBJECT(x) && HAS_DEFINED_PRIVATE(x, promiseStatus);
}
PromiseCreate = function PromiseCreate() {
......@@ -162,7 +162,7 @@ var lastMicrotaskId = 0;
// Check promiseDebug property to avoid duplicate event.
if (DEBUG_IS_ACTIVE &&
GET_PRIVATE(promise, promiseStatus) == 0 &&
!HAS_PRIVATE(promise, promiseDebug)) {
!HAS_DEFINED_PRIVATE(promise, promiseDebug)) {
%DebugPromiseRejectEvent(promise, r);
}
PromiseDone(promise, -1, r, promiseOnReject)
......
......@@ -619,7 +619,7 @@ RUNTIME_FUNCTION(Runtime_CreatePrivateOwnSymbol) {
}
RUNTIME_FUNCTION(Runtime_CreateGlobalPrivateSymbol) {
RUNTIME_FUNCTION(Runtime_CreateGlobalPrivateOwnSymbol) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
......@@ -635,6 +635,7 @@ RUNTIME_FUNCTION(Runtime_CreateGlobalPrivateSymbol) {
DCHECK(symbol->IsUndefined());
symbol = isolate->factory()->NewPrivateSymbol();
Handle<Symbol>::cast(symbol)->set_name(*name);
Handle<Symbol>::cast(symbol)->set_is_own(true);
JSObject::SetProperty(Handle<JSObject>::cast(privates), name, symbol,
STRICT).Assert();
}
......
......@@ -259,7 +259,7 @@ namespace internal {
/* Harmony symbols */ \
F(CreateSymbol, 1, 1) \
F(CreatePrivateSymbol, 1, 1) \
F(CreateGlobalPrivateSymbol, 1, 1) \
F(CreateGlobalPrivateOwnSymbol, 1, 1) \
F(CreatePrivateOwnSymbol, 1, 1) \
F(NewSymbolWrapper, 1, 1) \
F(SymbolDescription, 1, 1) \
......
......@@ -38,7 +38,7 @@ function StringIteratorIterator() {
function StringIteratorNext() {
var iterator = ToObject(this);
if (!HAS_PRIVATE(iterator, stringIteratorIteratedStringSymbol)) {
if (!HAS_DEFINED_PRIVATE(iterator, stringIteratorNextIndexSymbol)) {
throw MakeTypeError('incompatible_method_receiver',
['String Iterator.prototype.next']);
}
......@@ -52,7 +52,8 @@ function StringIteratorNext() {
var length = TO_UINT32(s.length);
if (position >= length) {
SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol, UNDEFINED);
SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol,
UNDEFINED);
return CreateIteratorResultObject(UNDEFINED, true);
}
......
......@@ -2,4 +2,4 @@
// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY
// Flags: --allow-natives-syntax --harmony --harmony-proxies
var _name = "foo";
%CreateGlobalPrivateSymbol(_name);
%CreateGlobalPrivateOwnSymbol(_name);
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