Commit 2cfac65e authored by jochen's avatar jochen Committed by Commit bot

Allow for creating Private API symbols that have a number as an ID

BUG=v8:4933
R=verwaest@chromium.org
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#35692}
parent e5305564
...@@ -6996,7 +6996,7 @@ static i::Handle<i::Symbol> SymbolFor(i::Isolate* isolate, ...@@ -6996,7 +6996,7 @@ static i::Handle<i::Symbol> SymbolFor(i::Isolate* isolate,
else else
symbol = isolate->factory()->NewSymbol(); symbol = isolate->factory()->NewSymbol();
i::Handle<i::Symbol>::cast(symbol)->set_name(*name); i::Handle<i::Symbol>::cast(symbol)->set_name(*name);
i::JSObject::SetProperty(symbols, name, symbol, i::STRICT).Assert(); i::Object::SetPropertyOrElement(symbols, name, symbol, i::STRICT).Assert();
} }
return i::Handle<i::Symbol>::cast(symbol); return i::Handle<i::Symbol>::cast(symbol);
} }
......
...@@ -7034,6 +7034,17 @@ MaybeHandle<Object> Object::GetPropertyOrElement(Handle<Object> object, ...@@ -7034,6 +7034,17 @@ MaybeHandle<Object> Object::GetPropertyOrElement(Handle<Object> object,
return GetProperty(&it); return GetProperty(&it);
} }
MaybeHandle<Object> Object::SetPropertyOrElement(Handle<Object> object,
Handle<Name> name,
Handle<Object> value,
LanguageMode language_mode,
StoreFromKeyed store_mode) {
LookupIterator it =
LookupIterator::PropertyOrElement(name->GetIsolate(), object, name);
MAYBE_RETURN_NULL(SetProperty(&it, value, language_mode, store_mode));
return value;
}
MaybeHandle<Object> Object::GetPropertyOrElement(Handle<Object> receiver, MaybeHandle<Object> Object::GetPropertyOrElement(Handle<Object> receiver,
Handle<Name> name, Handle<Name> name,
Handle<JSReceiver> holder) { Handle<JSReceiver> holder) {
......
...@@ -1241,6 +1241,10 @@ class Object { ...@@ -1241,6 +1241,10 @@ class Object {
Handle<Object> object, Handle<Name> name, Handle<Object> value, Handle<Object> object, Handle<Name> name, Handle<Object> value,
LanguageMode language_mode, LanguageMode language_mode,
StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED); StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED);
MUST_USE_RESULT static inline MaybeHandle<Object> SetPropertyOrElement(
Handle<Object> object, Handle<Name> name, Handle<Object> value,
LanguageMode language_mode,
StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED);
MUST_USE_RESULT static Maybe<bool> SetSuperProperty( MUST_USE_RESULT static Maybe<bool> SetSuperProperty(
LookupIterator* it, Handle<Object> value, LanguageMode language_mode, LookupIterator* it, Handle<Object> value, LanguageMode language_mode,
......
...@@ -25026,3 +25026,12 @@ TEST(SetIntegrityLevel) { ...@@ -25026,3 +25026,12 @@ TEST(SetIntegrityLevel) {
is_frozen = CompileRun("Object.isFrozen(o)"); is_frozen = CompileRun("Object.isFrozen(o)");
CHECK(is_frozen->BooleanValue(context.local()).FromJust()); CHECK(is_frozen->BooleanValue(context.local()).FromJust());
} }
TEST(PrivateForApiIsNumber) {
LocalContext context;
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
// Shouldn't crash.
v8::Private::ForApi(isolate, v8_str("42"));
}
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