}
-static Local<Value> GetPropertyByLookup(i::Isolate* isolate,
- i::Handle<i::JSObject> receiver,
- i::Handle<i::String> name,
- i::LookupResult* lookup) {
- if (!lookup->IsProperty()) {
- // No real property was found.
- return Local<Value>();
- }
-
- // If the property being looked up is a callback, it can throw
- // an exception.
- EXCEPTION_PREAMBLE(isolate);
- i::LookupIterator it(receiver, name,
- i::Handle<i::JSReceiver>(lookup->holder(), isolate),
- i::LookupIterator::CHECK_DERIVED_SKIP_INTERCEPTOR);
+static Local<Value> GetPropertyByLookup(i::LookupIterator* it) {
+ // If the property being looked up is a callback, it can throw an exception.
+ EXCEPTION_PREAMBLE(it->isolate());
i::Handle<i::Object> result;
- has_pending_exception = !i::Object::GetProperty(&it).ToHandle(&result);
- EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
+ has_pending_exception = !i::Object::GetProperty(it).ToHandle(&result);
+ EXCEPTION_BAILOUT_CHECK(it->isolate(), Local<Value>());
return Utils::ToLocal(result);
}
ENTER_V8(isolate);
i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this);
i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
- i::LookupResult lookup(isolate);
- self_obj->LookupRealNamedPropertyInPrototypes(key_obj, &lookup);
- return GetPropertyByLookup(isolate, self_obj, key_obj, &lookup);
+ 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);
+ return GetPropertyByLookup(&it);
}
ENTER_V8(isolate);
i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this);
i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
- i::LookupResult lookup(isolate);
- self_obj->LookupRealNamedProperty(key_obj, &lookup);
- return GetPropertyByLookup(isolate, self_obj, key_obj, &lookup);
+ i::LookupIterator it(self_obj, key_obj,
+ i::LookupIterator::CHECK_DERIVED_PROPERTY);
+ return GetPropertyByLookup(&it);
}
i::Handle<i::String> property_name =
isolate->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("displayName"));
- i::LookupResult lookup(isolate);
- func->LookupRealNamedProperty(property_name, &lookup);
- if (lookup.IsFound()) {
- i::Object* value = lookup.GetLazyValue();
- if (value && value->IsString()) {
- i::String* name = i::String::cast(value);
- if (name->length() > 0) return Utils::ToLocal(i::Handle<i::String>(name));
- }
+ i::LookupIterator it(func, property_name,
+ i::LookupIterator::CHECK_DERIVED_PROPERTY);
+
+ i::Handle<i::Object> value =
+ i::JSObject::GetDataProperty(func, property_name);
+ if (value->IsString()) {
+ i::Handle<i::String> name = i::Handle<i::String>::cast(value);
+ if (name->length() > 0) return Utils::ToLocal(name);
}
+
return ToApiHandle<Primitive>(isolate->factory()->undefined_value());
}
}
+Handle<Object> JSObject::GetDataProperty(Handle<JSObject> object,
+ Handle<Name> key) {
+ LookupIterator it(object, key, LookupIterator::CHECK_DERIVED_PROPERTY);
+ for (; it.IsFound(); it.Next()) {
+ switch (it.state()) {
+ case LookupIterator::NOT_FOUND:
+ case LookupIterator::ACCESS_CHECK:
+ case LookupIterator::INTERCEPTOR:
+ UNREACHABLE();
+ case LookupIterator::JSPROXY:
+ return it.isolate()->factory()->undefined_value();
+ case LookupIterator::PROPERTY:
+ if (!it.HasProperty()) continue;
+ switch (it.property_kind()) {
+ case LookupIterator::DATA:
+ return it.GetDataValue();
+ case LookupIterator::ACCESSOR:
+ // TODO(verwaest): For now this doesn't call into
+ // ExecutableAccessorInfo, since clients don't need it. Update once
+ // relevant.
+ return it.isolate()->factory()->undefined_value();
+ }
+ }
+ }
+ return it.isolate()->factory()->undefined_value();
+}
+
+
bool Object::ToInt32(int32_t* value) {
if (IsSmi()) {
*value = Smi::cast(this)->value();
}
-Handle<Object> JSObject::GetNormalizedProperty(Handle<JSObject> object,
- const LookupResult* result) {
- DCHECK(!object->HasFastProperties());
- Isolate* isolate = object->GetIsolate();
- Handle<Object> value(
- object->property_dictionary()->ValueAt(result->GetDictionaryEntry()),
- isolate);
- if (object->IsGlobalObject()) {
- value = handle(Handle<PropertyCell>::cast(value)->value(), isolate);
- DCHECK(!value->IsTheHole());
- }
- DCHECK(!value->IsPropertyCell() && !value->IsCell());
- return value;
-}
-
-
void JSObject::SetNormalizedProperty(Handle<JSObject> object,
Handle<Name> name,
Handle<Object> value,
}
-void JSObject::LookupRealNamedProperty(Handle<Name> name,
- LookupResult* result) {
- DisallowHeapAllocation no_gc;
- LookupOwnRealNamedProperty(name, result);
- if (result->IsFound()) return;
-
- LookupRealNamedPropertyInPrototypes(name, result);
-}
-
-
-void JSObject::LookupRealNamedPropertyInPrototypes(Handle<Name> name,
- LookupResult* result) {
- if (name->IsOwn()) {
- result->NotFound();
- return;
- }
-
- DisallowHeapAllocation no_gc;
- Isolate* isolate = GetIsolate();
- for (PrototypeIterator iter(isolate, this); !iter.IsAtEnd(); iter.Advance()) {
- if (iter.GetCurrent()->IsJSProxy()) {
- return result->HandlerResult(JSProxy::cast(iter.GetCurrent()));
- }
- JSObject::cast(iter.GetCurrent())->LookupOwnRealNamedProperty(name, result);
- DCHECK(!(result->IsFound() && result->type() == INTERCEPTOR));
- if (result->IsFound()) return;
- }
- result->NotFound();
-}
-
-
Maybe<bool> JSProxy::HasPropertyWithHandler(Handle<JSProxy> proxy,
Handle<Name> name) {
Isolate* isolate = proxy->GetIsolate();
}
-Handle<Object> JSObject::GetDataProperty(Handle<JSObject> object,
- Handle<Name> key) {
- Isolate* isolate = object->GetIsolate();
- LookupResult lookup(isolate);
- {
- DisallowHeapAllocation no_allocation;
- object->LookupRealNamedProperty(key, &lookup);
- }
- Handle<Object> result = isolate->factory()->undefined_value();
- if (lookup.IsFound() && !lookup.IsTransition()) {
- switch (lookup.type()) {
- case NORMAL:
- result = GetNormalizedProperty(
- Handle<JSObject>(lookup.holder(), isolate), &lookup);
- break;
- case FIELD:
- result = FastPropertyAt(Handle<JSObject>(lookup.holder(), isolate),
- lookup.representation(),
- lookup.GetFieldIndex());
- break;
- case CONSTANT:
- result = Handle<Object>(lookup.GetConstant(), isolate);
- break;
- case CALLBACKS:
- case HANDLER:
- case INTERCEPTOR:
- break;
- case NONEXISTENT:
- UNREACHABLE();
- }
- }
- return result;
-}
-
-
// Tests for the fast common case for property enumeration:
// - This object and all prototypes has an enum cache (which means that
// it is no proxy, has no interceptors and needs no access checks).
// Retrieve a value in a normalized object given a lookup result.
// Handles the special representation of JS global objects.
Object* GetNormalizedProperty(const LookupResult* result);
- static Handle<Object> GetNormalizedProperty(Handle<JSObject> object,
- const LookupResult* result);
// Sets the property value in a normalized object given (key, value, details).
// Handles the special representation of JS global objects.
// The following lookup functions skip interceptors.
void LookupOwnRealNamedProperty(Handle<Name> name, LookupResult* result);
- void LookupRealNamedProperty(Handle<Name> name, LookupResult* result);
- void LookupRealNamedPropertyInPrototypes(Handle<Name> name,
- LookupResult* result);
// Returns the number of properties on this object filtering out properties
// with the specified attributes (ignoring interceptors).