i::PrototypeIterator iter(isolate, self_obj);
if (iter.IsAtEnd()) return Local<Value>();
i::LookupIterator it(i::PrototypeIterator::GetCurrent(iter), key_obj,
- i::LookupIterator::CHECK_DERIVED_PROPERTY);
+ i::LookupIterator::PROTOTYPE_CHAIN_PROPERTY);
return GetPropertyByLookup(&it);
}
i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this);
i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
i::LookupIterator it(self_obj, key_obj,
- i::LookupIterator::CHECK_DERIVED_PROPERTY);
+ i::LookupIterator::PROTOTYPE_CHAIN_PROPERTY);
return GetPropertyByLookup(&it);
}
name, code, prototype, JS_GLOBAL_OBJECT_TYPE, JSGlobalObject::kSize);
#ifdef DEBUG
LookupIterator it(prototype, factory()->constructor_string(),
- LookupIterator::CHECK_PROPERTY);
+ LookupIterator::OWN_PROPERTY);
Handle<Object> value = JSReceiver::GetProperty(&it).ToHandleChecked();
DCHECK(it.IsFound());
DCHECK_EQ(*isolate()->object_function(), *value);
}
case CALLBACKS: {
Handle<Name> key(descs->GetKey(i));
- LookupIterator it(to, key, LookupIterator::CHECK_PROPERTY);
+ LookupIterator it(to, key, LookupIterator::OWN_PROPERTY);
// If the property is already there we skip it
if (it.IsFound() && it.HasProperty()) continue;
HandleScope inner(isolate());
DCHECK(raw_key->IsName());
// If the property is already there we skip it.
Handle<Name> key(Name::cast(raw_key));
- LookupIterator it(to, key, LookupIterator::CHECK_PROPERTY);
+ LookupIterator it(to, key, LookupIterator::OWN_PROPERTY);
if (it.IsFound() && it.HasProperty()) continue;
// Set the property.
Handle<Object> value = Handle<Object>(properties->ValueAt(i),
if (prototype->IsTheHole()) {
#ifdef DEBUG
LookupIterator it(handle(JSObject::cast(result->prototype())),
- constructor_string(), LookupIterator::CHECK_PROPERTY);
+ constructor_string(), LookupIterator::OWN_PROPERTY);
MaybeHandle<Object> maybe_prop = Object::GetProperty(&it);
DCHECK(it.IsFound());
DCHECK(maybe_prop.ToHandleChecked().is_identical_to(result));
}
Handle<GlobalObject> global(current_info()->global_object());
- LookupIterator it(global, variable->name(),
- LookupIterator::CHECK_PROPERTY);
+ LookupIterator it(global, variable->name(), LookupIterator::OWN_PROPERTY);
GlobalPropertyAccess type = LookupGlobalProperty(variable, &it, LOAD);
if (type == kUseCell &&
HConstant::cast(checked_object->ActualValue())->handle(isolate()));
if (object->IsJSObject()) {
- LookupIterator it(object, info->name(), LookupIterator::CHECK_PROPERTY);
+ LookupIterator it(object, info->name(), LookupIterator::OWN_PROPERTY);
Handle<Object> value = JSObject::GetDataProperty(&it);
CHECK(it.IsFound());
return New<HConstant>(value);
HValue* value,
BailoutId ast_id) {
Handle<GlobalObject> global(current_info()->global_object());
- LookupIterator it(global, var->name(), LookupIterator::CHECK_PROPERTY);
+ LookupIterator it(global, var->name(), LookupIterator::OWN_PROPERTY);
GlobalPropertyAccess type = LookupGlobalProperty(var, &it, STORE);
if (type == kUseCell) {
Handle<PropertyCell> cell = it.GetPropertyCell();
// access check is not enabled we assume that the function will not change
// and generate optimized code for calling the function.
Handle<GlobalObject> global(current_info()->global_object());
- LookupIterator it(global, var->name(), LookupIterator::CHECK_PROPERTY);
+ LookupIterator it(global, var->name(), LookupIterator::OWN_PROPERTY);
GlobalPropertyAccess type = LookupGlobalProperty(var, &it, LOAD);
if (type == kUseCell &&
!current_info()->global_object()->IsAccessCheckNeeded()) {
!current_info()->global_object()->IsAccessCheckNeeded()) {
Handle<String> name = proxy->name();
Handle<GlobalObject> global(current_info()->global_object());
- LookupIterator it(global, name, LookupIterator::CHECK_PROPERTY);
+ LookupIterator it(global, name, LookupIterator::OWN_PROPERTY);
Handle<Object> value = JSObject::GetDataProperty(&it);
if (it.IsFound() && value->IsJSFunction()) {
Handle<JSFunction> candidate = Handle<JSFunction>::cast(value);
if (receiver->IsGlobalObject()) {
Handle<GlobalObject> global = Handle<GlobalObject>::cast(receiver);
- LookupIterator it(global, name, LookupIterator::CHECK_PROPERTY);
+ LookupIterator it(global, name, LookupIterator::OWN_PROPERTY);
if (!it.IsFound() || !it.HasProperty()) return false;
Handle<PropertyCell> cell = it.GetPropertyCell();
return cell->type()->IsConstant();
// probably not a valid Error object. In that case, we fall through
// and capture the stack trace at this throw site.
LookupIterator lookup(exception_handle, key,
- LookupIterator::CHECK_PROPERTY);
+ LookupIterator::OWN_PROPERTY);
Handle<Object> stack_trace_property;
if (Object::GetProperty(&lookup).ToHandle(&stack_trace_property) &&
stack_trace_property->IsJSArray()) {
MaybeHandle<Object> BasicJsonStringifier::ApplyToJsonFunction(
Handle<Object> object, Handle<Object> key) {
LookupIterator it(object, tojson_string_,
- LookupIterator::CHECK_DERIVED_SKIP_INTERCEPTOR);
+ LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
Handle<Object> fun;
ASSIGN_RETURN_ON_EXCEPTION(isolate_, fun, Object::GetProperty(&it), Object);
if (!fun->IsJSFunction()) return object;
DCHECK(!next->map()->IsGlobalObjectMap() ||
next->map()->is_hidden_prototype());
- if (!check_derived() &&
+ if (!check_prototype_chain() &&
!(check_hidden() && next->map()->is_hidden_prototype()) &&
// Always lookup behind the JSGlobalProxy into the JSGlobalObject, even
// when not checking other hidden prototypes.
bool LookupIterator::HolderIsReceiverOrHiddenPrototype() const {
DCHECK(has_property_ || state_ == INTERCEPTOR || state_ == JSPROXY);
// Optimization that only works if configuration_ is not mutable.
- if (!check_derived()) return true;
+ if (!check_prototype_chain()) return true;
DisallowHeapAllocation no_gc;
Handle<Object> receiver = GetReceiver();
if (!receiver->IsJSReceiver()) return false;
public:
enum Configuration {
// Configuration bits.
- CHECK_HIDDEN_PROPERTY = 1 << 0,
- CHECK_DERIVED_PROPERTY = 1 << 1,
- CHECK_INTERCEPTOR = 1 << 2,
- CHECK_ACCESS_CHECK = 1 << 3,
+ kAccessCheck = 1 << 0,
+ kHidden = 1 << 1,
+ kInterceptor = 1 << 2,
+ kPrototypeChain = 1 << 3,
// Convience combinations of bits.
- CHECK_PROPERTY = 0,
- CHECK_OWN = CHECK_ACCESS_CHECK | CHECK_INTERCEPTOR,
- CHECK_HIDDEN_SKIP_INTERCEPTOR = CHECK_HIDDEN_PROPERTY | CHECK_ACCESS_CHECK,
- CHECK_DERIVED_SKIP_INTERCEPTOR =
- CHECK_HIDDEN_SKIP_INTERCEPTOR | CHECK_DERIVED_PROPERTY,
- CHECK_DERIVED = CHECK_DERIVED_SKIP_INTERCEPTOR | CHECK_INTERCEPTOR,
- CHECK_HIDDEN = CHECK_HIDDEN_SKIP_INTERCEPTOR | CHECK_INTERCEPTOR
+ OWN_PROPERTY = 0,
+ OWN_SKIP_INTERCEPTOR = kAccessCheck,
+ OWN = kAccessCheck | kInterceptor,
+ HIDDEN_PROPERTY = kHidden,
+ HIDDEN_SKIP_INTERCEPTOR = kAccessCheck | kHidden,
+ HIDDEN = kAccessCheck | kHidden | kInterceptor,
+ PROTOTYPE_CHAIN_PROPERTY = kHidden | kPrototypeChain,
+ PROTOTYPE_CHAIN_SKIP_INTERCEPTOR = kAccessCheck | kHidden | kPrototypeChain,
+ PROTOTYPE_CHAIN = kAccessCheck | kHidden | kPrototypeChain | kInterceptor
};
enum State {
};
LookupIterator(Handle<Object> receiver, Handle<Name> name,
- Configuration configuration = CHECK_DERIVED)
+ Configuration configuration = PROTOTYPE_CHAIN)
: configuration_(ComputeConfiguration(configuration, name)),
state_(NOT_FOUND),
property_kind_(DATA),
LookupIterator(Handle<Object> receiver, Handle<Name> name,
Handle<JSReceiver> holder,
- Configuration configuration = CHECK_DERIVED)
+ Configuration configuration = PROTOTYPE_CHAIN)
: configuration_(ComputeConfiguration(configuration, name)),
state_(NOT_FOUND),
property_kind_(DATA),
bool is_guaranteed_to_have_holder() const {
return !maybe_receiver_.is_null();
}
- bool check_interceptor() const {
- return !IsBootstrapping() && (configuration_ & CHECK_INTERCEPTOR) != 0;
- }
- bool check_derived() const {
- return (configuration_ & CHECK_DERIVED_PROPERTY) != 0;
+ bool check_access_check() const {
+ return (configuration_ & kAccessCheck) != 0;
}
- bool check_hidden() const {
- return (configuration_ & CHECK_HIDDEN_PROPERTY) != 0;
+ bool check_hidden() const { return (configuration_ & kHidden) != 0; }
+ bool check_interceptor() const {
+ return !IsBootstrapping() && (configuration_ & kInterceptor) != 0;
}
- bool check_access_check() const {
- return (configuration_ & CHECK_ACCESS_CHECK) != 0;
+ bool check_prototype_chain() const {
+ return (configuration_ & kPrototypeChain) != 0;
}
int descriptor_number() const {
DCHECK(has_property_);
static Configuration ComputeConfiguration(
Configuration configuration, Handle<Name> name) {
if (name->IsOwn()) {
- return static_cast<Configuration>(configuration & CHECK_HIDDEN);
+ return static_cast<Configuration>(configuration & HIDDEN);
} else {
return configuration;
}
Handle<Object> JSObject::GetDataProperty(Handle<JSObject> object,
Handle<Name> key) {
- LookupIterator it(object, key, LookupIterator::CHECK_DERIVED_PROPERTY);
+ LookupIterator it(object, key, LookupIterator::PROTOTYPE_CHAIN_PROPERTY);
return GetDataProperty(&it);
}
void JSObject::AddProperty(Handle<JSObject> object, Handle<Name> name,
Handle<Object> value,
PropertyAttributes attributes) {
- LookupIterator it(object, name, LookupIterator::CHECK_PROPERTY);
+ LookupIterator it(object, name, LookupIterator::OWN_PROPERTY);
#ifdef DEBUG
uint32_t index;
DCHECK(!object->IsJSProxy());
PropertyAttributes attributes,
ExecutableAccessorInfoHandling handling) {
DCHECK(!value->IsTheHole());
- LookupIterator it(object, name,
- LookupIterator::CHECK_HIDDEN_SKIP_INTERCEPTOR);
+ LookupIterator it(object, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR);
bool is_observed = object->map()->is_observed() &&
*name != it.isolate()->heap()->hidden_string();
for (; it.IsFound(); it.Next()) {
if (object->IsJSObject() && name->AsArrayIndex(&index)) {
return GetOwnElementAttribute(object, index);
}
- LookupIterator it(object, name, LookupIterator::CHECK_HIDDEN);
+ LookupIterator it(object, name, LookupIterator::HIDDEN);
return GetPropertyAttributes(&it);
}
bool JSObject::HasHiddenProperties(Handle<JSObject> object) {
Handle<Name> hidden = object->GetIsolate()->factory()->hidden_string();
- LookupIterator it(object, hidden, LookupIterator::CHECK_PROPERTY);
+ LookupIterator it(object, hidden, LookupIterator::OWN_PROPERTY);
Maybe<PropertyAttributes> maybe = GetPropertyAttributes(&it);
// Cannot get an exception since the hidden_string isn't accessible to JS.
DCHECK(maybe.has_value);
} else {
Isolate* isolate = GetIsolate();
LookupIterator it(handle(this), isolate->factory()->hidden_string(),
- LookupIterator::CHECK_PROPERTY);
+ LookupIterator::OWN_PROPERTY);
if (it.IsFound() && it.HasProperty()) {
DCHECK_EQ(LookupIterator::DATA, it.property_kind());
return *it.GetDataValue();
// Skip interceptors on FORCE_DELETION.
LookupIterator::Configuration config =
- delete_mode == FORCE_DELETION
- ? LookupIterator::CHECK_HIDDEN_SKIP_INTERCEPTOR
- : LookupIterator::CHECK_HIDDEN;
+ delete_mode == FORCE_DELETION ? LookupIterator::HIDDEN_SKIP_INTERCEPTOR
+ : LookupIterator::HIDDEN;
LookupIterator it(object, name, config);
Object::GetElement(isolate, object, index).ToHandleChecked();
}
} else {
- LookupIterator it(object, name,
- LookupIterator::CHECK_HIDDEN_SKIP_INTERCEPTOR);
+ LookupIterator it(object, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR);
CHECK(GetPropertyAttributes(&it).has_value);
preexists = it.IsFound();
if (preexists && (it.property_kind() == LookupIterator::DATA ||
setter->IsNull());
// At least one of the accessors needs to be a new value.
DCHECK(!getter->IsNull() || !setter->IsNull());
- LookupIterator it(object, name, LookupIterator::CHECK_PROPERTY);
+ LookupIterator it(object, name, LookupIterator::OWN_PROPERTY);
if (!getter->IsNull()) {
it.TransitionToAccessorProperty(ACCESSOR_GETTER, getter, attributes);
}
SetElementCallback(object, index, info, info->property_attributes());
} else {
// Lookup the name.
- LookupIterator it(object, name,
- LookupIterator::CHECK_HIDDEN_SKIP_INTERCEPTOR);
+ LookupIterator it(object, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR);
CHECK(GetPropertyAttributes(&it).has_value);
// ES5 forbids turning a property into an accessor if it's not
// configurable. See 8.6.1 (Table 5).
}
} else {
LookupIterator it(object, name,
- LookupIterator::CHECK_DERIVED_SKIP_INTERCEPTOR);
+ LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
for (; it.IsFound(); it.Next()) {
switch (it.state()) {
case LookupIterator::INTERCEPTOR:
CHECK(array->length()->ToArrayIndex(&length));
if (length <= index) {
LookupIterator it(array, array->GetIsolate()->factory()->length_string(),
- LookupIterator::CHECK_PROPERTY);
+ LookupIterator::OWN_PROPERTY);
CHECK(it.IsFound());
CHECK(it.HasProperty());
return it.IsReadOnly();
Maybe<bool> JSObject::HasRealNamedProperty(Handle<JSObject> object,
Handle<Name> key) {
- LookupIterator it(object, key, LookupIterator::CHECK_ACCESS_CHECK);
+ LookupIterator it(object, key, LookupIterator::OWN_SKIP_INTERCEPTOR);
Maybe<PropertyAttributes> maybe_result = GetPropertyAttributes(&it);
if (!maybe_result.has_value) return Maybe<bool>();
return maybe(it.IsFound());
Maybe<bool> JSObject::HasRealNamedCallbackProperty(Handle<JSObject> object,
Handle<Name> key) {
- LookupIterator it(object, key, LookupIterator::CHECK_ACCESS_CHECK);
+ LookupIterator it(object, key, LookupIterator::OWN_SKIP_INTERCEPTOR);
Maybe<PropertyAttributes> maybe_result = GetPropertyAttributes(&it);
if (!maybe_result.has_value) return Maybe<bool>();
return maybe(it.IsFound() && it.property_kind() == LookupIterator::ACCESSOR);
}
} else {
// Get attributes.
- LookupIterator it(obj, name, LookupIterator::CHECK_HIDDEN);
+ LookupIterator it(obj, name, LookupIterator::HIDDEN);
Maybe<PropertyAttributes> maybe = JSObject::GetPropertyAttributes(&it);
if (!maybe.has_value) return MaybeHandle<Object>();
attrs = maybe.value;
PropertyAttributes attr, bool is_var,
bool is_const, bool is_function) {
// Do the lookup own properties only, see ES5 erratum.
- LookupIterator it(global, name, LookupIterator::CHECK_HIDDEN_PROPERTY);
+ LookupIterator it(global, name, LookupIterator::HIDDEN_PROPERTY);
Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
DCHECK(maybe.has_value);
PropertyAttributes old_attributes = maybe.value;
Handle<GlobalObject> global = isolate->global_object();
// Lookup the property as own on the global object.
- LookupIterator it(global, name, LookupIterator::CHECK_HIDDEN_PROPERTY);
+ LookupIterator it(global, name, LookupIterator::HIDDEN_PROPERTY);
Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
DCHECK(maybe.has_value);
PropertyAttributes old_attributes = maybe.value;
// code can run in between that modifies the declared property.
DCHECK(holder->IsJSGlobalObject() || holder->IsJSContextExtensionObject());
- LookupIterator it(holder, name, LookupIterator::CHECK_HIDDEN_PROPERTY);
+ LookupIterator it(holder, name, LookupIterator::HIDDEN_PROPERTY);
Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
if (!maybe.has_value) return isolate->heap()->exception();
PropertyAttributes old_attributes = maybe.value;
}
// Lookup cache miss. Perform lookup and update the cache if
// appropriate.
- LookupIterator it(receiver, key, LookupIterator::CHECK_OWN);
+ LookupIterator it(receiver, key, LookupIterator::OWN);
if (it.IsFound() && it.state() == LookupIterator::PROPERTY &&
it.HasProperty() && it.property_details().type() == FIELD) {
FieldIndex field_index = it.GetFieldIndex();
return isolate->heap()->undefined_value();
}
- LookupIterator it(js_object, name, LookupIterator::CHECK_PROPERTY);
+ LookupIterator it(js_object, name, LookupIterator::OWN_PROPERTY);
// Take special care when attributes are different and there is already
// a property.
#ifdef DEBUG
uint32_t index = 0;
DCHECK(!key->ToArrayIndex(&index));
- LookupIterator it(object, key, LookupIterator::CHECK_PROPERTY);
+ LookupIterator it(object, key, LookupIterator::OWN_PROPERTY);
Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
DCHECK(maybe.has_value);
RUNTIME_ASSERT(!it.IsFound());
bool duplicate;
if (key->IsName()) {
LookupIterator it(object, Handle<Name>::cast(key),
- LookupIterator::CHECK_PROPERTY);
+ LookupIterator::OWN_PROPERTY);
Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
DCHECK(maybe.has_value);
duplicate = it.IsFound();
return *isolate->factory()->NewJSArrayWithElements(details);
}
- LookupIterator it(obj, name, LookupIterator::CHECK_HIDDEN);
+ LookupIterator it(obj, name, LookupIterator::HIDDEN);
bool has_caught = false;
Handle<Object> value = DebugGetProperty(&it, &has_caught);
if (!it.IsFound()) return isolate->heap()->undefined_value();
CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
- LookupIterator it(obj, name, LookupIterator::CHECK_DERIVED);
+ LookupIterator it(obj, name);
return *DebugGetProperty(&it);
}
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
i::LookupResult lookup(i_isolate);
i::Handle<i::String> name(v8::Utils::OpenHandle(*v8_str("length")));
- i::LookupIterator it(a, name, i::LookupIterator::CHECK_PROPERTY);
+ i::LookupIterator it(a, name, i::LookupIterator::OWN_PROPERTY);
CHECK(it.HasProperty());
CHECK(it.GetAccessors()->IsExecutableAccessorInfo());
}