[objects] Pass isolate to integrity-level methods
With shared objects we can't get the isolate from the heap object, so we need to pass the isolate as an argument. This CL plumbs the Isolate through the following set of methods on JS{Object,Receiver}: - SetIntegrityLevel - TestIntegrityLevel - PreventExtensions - IsExtensible Notably it does not touch the same methods on JSProxy, because JSProxies are never shared. Bug: v8:12547 Change-Id: I24fcf4b7f9f9d72218ff1f386c34577912a93be1 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4204828 Commit-Queue: Shu-yu Guo <syg@chromium.org> Reviewed-by: Adam Klein <adamk@chromium.org> Cr-Commit-Position: refs/heads/main@{#85551}
This commit is contained in:
parent
24b1878832
commit
8131315998
@ -4915,8 +4915,8 @@ Maybe<bool> v8::Object::SetIntegrityLevel(Local<Context> context,
|
||||
auto self = Utils::OpenHandle(this);
|
||||
i::JSReceiver::IntegrityLevel i_level =
|
||||
level == IntegrityLevel::kFrozen ? i::FROZEN : i::SEALED;
|
||||
Maybe<bool> result =
|
||||
i::JSReceiver::SetIntegrityLevel(self, i_level, i::kThrowOnError);
|
||||
Maybe<bool> result = i::JSReceiver::SetIntegrityLevel(
|
||||
i_isolate, self, i_level, i::kThrowOnError);
|
||||
has_pending_exception = result.IsNothing();
|
||||
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
|
||||
return result;
|
||||
|
@ -52,7 +52,7 @@ BUILTIN(ErrorCaptureStackTrace) {
|
||||
|
||||
// Explicitly check for frozen objects. Other access checks are performed by
|
||||
// the LookupIterator in SetAccessor below.
|
||||
if (!JSObject::IsExtensible(object)) {
|
||||
if (!JSObject::IsExtensible(isolate, object)) {
|
||||
return isolate->Throw(*isolate->factory()->NewTypeError(
|
||||
MessageTemplate::kDefineDisallowed, name));
|
||||
}
|
||||
|
@ -215,9 +215,10 @@ BUILTIN(ObjectFreeze) {
|
||||
HandleScope scope(isolate);
|
||||
Handle<Object> object = args.atOrUndefined(isolate, 1);
|
||||
if (object->IsJSReceiver()) {
|
||||
MAYBE_RETURN(JSReceiver::SetIntegrityLevel(Handle<JSReceiver>::cast(object),
|
||||
FROZEN, kThrowOnError),
|
||||
ReadOnlyRoots(isolate).exception());
|
||||
MAYBE_RETURN(
|
||||
JSReceiver::SetIntegrityLevel(isolate, Handle<JSReceiver>::cast(object),
|
||||
FROZEN, kThrowOnError),
|
||||
ReadOnlyRoots(isolate).exception());
|
||||
}
|
||||
return *object;
|
||||
}
|
||||
@ -295,10 +296,11 @@ BUILTIN(ObjectGetOwnPropertySymbols) {
|
||||
BUILTIN(ObjectIsFrozen) {
|
||||
HandleScope scope(isolate);
|
||||
Handle<Object> object = args.atOrUndefined(isolate, 1);
|
||||
Maybe<bool> result = object->IsJSReceiver()
|
||||
? JSReceiver::TestIntegrityLevel(
|
||||
Handle<JSReceiver>::cast(object), FROZEN)
|
||||
: Just(true);
|
||||
Maybe<bool> result =
|
||||
object->IsJSReceiver()
|
||||
? JSReceiver::TestIntegrityLevel(
|
||||
isolate, Handle<JSReceiver>::cast(object), FROZEN)
|
||||
: Just(true);
|
||||
MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
|
||||
return isolate->heap()->ToBoolean(result.FromJust());
|
||||
}
|
||||
@ -307,10 +309,11 @@ BUILTIN(ObjectIsFrozen) {
|
||||
BUILTIN(ObjectIsSealed) {
|
||||
HandleScope scope(isolate);
|
||||
Handle<Object> object = args.atOrUndefined(isolate, 1);
|
||||
Maybe<bool> result = object->IsJSReceiver()
|
||||
? JSReceiver::TestIntegrityLevel(
|
||||
Handle<JSReceiver>::cast(object), SEALED)
|
||||
: Just(true);
|
||||
Maybe<bool> result =
|
||||
object->IsJSReceiver()
|
||||
? JSReceiver::TestIntegrityLevel(
|
||||
isolate, Handle<JSReceiver>::cast(object), SEALED)
|
||||
: Just(true);
|
||||
MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
|
||||
return isolate->heap()->ToBoolean(result.FromJust());
|
||||
}
|
||||
@ -356,9 +359,10 @@ BUILTIN(ObjectSeal) {
|
||||
HandleScope scope(isolate);
|
||||
Handle<Object> object = args.atOrUndefined(isolate, 1);
|
||||
if (object->IsJSReceiver()) {
|
||||
MAYBE_RETURN(JSReceiver::SetIntegrityLevel(Handle<JSReceiver>::cast(object),
|
||||
SEALED, kThrowOnError),
|
||||
ReadOnlyRoots(isolate).exception());
|
||||
MAYBE_RETURN(
|
||||
JSReceiver::SetIntegrityLevel(isolate, Handle<JSReceiver>::cast(object),
|
||||
SEALED, kThrowOnError),
|
||||
ReadOnlyRoots(isolate).exception());
|
||||
}
|
||||
return *object;
|
||||
}
|
||||
|
@ -2772,7 +2772,8 @@ Handle<JSArray> Factory::NewJSArrayForTemplateLiteralArray(
|
||||
Handle<JSArray> raw_object =
|
||||
NewJSArrayWithElements(raw_strings, PACKED_ELEMENTS,
|
||||
raw_strings->length(), AllocationType::kOld);
|
||||
JSObject::SetIntegrityLevel(raw_object, FROZEN, kThrowOnError).ToChecked();
|
||||
JSObject::SetIntegrityLevel(isolate(), raw_object, FROZEN, kThrowOnError)
|
||||
.ToChecked();
|
||||
|
||||
Handle<NativeContext> native_context = isolate()->native_context();
|
||||
Handle<TemplateLiteralObject> template_object =
|
||||
|
@ -792,7 +792,8 @@ Handle<JSFunction> Genesis::GetThrowTypeErrorIntrinsic() {
|
||||
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY))
|
||||
.Assert();
|
||||
|
||||
if (JSObject::PreventExtensions(function, kThrowOnError).IsNothing()) {
|
||||
if (JSObject::PreventExtensions(isolate_, function, kThrowOnError)
|
||||
.IsNothing()) {
|
||||
DCHECK(false);
|
||||
}
|
||||
|
||||
@ -5895,7 +5896,8 @@ bool Genesis::InstallABunchOfRandomThings() {
|
||||
.ToChecked();
|
||||
|
||||
// Freeze the {template_object} as well.
|
||||
JSObject::SetIntegrityLevel(template_object, FROZEN, kThrowOnError)
|
||||
JSObject::SetIntegrityLevel(isolate(), template_object, FROZEN,
|
||||
kThrowOnError)
|
||||
.ToChecked();
|
||||
{
|
||||
DisallowGarbageCollection no_gc;
|
||||
|
@ -260,7 +260,7 @@ Maybe<bool> JSReceiver::CheckIfCanDefine(Isolate* isolate, LookupIterator* it,
|
||||
NewTypeError(MessageTemplate::kRedefineDisallowed, it->GetName()));
|
||||
}
|
||||
} else if (!JSObject::IsExtensible(
|
||||
Handle<JSObject>::cast(it->GetReceiver()))) {
|
||||
isolate, Handle<JSObject>::cast(it->GetReceiver()))) {
|
||||
RETURN_FAILURE(
|
||||
isolate, GetShouldThrow(isolate, should_throw),
|
||||
NewTypeError(MessageTemplate::kDefineDisallowed, it->GetName()));
|
||||
@ -1437,7 +1437,7 @@ Maybe<bool> JSReceiver::OrdinaryDefineOwnProperty(
|
||||
it->Restart();
|
||||
// 3. Let extensible be the value of the [[Extensible]] internal slot of O.
|
||||
Handle<JSObject> object = Handle<JSObject>::cast(it->GetReceiver());
|
||||
bool extensible = JSObject::IsExtensible(object);
|
||||
bool extensible = JSObject::IsExtensible(isolate, object);
|
||||
|
||||
return ValidateAndApplyPropertyDescriptor(
|
||||
isolate, it, extensible, desc, ¤t, should_throw, Handle<Name>());
|
||||
@ -1939,7 +1939,8 @@ Maybe<bool> JSReceiver::GetOwnPropertyDescriptor(LookupIterator* it,
|
||||
PropertyDescriptor::IsDataDescriptor(desc));
|
||||
return Just(true);
|
||||
}
|
||||
Maybe<bool> JSReceiver::SetIntegrityLevel(Handle<JSReceiver> receiver,
|
||||
Maybe<bool> JSReceiver::SetIntegrityLevel(Isolate* isolate,
|
||||
Handle<JSReceiver> receiver,
|
||||
IntegrityLevel level,
|
||||
ShouldThrow should_throw) {
|
||||
DCHECK(level == SEALED || level == FROZEN);
|
||||
@ -1950,23 +1951,21 @@ Maybe<bool> JSReceiver::SetIntegrityLevel(Handle<JSReceiver> receiver,
|
||||
if (!object->HasSloppyArgumentsElements() &&
|
||||
!object->IsJSModuleNamespace()) { // Fast path.
|
||||
// Prevent memory leaks by not adding unnecessary transitions.
|
||||
Maybe<bool> test = JSObject::TestIntegrityLevel(object, level);
|
||||
Maybe<bool> test = JSObject::TestIntegrityLevel(isolate, object, level);
|
||||
MAYBE_RETURN(test, Nothing<bool>());
|
||||
if (test.FromJust()) return test;
|
||||
|
||||
if (level == SEALED) {
|
||||
return JSObject::PreventExtensionsWithTransition<SEALED>(object,
|
||||
should_throw);
|
||||
return JSObject::PreventExtensionsWithTransition<SEALED>(
|
||||
isolate, object, should_throw);
|
||||
} else {
|
||||
return JSObject::PreventExtensionsWithTransition<FROZEN>(object,
|
||||
should_throw);
|
||||
return JSObject::PreventExtensionsWithTransition<FROZEN>(
|
||||
isolate, object, should_throw);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Isolate* isolate = receiver->GetIsolate();
|
||||
|
||||
MAYBE_RETURN(JSReceiver::PreventExtensions(receiver, should_throw),
|
||||
MAYBE_RETURN(JSReceiver::PreventExtensions(isolate, receiver, should_throw),
|
||||
Nothing<bool>());
|
||||
|
||||
Handle<FixedArray> keys;
|
||||
@ -2011,16 +2010,15 @@ Maybe<bool> JSReceiver::SetIntegrityLevel(Handle<JSReceiver> receiver,
|
||||
}
|
||||
|
||||
namespace {
|
||||
Maybe<bool> GenericTestIntegrityLevel(Handle<JSReceiver> receiver,
|
||||
Maybe<bool> GenericTestIntegrityLevel(Isolate* isolate,
|
||||
Handle<JSReceiver> receiver,
|
||||
PropertyAttributes level) {
|
||||
DCHECK(level == SEALED || level == FROZEN);
|
||||
|
||||
Maybe<bool> extensible = JSReceiver::IsExtensible(receiver);
|
||||
Maybe<bool> extensible = JSReceiver::IsExtensible(isolate, receiver);
|
||||
MAYBE_RETURN(extensible, Nothing<bool>());
|
||||
if (extensible.FromJust()) return Just(false);
|
||||
|
||||
Isolate* isolate = receiver->GetIsolate();
|
||||
|
||||
Handle<FixedArray> keys;
|
||||
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
|
||||
isolate, keys, JSReceiver::OwnPropertyKeys(isolate, receiver),
|
||||
@ -2046,38 +2044,41 @@ Maybe<bool> GenericTestIntegrityLevel(Handle<JSReceiver> receiver,
|
||||
|
||||
} // namespace
|
||||
|
||||
Maybe<bool> JSReceiver::TestIntegrityLevel(Handle<JSReceiver> receiver,
|
||||
Maybe<bool> JSReceiver::TestIntegrityLevel(Isolate* isolate,
|
||||
Handle<JSReceiver> receiver,
|
||||
IntegrityLevel level) {
|
||||
if (!receiver->map().IsCustomElementsReceiverMap()) {
|
||||
return JSObject::TestIntegrityLevel(Handle<JSObject>::cast(receiver),
|
||||
level);
|
||||
return JSObject::TestIntegrityLevel(
|
||||
isolate, Handle<JSObject>::cast(receiver), level);
|
||||
}
|
||||
return GenericTestIntegrityLevel(receiver, level);
|
||||
return GenericTestIntegrityLevel(isolate, receiver, level);
|
||||
}
|
||||
|
||||
Maybe<bool> JSReceiver::PreventExtensions(Handle<JSReceiver> object,
|
||||
Maybe<bool> JSReceiver::PreventExtensions(Isolate* isolate,
|
||||
Handle<JSReceiver> object,
|
||||
ShouldThrow should_throw) {
|
||||
if (object->IsJSProxy()) {
|
||||
return JSProxy::PreventExtensions(Handle<JSProxy>::cast(object),
|
||||
should_throw);
|
||||
}
|
||||
if (object->IsWasmObject()) {
|
||||
RETURN_FAILURE(object->GetIsolate(), kThrowOnError,
|
||||
RETURN_FAILURE(isolate, kThrowOnError,
|
||||
NewTypeError(MessageTemplate::kWasmObjectsAreOpaque));
|
||||
}
|
||||
DCHECK(object->IsJSObject());
|
||||
return JSObject::PreventExtensions(Handle<JSObject>::cast(object),
|
||||
return JSObject::PreventExtensions(isolate, Handle<JSObject>::cast(object),
|
||||
should_throw);
|
||||
}
|
||||
|
||||
Maybe<bool> JSReceiver::IsExtensible(Handle<JSReceiver> object) {
|
||||
Maybe<bool> JSReceiver::IsExtensible(Isolate* isolate,
|
||||
Handle<JSReceiver> object) {
|
||||
if (object->IsJSProxy()) {
|
||||
return JSProxy::IsExtensible(Handle<JSProxy>::cast(object));
|
||||
}
|
||||
if (object->IsWasmObject()) {
|
||||
return Just(false);
|
||||
}
|
||||
return Just(JSObject::IsExtensible(Handle<JSObject>::cast(object)));
|
||||
return Just(JSObject::IsExtensible(isolate, Handle<JSObject>::cast(object)));
|
||||
}
|
||||
|
||||
// static
|
||||
@ -4184,21 +4185,22 @@ bool FastTestIntegrityLevel(JSObject object, PropertyAttributes level) {
|
||||
|
||||
} // namespace
|
||||
|
||||
Maybe<bool> JSObject::TestIntegrityLevel(Handle<JSObject> object,
|
||||
Maybe<bool> JSObject::TestIntegrityLevel(Isolate* isolate,
|
||||
Handle<JSObject> object,
|
||||
IntegrityLevel level) {
|
||||
if (!object->map().IsCustomElementsReceiverMap() &&
|
||||
!object->HasSloppyArgumentsElements()) {
|
||||
return Just(FastTestIntegrityLevel(*object, level));
|
||||
}
|
||||
return GenericTestIntegrityLevel(Handle<JSReceiver>::cast(object), level);
|
||||
return GenericTestIntegrityLevel(isolate, Handle<JSReceiver>::cast(object),
|
||||
level);
|
||||
}
|
||||
|
||||
Maybe<bool> JSObject::PreventExtensions(Handle<JSObject> object,
|
||||
Maybe<bool> JSObject::PreventExtensions(Isolate* isolate,
|
||||
Handle<JSObject> object,
|
||||
ShouldThrow should_throw) {
|
||||
Isolate* isolate = object->GetIsolate();
|
||||
|
||||
if (!object->HasSloppyArgumentsElements()) {
|
||||
return PreventExtensionsWithTransition<NONE>(object, should_throw);
|
||||
return PreventExtensionsWithTransition<NONE>(isolate, object, should_throw);
|
||||
}
|
||||
|
||||
if (object->IsAccessCheckNeeded() &&
|
||||
@ -4215,8 +4217,8 @@ Maybe<bool> JSObject::PreventExtensions(Handle<JSObject> object,
|
||||
PrototypeIterator iter(isolate, object);
|
||||
if (iter.IsAtEnd()) return Just(true);
|
||||
DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject());
|
||||
return PreventExtensions(PrototypeIterator::GetCurrent<JSObject>(iter),
|
||||
should_throw);
|
||||
return PreventExtensions(
|
||||
isolate, PrototypeIterator::GetCurrent<JSObject>(iter), should_throw);
|
||||
}
|
||||
|
||||
if (object->map().has_named_interceptor() ||
|
||||
@ -4249,8 +4251,7 @@ Maybe<bool> JSObject::PreventExtensions(Handle<JSObject> object,
|
||||
return Just(true);
|
||||
}
|
||||
|
||||
bool JSObject::IsExtensible(Handle<JSObject> object) {
|
||||
Isolate* isolate = object->GetIsolate();
|
||||
bool JSObject::IsExtensible(Isolate* isolate, Handle<JSObject> object) {
|
||||
if (object->IsAccessCheckNeeded() &&
|
||||
!isolate->MayAccess(handle(isolate->context(), isolate), object)) {
|
||||
return true;
|
||||
@ -4317,7 +4318,7 @@ Handle<NumberDictionary> CreateElementDictionary(Isolate* isolate,
|
||||
|
||||
template <PropertyAttributes attrs>
|
||||
Maybe<bool> JSObject::PreventExtensionsWithTransition(
|
||||
Handle<JSObject> object, ShouldThrow should_throw) {
|
||||
Isolate* isolate, Handle<JSObject> object, ShouldThrow should_throw) {
|
||||
static_assert(attrs == NONE || attrs == SEALED || attrs == FROZEN);
|
||||
|
||||
// Sealing/freezing sloppy arguments or namespace objects should be handled
|
||||
@ -4325,7 +4326,6 @@ Maybe<bool> JSObject::PreventExtensionsWithTransition(
|
||||
DCHECK(!object->HasSloppyArgumentsElements());
|
||||
DCHECK_IMPLIES(object->IsJSModuleNamespace(), attrs == NONE);
|
||||
|
||||
Isolate* isolate = object->GetIsolate();
|
||||
if (object->IsAccessCheckNeeded() &&
|
||||
!isolate->MayAccess(handle(isolate->context(), isolate), object)) {
|
||||
isolate->ReportFailedAccessCheck(object);
|
||||
@ -4351,7 +4351,7 @@ Maybe<bool> JSObject::PreventExtensionsWithTransition(
|
||||
if (iter.IsAtEnd()) return Just(true);
|
||||
DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject());
|
||||
return PreventExtensionsWithTransition<attrs>(
|
||||
PrototypeIterator::GetCurrent<JSObject>(iter), should_throw);
|
||||
isolate, PrototypeIterator::GetCurrent<JSObject>(iter), should_throw);
|
||||
}
|
||||
|
||||
if (object->map().has_named_interceptor() ||
|
||||
|
@ -222,19 +222,20 @@ class JSReceiver : public TorqueGeneratedJSReceiver<JSReceiver, HeapObject> {
|
||||
// ES6 7.3.14 (when passed kDontThrow)
|
||||
// 'level' must be SEALED or FROZEN.
|
||||
V8_WARN_UNUSED_RESULT static Maybe<bool> SetIntegrityLevel(
|
||||
Handle<JSReceiver> object, IntegrityLevel lvl, ShouldThrow should_throw);
|
||||
Isolate* isolate, Handle<JSReceiver> object, IntegrityLevel lvl,
|
||||
ShouldThrow should_throw);
|
||||
|
||||
// ES6 7.3.15
|
||||
// 'level' must be SEALED or FROZEN.
|
||||
V8_WARN_UNUSED_RESULT static Maybe<bool> TestIntegrityLevel(
|
||||
Handle<JSReceiver> object, IntegrityLevel lvl);
|
||||
Isolate* isolate, Handle<JSReceiver> object, IntegrityLevel lvl);
|
||||
|
||||
// ES6 [[PreventExtensions]] (when passed kDontThrow)
|
||||
V8_WARN_UNUSED_RESULT static Maybe<bool> PreventExtensions(
|
||||
Handle<JSReceiver> object, ShouldThrow should_throw);
|
||||
Isolate* isolate, Handle<JSReceiver> object, ShouldThrow should_throw);
|
||||
|
||||
V8_WARN_UNUSED_RESULT static Maybe<bool> IsExtensible(
|
||||
Handle<JSReceiver> object);
|
||||
Isolate* isolate, Handle<JSReceiver> object);
|
||||
|
||||
// Returns the class name.
|
||||
V8_EXPORT_PRIVATE String class_name();
|
||||
@ -753,12 +754,12 @@ class JSObject : public TorqueGeneratedJSObject<JSObject, JSReceiver> {
|
||||
bool ReferencesObject(Object obj);
|
||||
|
||||
V8_WARN_UNUSED_RESULT static Maybe<bool> TestIntegrityLevel(
|
||||
Handle<JSObject> object, IntegrityLevel lvl);
|
||||
Isolate* isolate, Handle<JSObject> object, IntegrityLevel lvl);
|
||||
|
||||
V8_WARN_UNUSED_RESULT static Maybe<bool> PreventExtensions(
|
||||
Handle<JSObject> object, ShouldThrow should_throw);
|
||||
Isolate* isolate, Handle<JSObject> object, ShouldThrow should_throw);
|
||||
|
||||
static bool IsExtensible(Handle<JSObject> object);
|
||||
static bool IsExtensible(Isolate* isolate, Handle<JSObject> object);
|
||||
|
||||
static MaybeHandle<Object> ReadFromOptionsBag(Handle<Object> options,
|
||||
Handle<String> option_name,
|
||||
@ -901,7 +902,7 @@ class JSObject : public TorqueGeneratedJSObject<JSObject, JSReceiver> {
|
||||
// attrs is one of NONE, SEALED, or FROZEN (depending on the operation).
|
||||
template <PropertyAttributes attrs>
|
||||
V8_WARN_UNUSED_RESULT static Maybe<bool> PreventExtensionsWithTransition(
|
||||
Handle<JSObject> object, ShouldThrow should_throw);
|
||||
Isolate* isolate, Handle<JSObject> object, ShouldThrow should_throw);
|
||||
|
||||
TQ_OBJECT_CONSTRUCTORS(JSObject)
|
||||
};
|
||||
|
@ -34,7 +34,7 @@ MaybeHandle<JSRawJson> JSRawJson::Create(Isolate* isolate,
|
||||
Handle<JSObject> result =
|
||||
isolate->factory()->NewJSObjectFromMap(isolate->js_raw_json_map());
|
||||
result->InObjectPropertyAtPut(JSRawJson::kRawJsonIndex, *json_string);
|
||||
JSObject::SetIntegrityLevel(result, FROZEN, kThrowOnError).Check();
|
||||
JSObject::SetIntegrityLevel(isolate, result, FROZEN, kThrowOnError).Check();
|
||||
return Handle<JSRawJson>::cast(result);
|
||||
}
|
||||
|
||||
|
@ -1290,7 +1290,7 @@ Maybe<bool> KeyAccumulator::CollectOwnJSProxyKeys(Handle<JSReceiver> receiver,
|
||||
}
|
||||
}
|
||||
// 10. Let extensibleTarget be ? IsExtensible(target).
|
||||
Maybe<bool> maybe_extensible = JSReceiver::IsExtensible(target);
|
||||
Maybe<bool> maybe_extensible = JSReceiver::IsExtensible(isolate_, target);
|
||||
MAYBE_RETURN(maybe_extensible, Nothing<bool>());
|
||||
bool extensible_target = maybe_extensible.FromJust();
|
||||
// 11. Let targetKeys be ? target.[[OwnPropertyKeys]]().
|
||||
|
@ -346,7 +346,7 @@ Handle<JSModuleNamespace> Module::GetModuleNamespace(Isolate* isolate,
|
||||
PropertyCellType::kMutable));
|
||||
}
|
||||
}
|
||||
JSObject::PreventExtensions(ns, kThrowOnError).ToChecked();
|
||||
JSObject::PreventExtensions(isolate, ns, kThrowOnError).ToChecked();
|
||||
|
||||
// Optimize the namespace object as a prototype, for two reasons:
|
||||
// - The object's map is guaranteed not to be shared. ICs rely on this.
|
||||
|
@ -1382,7 +1382,7 @@ MaybeHandle<HeapObject> JSProxy::GetPrototype(Handle<JSProxy> proxy) {
|
||||
HeapObject);
|
||||
}
|
||||
// 9. Let extensibleTarget be ? IsExtensible(target).
|
||||
Maybe<bool> is_extensible = JSReceiver::IsExtensible(target);
|
||||
Maybe<bool> is_extensible = JSReceiver::IsExtensible(isolate, target);
|
||||
MAYBE_RETURN(is_extensible, MaybeHandle<HeapObject>());
|
||||
// 10. If extensibleTarget is true, return handlerProto.
|
||||
if (is_extensible.FromJust()) return Handle<HeapObject>::cast(handler_proto);
|
||||
@ -3092,7 +3092,7 @@ Maybe<bool> JSProxy::CheckHasTrap(Isolate* isolate, Handle<Name> name,
|
||||
return Nothing<bool>();
|
||||
}
|
||||
// 9b ii. Let extensibleTarget be ? IsExtensible(target).
|
||||
Maybe<bool> extensible_target = JSReceiver::IsExtensible(target);
|
||||
Maybe<bool> extensible_target = JSReceiver::IsExtensible(isolate, target);
|
||||
MAYBE_RETURN(extensible_target, Nothing<bool>());
|
||||
// 9b iii. If extensibleTarget is false, throw a TypeError exception.
|
||||
if (!extensible_target.FromJust()) {
|
||||
@ -3211,7 +3211,7 @@ Maybe<bool> JSProxy::CheckDeleteTrap(Isolate* isolate, Handle<Name> name,
|
||||
return Nothing<bool>();
|
||||
}
|
||||
// 13. Let extensibleTarget be ? IsExtensible(target).
|
||||
Maybe<bool> extensible_target = JSReceiver::IsExtensible(target);
|
||||
Maybe<bool> extensible_target = JSReceiver::IsExtensible(isolate, target);
|
||||
MAYBE_RETURN(extensible_target, Nothing<bool>());
|
||||
// 14. If extensibleTarget is false, throw a TypeError exception.
|
||||
if (!extensible_target.FromJust()) {
|
||||
@ -3519,7 +3519,7 @@ Maybe<bool> JSProxy::DefineOwnProperty(Isolate* isolate, Handle<JSProxy> proxy,
|
||||
JSReceiver::GetOwnPropertyDescriptor(isolate, target, key, &target_desc);
|
||||
MAYBE_RETURN(target_found, Nothing<bool>());
|
||||
// 12. Let extensibleTarget be ? IsExtensible(target).
|
||||
Maybe<bool> maybe_extensible = JSReceiver::IsExtensible(target);
|
||||
Maybe<bool> maybe_extensible = JSReceiver::IsExtensible(isolate, target);
|
||||
MAYBE_RETURN(maybe_extensible, Nothing<bool>());
|
||||
bool extensible_target = maybe_extensible.FromJust();
|
||||
// 13. If Desc has a [[Configurable]] field and if Desc.[[Configurable]]
|
||||
@ -3692,7 +3692,7 @@ Maybe<bool> JSProxy::GetOwnPropertyDescriptor(Isolate* isolate,
|
||||
return Nothing<bool>();
|
||||
}
|
||||
// 11c. Let extensibleTarget be ? IsExtensible(target).
|
||||
Maybe<bool> extensible_target = JSReceiver::IsExtensible(target);
|
||||
Maybe<bool> extensible_target = JSReceiver::IsExtensible(isolate, target);
|
||||
MAYBE_RETURN(extensible_target, Nothing<bool>());
|
||||
// 11d. (Assert)
|
||||
// 11e. If extensibleTarget is false, throw a TypeError exception.
|
||||
@ -3705,7 +3705,7 @@ Maybe<bool> JSProxy::GetOwnPropertyDescriptor(Isolate* isolate,
|
||||
return Just(false);
|
||||
}
|
||||
// 12. Let extensibleTarget be ? IsExtensible(target).
|
||||
Maybe<bool> extensible_target = JSReceiver::IsExtensible(target);
|
||||
Maybe<bool> extensible_target = JSReceiver::IsExtensible(isolate, target);
|
||||
MAYBE_RETURN(extensible_target, Nothing<bool>());
|
||||
// 13. Let resultDesc be ? ToPropertyDescriptor(trapResultObj).
|
||||
if (!PropertyDescriptor::ToPropertyDescriptor(isolate, trap_result_obj,
|
||||
@ -3773,7 +3773,7 @@ Maybe<bool> JSProxy::PreventExtensions(Handle<JSProxy> proxy,
|
||||
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
|
||||
isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>());
|
||||
if (trap->IsUndefined(isolate)) {
|
||||
return JSReceiver::PreventExtensions(target, should_throw);
|
||||
return JSReceiver::PreventExtensions(isolate, target, should_throw);
|
||||
}
|
||||
|
||||
Handle<Object> trap_result;
|
||||
@ -3789,7 +3789,7 @@ Maybe<bool> JSProxy::PreventExtensions(Handle<JSProxy> proxy,
|
||||
}
|
||||
|
||||
// Enforce the invariant.
|
||||
Maybe<bool> target_result = JSReceiver::IsExtensible(target);
|
||||
Maybe<bool> target_result = JSReceiver::IsExtensible(isolate, target);
|
||||
MAYBE_RETURN(target_result, Nothing<bool>());
|
||||
if (target_result.FromJust()) {
|
||||
isolate->Throw(*factory->NewTypeError(
|
||||
@ -3817,7 +3817,7 @@ Maybe<bool> JSProxy::IsExtensible(Handle<JSProxy> proxy) {
|
||||
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
|
||||
isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>());
|
||||
if (trap->IsUndefined(isolate)) {
|
||||
return JSReceiver::IsExtensible(target);
|
||||
return JSReceiver::IsExtensible(isolate, target);
|
||||
}
|
||||
|
||||
Handle<Object> trap_result;
|
||||
@ -3828,7 +3828,7 @@ Maybe<bool> JSProxy::IsExtensible(Handle<JSProxy> proxy) {
|
||||
Nothing<bool>());
|
||||
|
||||
// Enforce the invariant.
|
||||
Maybe<bool> target_result = JSReceiver::IsExtensible(target);
|
||||
Maybe<bool> target_result = JSReceiver::IsExtensible(isolate, target);
|
||||
MAYBE_RETURN(target_result, Nothing<bool>());
|
||||
if (target_result.FromJust() != trap_result->BooleanValue(isolate)) {
|
||||
isolate->Throw(
|
||||
@ -5291,7 +5291,7 @@ Maybe<bool> JSProxy::SetPrototype(Isolate* isolate, Handle<JSProxy> proxy,
|
||||
NewTypeError(MessageTemplate::kProxyTrapReturnedFalsish, trap_name));
|
||||
}
|
||||
// 10. Let extensibleTarget be ? IsExtensible(target).
|
||||
Maybe<bool> is_extensible = JSReceiver::IsExtensible(target);
|
||||
Maybe<bool> is_extensible = JSReceiver::IsExtensible(isolate, target);
|
||||
if (is_extensible.IsNothing()) return Nothing<bool>();
|
||||
// 11. If extensibleTarget is true, return true.
|
||||
if (is_extensible.FromJust()) {
|
||||
|
@ -702,7 +702,7 @@ RUNTIME_FUNCTION(Runtime_ObjectIsExtensible) {
|
||||
|
||||
Maybe<bool> result =
|
||||
object->IsJSReceiver()
|
||||
? JSReceiver::IsExtensible(Handle<JSReceiver>::cast(object))
|
||||
? JSReceiver::IsExtensible(isolate, Handle<JSReceiver>::cast(object))
|
||||
: Just(false);
|
||||
MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
|
||||
return isolate->heap()->ToBoolean(result.FromJust());
|
||||
@ -713,8 +713,8 @@ RUNTIME_FUNCTION(Runtime_JSReceiverPreventExtensionsThrow) {
|
||||
DCHECK_EQ(1, args.length());
|
||||
Handle<JSReceiver> object = args.at<JSReceiver>(0);
|
||||
|
||||
MAYBE_RETURN(JSReceiver::PreventExtensions(Handle<JSReceiver>::cast(object),
|
||||
kThrowOnError),
|
||||
MAYBE_RETURN(JSReceiver::PreventExtensions(
|
||||
isolate, Handle<JSReceiver>::cast(object), kThrowOnError),
|
||||
ReadOnlyRoots(isolate).exception());
|
||||
return *object;
|
||||
}
|
||||
@ -725,7 +725,7 @@ RUNTIME_FUNCTION(Runtime_JSReceiverPreventExtensionsDontThrow) {
|
||||
Handle<JSReceiver> object = args.at<JSReceiver>(0);
|
||||
|
||||
Maybe<bool> result = JSReceiver::PreventExtensions(
|
||||
Handle<JSReceiver>::cast(object), kDontThrow);
|
||||
isolate, Handle<JSReceiver>::cast(object), kDontThrow);
|
||||
MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
|
||||
return *isolate->factory()->ToBoolean(result.FromJust());
|
||||
}
|
||||
|
@ -1933,8 +1933,8 @@ void InstanceBuilder::ProcessExports(Handle<WasmInstanceObject> instance) {
|
||||
}
|
||||
|
||||
if (module_->origin == kWasmOrigin) {
|
||||
v8::Maybe<bool> success =
|
||||
JSReceiver::SetIntegrityLevel(exports_object, FROZEN, kDontThrow);
|
||||
v8::Maybe<bool> success = JSReceiver::SetIntegrityLevel(
|
||||
isolate_, exports_object, FROZEN, kDontThrow);
|
||||
DCHECK(success.FromMaybe(false));
|
||||
USE(success);
|
||||
}
|
||||
|
@ -1357,7 +1357,7 @@ void WebAssemblyMemory(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
i::Handle<i::WasmMemoryObject>::cast(memory_obj)->array_buffer(),
|
||||
i_isolate);
|
||||
Maybe<bool> result =
|
||||
buffer->SetIntegrityLevel(buffer, i::FROZEN, i::kDontThrow);
|
||||
buffer->SetIntegrityLevel(i_isolate, buffer, i::FROZEN, i::kDontThrow);
|
||||
if (!result.FromJust()) {
|
||||
thrower.TypeError(
|
||||
"Status of setting SetIntegrityLevel of buffer is false.");
|
||||
@ -2424,7 +2424,7 @@ void WebAssemblyMemoryGetBuffer(
|
||||
// buffer are out of sync, handle that here when bounds checks, and Grow
|
||||
// are handled correctly.
|
||||
Maybe<bool> result =
|
||||
buffer->SetIntegrityLevel(buffer, i::FROZEN, i::kDontThrow);
|
||||
buffer->SetIntegrityLevel(i_isolate, buffer, i::FROZEN, i::kDontThrow);
|
||||
if (!result.FromJust()) {
|
||||
thrower.TypeError(
|
||||
"Status of setting SetIntegrityLevel of buffer is false.");
|
||||
|
Loading…
Reference in New Issue
Block a user