Plumb Isolate through HasProperty and friends
Currently the Isolate is gotten off of the object that the operation is being performed on. Shared objects return the shared Isolate, which is incorrect as it shouldn't be used to run JS, nor does it have HandleScopes open. Plumb the executing Isolate through. Bug: v8:12547 Change-Id: I52d5a172ea602f4ad058d979003d51a80cdb4405 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3441022 Reviewed-by: Adam Klein <adamk@chromium.org> Commit-Queue: Shu-yu Guo <syg@chromium.org> Cr-Commit-Position: refs/heads/main@{#78961}
This commit is contained in:
parent
d4baeee65f
commit
33457e544a
@ -2895,7 +2895,7 @@ MaybeLocal<Value> v8::TryCatch::StackTrace(Local<Context> context,
|
||||
PREPARE_FOR_EXECUTION(context, TryCatch, StackTrace, Value);
|
||||
auto obj = i::Handle<i::JSObject>::cast(i_exception);
|
||||
i::Handle<i::String> name = isolate->factory()->stack_string();
|
||||
Maybe<bool> maybe = i::JSReceiver::HasProperty(obj, name);
|
||||
Maybe<bool> maybe = i::JSReceiver::HasProperty(isolate, obj, name);
|
||||
has_pending_exception = maybe.IsNothing();
|
||||
RETURN_ON_FAILED_EXECUTION(Value);
|
||||
if (!maybe.FromJust()) return v8::Local<Value>();
|
||||
@ -4748,12 +4748,12 @@ Maybe<bool> v8::Object::Has(Local<Context> context, Local<Value> key) {
|
||||
// Check if the given key is an array index.
|
||||
uint32_t index = 0;
|
||||
if (key_obj->ToArrayIndex(&index)) {
|
||||
maybe = i::JSReceiver::HasElement(self, index);
|
||||
maybe = i::JSReceiver::HasElement(isolate, self, index);
|
||||
} else {
|
||||
// Convert the key to a name - possibly by calling back into JavaScript.
|
||||
i::Handle<i::Name> name;
|
||||
if (i::Object::ToName(isolate, key_obj).ToHandle(&name)) {
|
||||
maybe = i::JSReceiver::HasProperty(self, name);
|
||||
maybe = i::JSReceiver::HasProperty(isolate, self, name);
|
||||
}
|
||||
}
|
||||
has_pending_exception = maybe.IsNothing();
|
||||
@ -4779,7 +4779,7 @@ Maybe<bool> v8::Object::Has(Local<Context> context, uint32_t index) {
|
||||
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
|
||||
ENTER_V8(isolate, context, Object, Has, Nothing<bool>(), i::HandleScope);
|
||||
auto self = Utils::OpenHandle(this);
|
||||
auto maybe = i::JSReceiver::HasElement(self, index);
|
||||
auto maybe = i::JSReceiver::HasElement(isolate, self, index);
|
||||
has_pending_exception = maybe.IsNothing();
|
||||
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
|
||||
return maybe;
|
||||
@ -4882,7 +4882,7 @@ Maybe<bool> v8::Object::HasOwnProperty(Local<Context> context,
|
||||
i::HandleScope);
|
||||
auto self = Utils::OpenHandle(this);
|
||||
auto key_val = Utils::OpenHandle(*key);
|
||||
auto result = i::JSReceiver::HasOwnProperty(self, key_val);
|
||||
auto result = i::JSReceiver::HasOwnProperty(isolate, self, key_val);
|
||||
has_pending_exception = result.IsNothing();
|
||||
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
|
||||
return result;
|
||||
@ -4893,7 +4893,7 @@ Maybe<bool> v8::Object::HasOwnProperty(Local<Context> context, uint32_t index) {
|
||||
ENTER_V8(isolate, context, Object, HasOwnProperty, Nothing<bool>(),
|
||||
i::HandleScope);
|
||||
auto self = Utils::OpenHandle(this);
|
||||
auto result = i::JSReceiver::HasOwnProperty(self, index);
|
||||
auto result = i::JSReceiver::HasOwnProperty(isolate, self, index);
|
||||
has_pending_exception = result.IsNothing();
|
||||
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
|
||||
return result;
|
||||
@ -4908,7 +4908,7 @@ Maybe<bool> v8::Object::HasRealNamedProperty(Local<Context> context,
|
||||
if (!self->IsJSObject()) return Just(false);
|
||||
auto key_val = Utils::OpenHandle(*key);
|
||||
auto result = i::JSObject::HasRealNamedProperty(
|
||||
i::Handle<i::JSObject>::cast(self), key_val);
|
||||
isolate, i::Handle<i::JSObject>::cast(self), key_val);
|
||||
has_pending_exception = result.IsNothing();
|
||||
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
|
||||
return result;
|
||||
@ -4922,7 +4922,7 @@ Maybe<bool> v8::Object::HasRealIndexedProperty(Local<Context> context,
|
||||
auto self = Utils::OpenHandle(this);
|
||||
if (!self->IsJSObject()) return Just(false);
|
||||
auto result = i::JSObject::HasRealElementProperty(
|
||||
i::Handle<i::JSObject>::cast(self), index);
|
||||
isolate, i::Handle<i::JSObject>::cast(self), index);
|
||||
has_pending_exception = result.IsNothing();
|
||||
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
|
||||
return result;
|
||||
@ -4937,7 +4937,7 @@ Maybe<bool> v8::Object::HasRealNamedCallbackProperty(Local<Context> context,
|
||||
if (!self->IsJSObject()) return Just(false);
|
||||
auto key_val = Utils::OpenHandle(*key);
|
||||
auto result = i::JSObject::HasRealNamedCallbackProperty(
|
||||
i::Handle<i::JSObject>::cast(self), key_val);
|
||||
isolate, i::Handle<i::JSObject>::cast(self), key_val);
|
||||
has_pending_exception = result.IsNothing();
|
||||
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
|
||||
return result;
|
||||
|
@ -537,7 +537,8 @@ V8_WARN_UNUSED_RESULT Object GenericArrayShift(Isolate* isolate,
|
||||
// c. Let fromPresent be ? HasProperty(O, from).
|
||||
bool from_present;
|
||||
MAYBE_ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
|
||||
isolate, from_present, JSReceiver::HasProperty(receiver, from));
|
||||
isolate, from_present,
|
||||
JSReceiver::HasProperty(isolate, receiver, from));
|
||||
|
||||
// d. If fromPresent is true, then.
|
||||
if (from_present) {
|
||||
@ -1046,7 +1047,7 @@ void CollectElementIndices(Isolate* isolate, Handle<JSObject> object,
|
||||
bool IterateElementsSlow(Isolate* isolate, Handle<JSReceiver> receiver,
|
||||
uint32_t length, ArrayConcatVisitor* visitor) {
|
||||
FOR_WITH_HANDLE_SCOPE(isolate, uint32_t, i = 0, i, i < length, ++i, {
|
||||
Maybe<bool> maybe = JSReceiver::HasElement(receiver, i);
|
||||
Maybe<bool> maybe = JSReceiver::HasElement(isolate, receiver, i);
|
||||
if (maybe.IsNothing()) return false;
|
||||
if (maybe.FromJust()) {
|
||||
Handle<Object> element_value;
|
||||
@ -1123,7 +1124,7 @@ bool IterateElements(Isolate* isolate, Handle<JSReceiver> receiver,
|
||||
if (!element_value->IsTheHole(isolate)) {
|
||||
if (!visitor->visit(j, element_value)) return false;
|
||||
} else {
|
||||
Maybe<bool> maybe = JSReceiver::HasElement(array, j);
|
||||
Maybe<bool> maybe = JSReceiver::HasElement(isolate, array, j);
|
||||
if (maybe.IsNothing()) return false;
|
||||
if (maybe.FromJust()) {
|
||||
// Call GetElement on array, not its prototype, or getters won't
|
||||
@ -1161,7 +1162,7 @@ bool IterateElements(Isolate* isolate, Handle<JSReceiver> receiver,
|
||||
isolate->factory()->NewNumber(double_value);
|
||||
if (!visitor->visit(j, element_value)) return false;
|
||||
} else {
|
||||
Maybe<bool> maybe = JSReceiver::HasElement(array, j);
|
||||
Maybe<bool> maybe = JSReceiver::HasElement(isolate, array, j);
|
||||
if (maybe.IsNothing()) return false;
|
||||
if (maybe.FromJust()) {
|
||||
// Call GetElement on array, not its prototype, or getters won't
|
||||
|
@ -565,7 +565,7 @@ Handle<JSObject> ScopeIterator::ScopeObject(Mode mode) {
|
||||
if (value->IsTheHole(isolate_)) {
|
||||
// Reflect variables under TDZ as undefined in scope object.
|
||||
if (scope_type == ScopeTypeScript &&
|
||||
JSReceiver::HasOwnProperty(scope, name).FromMaybe(true)) {
|
||||
JSReceiver::HasOwnProperty(isolate_, scope, name).FromMaybe(true)) {
|
||||
// We also use the hole to represent overridden let-declarations via
|
||||
// REPL mode in a script context. Catch this case.
|
||||
return false;
|
||||
|
@ -2765,7 +2765,8 @@ void Isolate::InstallConditionalFeatures(Handle<Context> context) {
|
||||
Handle<JSGlobalObject> global = handle(context->global_object(), this);
|
||||
Handle<String> sab_name = factory()->SharedArrayBuffer_string();
|
||||
if (IsSharedArrayBufferConstructorEnabled(context)) {
|
||||
if (!JSObject::HasRealNamedProperty(global, sab_name).FromMaybe(true)) {
|
||||
if (!JSObject::HasRealNamedProperty(this, global, sab_name)
|
||||
.FromMaybe(true)) {
|
||||
JSObject::AddProperty(this, global, factory()->SharedArrayBuffer_string(),
|
||||
shared_array_buffer_fun(), DONT_ENUM);
|
||||
}
|
||||
|
@ -557,7 +557,8 @@ MaybeHandle<JSObject> ErrorUtils::Construct(
|
||||
Handle<Name> cause_string = isolate->factory()->cause_string();
|
||||
if (options->IsJSReceiver()) {
|
||||
Handle<JSReceiver> js_options = Handle<JSReceiver>::cast(options);
|
||||
Maybe<bool> has_cause = JSObject::HasProperty(js_options, cause_string);
|
||||
Maybe<bool> has_cause =
|
||||
JSObject::HasProperty(isolate, js_options, cause_string);
|
||||
if (has_cause.IsNothing()) {
|
||||
DCHECK((isolate)->has_pending_exception());
|
||||
return MaybeHandle<JSObject>();
|
||||
|
@ -707,19 +707,18 @@ DEF_GETTER(JSReceiver, property_array, PropertyArray) {
|
||||
return PropertyArray::cast(prop);
|
||||
}
|
||||
|
||||
Maybe<bool> JSReceiver::HasProperty(Handle<JSReceiver> object,
|
||||
Maybe<bool> JSReceiver::HasProperty(Isolate* isolate, Handle<JSReceiver> object,
|
||||
Handle<Name> name) {
|
||||
Isolate* isolate = object->GetIsolate();
|
||||
PropertyKey key(isolate, name);
|
||||
LookupIterator it(isolate, object, key, object);
|
||||
return HasProperty(&it);
|
||||
}
|
||||
|
||||
Maybe<bool> JSReceiver::HasOwnProperty(Handle<JSReceiver> object,
|
||||
Maybe<bool> JSReceiver::HasOwnProperty(Isolate* isolate,
|
||||
Handle<JSReceiver> object,
|
||||
uint32_t index) {
|
||||
if (object->IsJSObject()) { // Shortcut.
|
||||
LookupIterator it(object->GetIsolate(), object, index, object,
|
||||
LookupIterator::OWN);
|
||||
LookupIterator it(isolate, object, index, object, LookupIterator::OWN);
|
||||
return HasProperty(&it);
|
||||
}
|
||||
|
||||
@ -752,8 +751,9 @@ Maybe<PropertyAttributes> JSReceiver::GetOwnPropertyAttributes(
|
||||
return GetPropertyAttributes(&it);
|
||||
}
|
||||
|
||||
Maybe<bool> JSReceiver::HasElement(Handle<JSReceiver> object, uint32_t index) {
|
||||
LookupIterator it(object->GetIsolate(), object, index, object);
|
||||
Maybe<bool> JSReceiver::HasElement(Isolate* isolate, Handle<JSReceiver> object,
|
||||
uint32_t index) {
|
||||
LookupIterator it(isolate, object, index, object);
|
||||
return HasProperty(&it);
|
||||
}
|
||||
|
||||
|
@ -120,16 +120,15 @@ Maybe<bool> JSReceiver::HasProperty(LookupIterator* it) {
|
||||
}
|
||||
|
||||
// static
|
||||
Maybe<bool> JSReceiver::HasOwnProperty(Handle<JSReceiver> object,
|
||||
Maybe<bool> JSReceiver::HasOwnProperty(Isolate* isolate,
|
||||
Handle<JSReceiver> object,
|
||||
Handle<Name> name) {
|
||||
if (object->IsJSModuleNamespace()) {
|
||||
PropertyDescriptor desc;
|
||||
return JSReceiver::GetOwnPropertyDescriptor(object->GetIsolate(), object,
|
||||
name, &desc);
|
||||
return JSReceiver::GetOwnPropertyDescriptor(isolate, object, name, &desc);
|
||||
}
|
||||
|
||||
if (object->IsJSObject()) { // Shortcut.
|
||||
Isolate* isolate = object->GetIsolate();
|
||||
PropertyKey key(isolate, name);
|
||||
LookupIterator it(isolate, object, key, LookupIterator::OWN);
|
||||
return HasProperty(&it);
|
||||
@ -5220,25 +5219,25 @@ MaybeHandle<Object> JSObject::GetPropertyWithInterceptor(LookupIterator* it,
|
||||
return GetPropertyWithInterceptorInternal(it, it->GetInterceptor(), done);
|
||||
}
|
||||
|
||||
Maybe<bool> JSObject::HasRealNamedProperty(Handle<JSObject> object,
|
||||
Maybe<bool> JSObject::HasRealNamedProperty(Isolate* isolate,
|
||||
Handle<JSObject> object,
|
||||
Handle<Name> name) {
|
||||
Isolate* isolate = object->GetIsolate();
|
||||
PropertyKey key(isolate, name);
|
||||
LookupIterator it(isolate, object, key, LookupIterator::OWN_SKIP_INTERCEPTOR);
|
||||
return HasProperty(&it);
|
||||
}
|
||||
|
||||
Maybe<bool> JSObject::HasRealElementProperty(Handle<JSObject> object,
|
||||
Maybe<bool> JSObject::HasRealElementProperty(Isolate* isolate,
|
||||
Handle<JSObject> object,
|
||||
uint32_t index) {
|
||||
Isolate* isolate = object->GetIsolate();
|
||||
LookupIterator it(isolate, object, index, object,
|
||||
LookupIterator::OWN_SKIP_INTERCEPTOR);
|
||||
return HasProperty(&it);
|
||||
}
|
||||
|
||||
Maybe<bool> JSObject::HasRealNamedCallbackProperty(Handle<JSObject> object,
|
||||
Maybe<bool> JSObject::HasRealNamedCallbackProperty(Isolate* isolate,
|
||||
Handle<JSObject> object,
|
||||
Handle<Name> name) {
|
||||
Isolate* isolate = object->GetIsolate();
|
||||
PropertyKey key(isolate, name);
|
||||
LookupIterator it(isolate, object, key, LookupIterator::OWN_SKIP_INTERCEPTOR);
|
||||
Maybe<PropertyAttributes> maybe_result = GetPropertyAttributes(&it);
|
||||
|
@ -119,14 +119,14 @@ class JSReceiver : public TorqueGeneratedJSReceiver<JSReceiver, HeapObject> {
|
||||
V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static Maybe<bool> HasProperty(
|
||||
LookupIterator* it);
|
||||
V8_WARN_UNUSED_RESULT static inline Maybe<bool> HasProperty(
|
||||
Handle<JSReceiver> object, Handle<Name> name);
|
||||
Isolate* isolate, Handle<JSReceiver> object, Handle<Name> name);
|
||||
V8_WARN_UNUSED_RESULT static inline Maybe<bool> HasElement(
|
||||
Handle<JSReceiver> object, uint32_t index);
|
||||
Isolate* isolate, Handle<JSReceiver> object, uint32_t index);
|
||||
|
||||
V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static Maybe<bool> HasOwnProperty(
|
||||
Handle<JSReceiver> object, Handle<Name> name);
|
||||
Isolate* isolate, Handle<JSReceiver> object, Handle<Name> name);
|
||||
V8_WARN_UNUSED_RESULT static inline Maybe<bool> HasOwnProperty(
|
||||
Handle<JSReceiver> object, uint32_t index);
|
||||
Isolate* isolate, Handle<JSReceiver> object, uint32_t index);
|
||||
|
||||
V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> GetProperty(
|
||||
Isolate* isolate, Handle<JSReceiver> receiver, const char* key);
|
||||
@ -587,11 +587,11 @@ class JSObject : public TorqueGeneratedJSObject<JSObject, JSReceiver> {
|
||||
|
||||
// Support functions for v8 api (needed for correct interceptor behavior).
|
||||
V8_WARN_UNUSED_RESULT static Maybe<bool> HasRealNamedProperty(
|
||||
Handle<JSObject> object, Handle<Name> name);
|
||||
Isolate* isolate, Handle<JSObject> object, Handle<Name> name);
|
||||
V8_WARN_UNUSED_RESULT static Maybe<bool> HasRealElementProperty(
|
||||
Handle<JSObject> object, uint32_t index);
|
||||
Isolate* isolate, Handle<JSObject> object, uint32_t index);
|
||||
V8_WARN_UNUSED_RESULT static Maybe<bool> HasRealNamedCallbackProperty(
|
||||
Handle<JSObject> object, Handle<Name> name);
|
||||
Isolate* isolate, Handle<JSObject> object, Handle<Name> name);
|
||||
|
||||
// Get the header size for a JSObject. Used to compute the index of
|
||||
// embedder fields as well as the number of embedder fields.
|
||||
|
@ -1330,7 +1330,7 @@ MaybeHandle<JSReceiver> ToTemporalCalendar(
|
||||
// b. If ? HasProperty(temporalCalendarLike, "calendar") is false, return
|
||||
// temporalCalendarLike.
|
||||
Maybe<bool> maybe_has =
|
||||
JSReceiver::HasProperty(obj, factory->calendar_string());
|
||||
JSReceiver::HasProperty(isolate, obj, factory->calendar_string());
|
||||
|
||||
MAYBE_RETURN(maybe_has, Handle<JSReceiver>());
|
||||
if (!maybe_has.FromJust()) {
|
||||
@ -1345,7 +1345,8 @@ MaybeHandle<JSReceiver> ToTemporalCalendar(
|
||||
if (temporal_calendar_like->IsJSReceiver()) {
|
||||
obj = Handle<JSReceiver>::cast(temporal_calendar_like);
|
||||
// and ? HasProperty(temporalCalendarLike, "calendar") is false,
|
||||
maybe_has = JSReceiver::HasProperty(obj, factory->calendar_string());
|
||||
maybe_has =
|
||||
JSReceiver::HasProperty(isolate, obj, factory->calendar_string());
|
||||
MAYBE_RETURN(maybe_has, Handle<JSReceiver>());
|
||||
if (!maybe_has.FromJust()) {
|
||||
// return temporalCalendarLike.
|
||||
@ -1405,7 +1406,7 @@ MaybeHandle<JSReceiver> ToTemporalTimeZone(
|
||||
Handle<JSReceiver> obj = Handle<JSReceiver>::cast(temporal_time_zone_like);
|
||||
// b. If ? HasProperty(temporalTimeZoneLike, "timeZone") is false,
|
||||
Maybe<bool> maybe_has =
|
||||
JSReceiver::HasProperty(obj, factory->timeZone_string());
|
||||
JSReceiver::HasProperty(isolate, obj, factory->timeZone_string());
|
||||
MAYBE_RETURN(maybe_has, Handle<JSReceiver>());
|
||||
if (!maybe_has.FromJust()) {
|
||||
// return temporalTimeZoneLike.
|
||||
@ -1421,7 +1422,8 @@ MaybeHandle<JSReceiver> ToTemporalTimeZone(
|
||||
if (temporal_time_zone_like->IsJSReceiver()) {
|
||||
// is Object and ? HasProperty(temporalTimeZoneLike, "timeZone") is false,
|
||||
obj = Handle<JSReceiver>::cast(temporal_time_zone_like);
|
||||
maybe_has = JSReceiver::HasProperty(obj, factory->timeZone_string());
|
||||
maybe_has =
|
||||
JSReceiver::HasProperty(isolate, obj, factory->timeZone_string());
|
||||
MAYBE_RETURN(maybe_has, Handle<JSReceiver>());
|
||||
if (!maybe_has.FromJust()) {
|
||||
// return temporalTimeZoneLike.
|
||||
|
@ -428,7 +428,8 @@ namespace {
|
||||
bool IsErrorObject(Isolate* isolate, Handle<Object> object) {
|
||||
if (!object->IsJSReceiver()) return false;
|
||||
Handle<Symbol> symbol = isolate->factory()->error_stack_symbol();
|
||||
return JSReceiver::HasOwnProperty(Handle<JSReceiver>::cast(object), symbol)
|
||||
return JSReceiver::HasOwnProperty(isolate, Handle<JSReceiver>::cast(object),
|
||||
symbol)
|
||||
.FromMaybe(false);
|
||||
}
|
||||
|
||||
@ -3021,7 +3022,7 @@ Maybe<bool> JSProxy::HasProperty(Isolate* isolate, Handle<JSProxy> proxy,
|
||||
// 7. If trap is undefined, then
|
||||
if (trap->IsUndefined(isolate)) {
|
||||
// 7a. Return target.[[HasProperty]](P).
|
||||
return JSReceiver::HasProperty(target, name);
|
||||
return JSReceiver::HasProperty(isolate, target, name);
|
||||
}
|
||||
// 8. Let booleanTrapResult be ToBoolean(? Call(trap, handler, «target, P»)).
|
||||
Handle<Object> trap_result_obj;
|
||||
|
@ -77,7 +77,7 @@ MaybeHandle<Object> Runtime::HasProperty(Isolate* isolate,
|
||||
Object);
|
||||
|
||||
// Lookup the {name} on {receiver}.
|
||||
Maybe<bool> maybe = JSReceiver::HasProperty(receiver, name);
|
||||
Maybe<bool> maybe = JSReceiver::HasProperty(isolate, receiver, name);
|
||||
if (maybe.IsNothing()) return MaybeHandle<Object>();
|
||||
return maybe.FromJust() ? ReadOnlyRoots(isolate).true_value_handle()
|
||||
: ReadOnlyRoots(isolate).false_value_handle();
|
||||
@ -969,7 +969,7 @@ RUNTIME_FUNCTION(Runtime_HasProperty) {
|
||||
Object::ToName(isolate, key));
|
||||
|
||||
// Lookup the {name} on {receiver}.
|
||||
Maybe<bool> maybe = JSReceiver::HasProperty(receiver, name);
|
||||
Maybe<bool> maybe = JSReceiver::HasProperty(isolate, receiver, name);
|
||||
if (maybe.IsNothing()) return ReadOnlyRoots(isolate).exception();
|
||||
return isolate->heap()->ToBoolean(maybe.FromJust());
|
||||
}
|
||||
|
@ -2989,7 +2989,8 @@ void WasmJs::InstallConditionalFeatures(Isolate* isolate,
|
||||
Handle<JSObject> webassembly = Handle<JSObject>::cast(webassembly_obj);
|
||||
// Setup Exception
|
||||
Handle<String> tag_name = v8_str(isolate, "Tag");
|
||||
if (JSObject::HasOwnProperty(webassembly, tag_name).FromMaybe(true)) {
|
||||
if (JSObject::HasOwnProperty(isolate, webassembly, tag_name)
|
||||
.FromMaybe(true)) {
|
||||
// The {Exception} constructor already exists, there is nothing more to
|
||||
// do.
|
||||
return;
|
||||
|
@ -337,7 +337,8 @@ TEST(HeapObjects) {
|
||||
Handle<String> object_string = Handle<String>::cast(factory->Object_string());
|
||||
Handle<JSGlobalObject> global(CcTest::i_isolate()->context().global_object(),
|
||||
isolate);
|
||||
CHECK(Just(true) == JSReceiver::HasOwnProperty(global, object_string));
|
||||
CHECK(Just(true) ==
|
||||
JSReceiver::HasOwnProperty(isolate, global, object_string));
|
||||
|
||||
// Check ToString for oddballs
|
||||
ReadOnlyRoots roots(heap);
|
||||
@ -406,7 +407,7 @@ TEST(GarbageCollection) {
|
||||
CcTest::CollectGarbage(NEW_SPACE);
|
||||
|
||||
// Function should be alive.
|
||||
CHECK(Just(true) == JSReceiver::HasOwnProperty(global, name));
|
||||
CHECK(Just(true) == JSReceiver::HasOwnProperty(isolate, global, name));
|
||||
// Check function is retained.
|
||||
Handle<Object> func_value =
|
||||
Object::GetProperty(isolate, global, name).ToHandleChecked();
|
||||
@ -424,7 +425,7 @@ TEST(GarbageCollection) {
|
||||
// After gc, it should survive.
|
||||
CcTest::CollectGarbage(NEW_SPACE);
|
||||
|
||||
CHECK(Just(true) == JSReceiver::HasOwnProperty(global, obj_name));
|
||||
CHECK(Just(true) == JSReceiver::HasOwnProperty(isolate, global, obj_name));
|
||||
Handle<Object> obj =
|
||||
Object::GetProperty(isolate, global, obj_name).ToHandleChecked();
|
||||
CHECK(obj->IsJSObject());
|
||||
@ -800,60 +801,60 @@ TEST(ObjectProperties) {
|
||||
Handle<Smi> two(Smi::FromInt(2), isolate);
|
||||
|
||||
// check for empty
|
||||
CHECK(Just(false) == JSReceiver::HasOwnProperty(obj, first));
|
||||
CHECK(Just(false) == JSReceiver::HasOwnProperty(isolate, obj, first));
|
||||
|
||||
// add first
|
||||
Object::SetProperty(isolate, obj, first, one).Check();
|
||||
CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, first));
|
||||
CHECK(Just(true) == JSReceiver::HasOwnProperty(isolate, obj, first));
|
||||
|
||||
// delete first
|
||||
CHECK(Just(true) ==
|
||||
JSReceiver::DeleteProperty(obj, first, LanguageMode::kSloppy));
|
||||
CHECK(Just(false) == JSReceiver::HasOwnProperty(obj, first));
|
||||
CHECK(Just(false) == JSReceiver::HasOwnProperty(isolate, obj, first));
|
||||
|
||||
// add first and then second
|
||||
Object::SetProperty(isolate, obj, first, one).Check();
|
||||
Object::SetProperty(isolate, obj, second, two).Check();
|
||||
CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, first));
|
||||
CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, second));
|
||||
CHECK(Just(true) == JSReceiver::HasOwnProperty(isolate, obj, first));
|
||||
CHECK(Just(true) == JSReceiver::HasOwnProperty(isolate, obj, second));
|
||||
|
||||
// delete first and then second
|
||||
CHECK(Just(true) ==
|
||||
JSReceiver::DeleteProperty(obj, first, LanguageMode::kSloppy));
|
||||
CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, second));
|
||||
CHECK(Just(true) == JSReceiver::HasOwnProperty(isolate, obj, second));
|
||||
CHECK(Just(true) ==
|
||||
JSReceiver::DeleteProperty(obj, second, LanguageMode::kSloppy));
|
||||
CHECK(Just(false) == JSReceiver::HasOwnProperty(obj, first));
|
||||
CHECK(Just(false) == JSReceiver::HasOwnProperty(obj, second));
|
||||
CHECK(Just(false) == JSReceiver::HasOwnProperty(isolate, obj, first));
|
||||
CHECK(Just(false) == JSReceiver::HasOwnProperty(isolate, obj, second));
|
||||
|
||||
// add first and then second
|
||||
Object::SetProperty(isolate, obj, first, one).Check();
|
||||
Object::SetProperty(isolate, obj, second, two).Check();
|
||||
CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, first));
|
||||
CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, second));
|
||||
CHECK(Just(true) == JSReceiver::HasOwnProperty(isolate, obj, first));
|
||||
CHECK(Just(true) == JSReceiver::HasOwnProperty(isolate, obj, second));
|
||||
|
||||
// delete second and then first
|
||||
CHECK(Just(true) ==
|
||||
JSReceiver::DeleteProperty(obj, second, LanguageMode::kSloppy));
|
||||
CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, first));
|
||||
CHECK(Just(true) == JSReceiver::HasOwnProperty(isolate, obj, first));
|
||||
CHECK(Just(true) ==
|
||||
JSReceiver::DeleteProperty(obj, first, LanguageMode::kSloppy));
|
||||
CHECK(Just(false) == JSReceiver::HasOwnProperty(obj, first));
|
||||
CHECK(Just(false) == JSReceiver::HasOwnProperty(obj, second));
|
||||
CHECK(Just(false) == JSReceiver::HasOwnProperty(isolate, obj, first));
|
||||
CHECK(Just(false) == JSReceiver::HasOwnProperty(isolate, obj, second));
|
||||
|
||||
// check string and internalized string match
|
||||
const char* string1 = "fisk";
|
||||
Handle<String> s1 = factory->NewStringFromAsciiChecked(string1);
|
||||
Object::SetProperty(isolate, obj, s1, one).Check();
|
||||
Handle<String> s1_string = factory->InternalizeUtf8String(string1);
|
||||
CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, s1_string));
|
||||
CHECK(Just(true) == JSReceiver::HasOwnProperty(isolate, obj, s1_string));
|
||||
|
||||
// check internalized string and string match
|
||||
const char* string2 = "fugl";
|
||||
Handle<String> s2_string = factory->InternalizeUtf8String(string2);
|
||||
Object::SetProperty(isolate, obj, s2_string, one).Check();
|
||||
Handle<String> s2 = factory->NewStringFromAsciiChecked(string2);
|
||||
CHECK(Just(true) == JSReceiver::HasOwnProperty(obj, s2));
|
||||
CHECK(Just(true) == JSReceiver::HasOwnProperty(isolate, obj, s2));
|
||||
}
|
||||
|
||||
|
||||
|
@ -154,7 +154,7 @@ HEAP_TEST(MarkCompactCollector) {
|
||||
|
||||
{ HandleScope scope(isolate);
|
||||
Handle<String> func_name = factory->InternalizeUtf8String("theFunction");
|
||||
CHECK(Just(true) == JSReceiver::HasOwnProperty(global, func_name));
|
||||
CHECK(Just(true) == JSReceiver::HasOwnProperty(isolate, global, func_name));
|
||||
Handle<Object> func_value =
|
||||
Object::GetProperty(isolate, global, func_name).ToHandleChecked();
|
||||
CHECK(func_value->IsJSFunction());
|
||||
@ -172,7 +172,7 @@ HEAP_TEST(MarkCompactCollector) {
|
||||
|
||||
{ HandleScope scope(isolate);
|
||||
Handle<String> obj_name = factory->InternalizeUtf8String("theObject");
|
||||
CHECK(Just(true) == JSReceiver::HasOwnProperty(global, obj_name));
|
||||
CHECK(Just(true) == JSReceiver::HasOwnProperty(isolate, global, obj_name));
|
||||
Handle<Object> object =
|
||||
Object::GetProperty(isolate, global, obj_name).ToHandleChecked();
|
||||
CHECK(object->IsJSObject());
|
||||
|
@ -1340,7 +1340,7 @@ TEST(TryHasOwnProperty) {
|
||||
for (Handle<JSObject> object : objects) {
|
||||
for (size_t name_index = 0; name_index < arraysize(names); name_index++) {
|
||||
Handle<Name> name = names[name_index];
|
||||
CHECK(JSReceiver::HasProperty(object, name).FromJust());
|
||||
CHECK(JSReceiver::HasProperty(isolate, object, name).FromJust());
|
||||
ft.CheckTrue(object, name, expect_found);
|
||||
}
|
||||
}
|
||||
@ -1360,7 +1360,7 @@ TEST(TryHasOwnProperty) {
|
||||
for (size_t key_index = 0; key_index < arraysize(non_existing_names);
|
||||
key_index++) {
|
||||
Handle<Name> name = non_existing_names[key_index];
|
||||
CHECK(!JSReceiver::HasProperty(object, name).FromJust());
|
||||
CHECK(!JSReceiver::HasProperty(isolate, object, name).FromJust());
|
||||
ft.CheckTrue(object, name, expect_not_found);
|
||||
}
|
||||
}
|
||||
@ -1667,11 +1667,11 @@ TEST(TryLookupElement) {
|
||||
Handle<Object> expect_bailout(Smi::FromInt(kBailout), isolate);
|
||||
|
||||
#define CHECK_FOUND(object, index) \
|
||||
CHECK(JSReceiver::HasElement(object, index).FromJust()); \
|
||||
CHECK(JSReceiver::HasElement(isolate, object, index).FromJust()); \
|
||||
ft.CheckTrue(object, smi##index, expect_found);
|
||||
|
||||
#define CHECK_NOT_FOUND(object, index) \
|
||||
CHECK(!JSReceiver::HasElement(object, index).FromJust()); \
|
||||
CHECK(!JSReceiver::HasElement(isolate, object, index).FromJust()); \
|
||||
ft.CheckTrue(object, smi##index, expect_not_found);
|
||||
|
||||
#define CHECK_ABSENT(object, index) \
|
||||
|
@ -539,11 +539,11 @@ TEST_P(MicrotaskQueueTest, DetachGlobal_HandlerContext) {
|
||||
" results['stale_rejected_promise'] = true;"
|
||||
"})");
|
||||
microtask_queue()->RunMicrotasks(isolate());
|
||||
EXPECT_TRUE(
|
||||
JSReceiver::HasProperty(results, NameFromChars("stale_resolved_promise"))
|
||||
EXPECT_TRUE(JSReceiver::HasProperty(isolate(), results,
|
||||
NameFromChars("stale_resolved_promise"))
|
||||
.FromJust());
|
||||
EXPECT_TRUE(
|
||||
JSReceiver::HasProperty(results, NameFromChars("stale_rejected_promise"))
|
||||
EXPECT_TRUE(JSReceiver::HasProperty(isolate(), results,
|
||||
NameFromChars("stale_rejected_promise"))
|
||||
.FromJust());
|
||||
|
||||
// Set stale handlers to valid promises.
|
||||
@ -554,11 +554,11 @@ TEST_P(MicrotaskQueueTest, DetachGlobal_HandlerContext) {
|
||||
"Promise.reject("
|
||||
" stale_handler.bind(null, results, 'stale_handler_reject'))");
|
||||
microtask_queue()->RunMicrotasks(isolate());
|
||||
EXPECT_FALSE(
|
||||
JSReceiver::HasProperty(results, NameFromChars("stale_handler_resolve"))
|
||||
EXPECT_FALSE(JSReceiver::HasProperty(isolate(), results,
|
||||
NameFromChars("stale_handler_resolve"))
|
||||
.FromJust());
|
||||
EXPECT_FALSE(
|
||||
JSReceiver::HasProperty(results, NameFromChars("stale_handler_reject"))
|
||||
EXPECT_FALSE(JSReceiver::HasProperty(isolate(), results,
|
||||
NameFromChars("stale_handler_reject"))
|
||||
.FromJust());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user