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}
This commit is contained in:
jochen 2016-04-21 02:48:58 -07:00 committed by Commit bot
parent e530556471
commit 2cfac65eac
4 changed files with 25 additions and 1 deletions

View File

@ -6996,7 +6996,7 @@ static i::Handle<i::Symbol> SymbolFor(i::Isolate* isolate,
else
symbol = isolate->factory()->NewSymbol();
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);
}

View File

@ -7034,6 +7034,17 @@ MaybeHandle<Object> Object::GetPropertyOrElement(Handle<Object> object,
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,
Handle<Name> name,
Handle<JSReceiver> holder) {

View File

@ -1241,6 +1241,10 @@ class Object {
Handle<Object> object, Handle<Name> name, Handle<Object> value,
LanguageMode language_mode,
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(
LookupIterator* it, Handle<Object> value, LanguageMode language_mode,

View File

@ -25026,3 +25026,12 @@ TEST(SetIntegrityLevel) {
is_frozen = CompileRun("Object.isFrozen(o)");
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"));
}