Commit 37df96f9 authored by verwaest@chromium.org's avatar verwaest@chromium.org

Introduce NonJSProxyHolder returning Handle<JSObject> and return Handle<JSReceiver> for GetHolder

BUG=
R=rossberg@chromium.org

Review URL: https://codereview.chromium.org/415953005

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22594 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 9523e0ac
......@@ -100,7 +100,7 @@ bool LookupIterator::IsBootstrapping() const {
bool LookupIterator::HasAccess(v8::AccessType access_type) const {
ASSERT_EQ(ACCESS_CHECK, state_);
ASSERT(is_guaranteed_to_have_holder());
return isolate_->MayNamedAccess(GetHolder(), name_, access_type);
return isolate_->MayNamedAccess(GetHolder<JSObject>(), name_, access_type);
}
......@@ -109,11 +109,11 @@ bool LookupIterator::HasProperty() {
ASSERT(is_guaranteed_to_have_holder());
if (property_encoding_ == DICTIONARY) {
Handle<JSObject> holder = GetHolder();
Handle<JSObject> holder = GetHolder<JSObject>();
number_ = holder->property_dictionary()->FindEntry(name_);
if (number_ == NameDictionary::kNotFound) return false;
property_details_ = GetHolder()->property_dictionary()->DetailsAt(number_);
property_details_ = holder->property_dictionary()->DetailsAt(number_);
// Holes in dictionary cells are absent values.
if (holder->IsGlobalObject() &&
(property_details_.IsDeleted() || FetchValue()->IsTheHole())) {
......@@ -149,7 +149,7 @@ void LookupIterator::PrepareForDataProperty(Handle<Object> value) {
ASSERT(HolderIsReceiver());
if (property_encoding_ == DICTIONARY) return;
holder_map_ = Map::PrepareForDataProperty(holder_map_, number_, value);
JSObject::MigrateToMap(GetHolder(), holder_map_);
JSObject::MigrateToMap(GetHolder<JSObject>(), holder_map_);
// Reload property information.
if (holder_map_->is_dictionary_map()) {
property_encoding_ = DICTIONARY;
......@@ -218,10 +218,11 @@ bool LookupIterator::HolderIsReceiver() const {
Handle<Object> LookupIterator::FetchValue() const {
Object* result = NULL;
Handle<JSObject> holder = GetHolder<JSObject>();
switch (property_encoding_) {
case DICTIONARY:
result = GetHolder()->property_dictionary()->ValueAt(number_);
if (GetHolder()->IsGlobalObject()) {
result = holder->property_dictionary()->ValueAt(number_);
if (holder->IsGlobalObject()) {
result = PropertyCell::cast(result)->value();
}
break;
......@@ -230,7 +231,7 @@ Handle<Object> LookupIterator::FetchValue() const {
FieldIndex field_index = FieldIndex::ForDescriptor(
*holder_map_, number_);
return JSObject::FastPropertyAt(
GetHolder(), property_details_.representation(), field_index);
holder, property_details_.representation(), field_index);
}
result = holder_map_->instance_descriptors()->GetValue(number_);
}
......@@ -256,8 +257,8 @@ Handle<Object> LookupIterator::GetDataValue() const {
void LookupIterator::WriteDataValue(Handle<Object> value) {
ASSERT(is_guaranteed_to_have_holder());
ASSERT(has_property_);
Handle<JSObject> holder = GetHolder<JSObject>();
if (property_encoding_ == DICTIONARY) {
Handle<JSObject> holder = GetHolder();
NameDictionary* property_dictionary = holder->property_dictionary();
if (holder->IsGlobalObject()) {
Handle<PropertyCell> cell(
......@@ -267,7 +268,7 @@ void LookupIterator::WriteDataValue(Handle<Object> value) {
property_dictionary->ValueAtPut(number_, *value);
}
} else if (property_details_.type() == v8::internal::FIELD) {
GetHolder()->WriteToField(number_, *value);
holder->WriteToField(number_, *value);
} else {
ASSERT_EQ(v8::internal::CONSTANT, property_details_.type());
}
......
......@@ -93,9 +93,10 @@ class LookupIterator V8_FINAL BASE_EMBEDDED {
return Handle<Object>::cast(maybe_receiver_.ToHandleChecked());
}
Handle<Map> holder_map() const { return holder_map_; }
Handle<JSObject> GetHolder() const {
ASSERT(IsFound() && state_ != JSPROXY);
return Handle<JSObject>::cast(maybe_holder_.ToHandleChecked());
template <class T>
Handle<T> GetHolder() const {
ASSERT(IsFound());
return Handle<T>::cast(maybe_holder_.ToHandleChecked());
}
Handle<JSReceiver> GetRoot() const;
bool HolderIsReceiver() const;
......@@ -141,11 +142,6 @@ class LookupIterator V8_FINAL BASE_EMBEDDED {
void InternalizeName();
/* JSPROXY */
Handle<JSProxy> GetJSProxy() const {
return Handle<JSProxy>::cast(maybe_holder_.ToHandleChecked());
}
private:
Handle<Map> GetReceiverMap() const;
......
......@@ -135,11 +135,11 @@ MaybeHandle<Object> Object::GetProperty(LookupIterator* it) {
case LookupIterator::NOT_FOUND:
UNREACHABLE();
case LookupIterator::JSPROXY:
return JSProxy::GetPropertyWithHandler(
it->GetJSProxy(), it->GetReceiver(), it->name());
return JSProxy::GetPropertyWithHandler(it->GetHolder<JSProxy>(),
it->GetReceiver(), it->name());
case LookupIterator::INTERCEPTOR: {
MaybeHandle<Object> maybe_result = JSObject::GetPropertyWithInterceptor(
it->GetHolder(), it->GetReceiver(), it->name());
it->GetHolder<JSObject>(), it->GetReceiver(), it->name());
if (!maybe_result.is_null()) return maybe_result;
if (it->isolate()->has_pending_exception()) return maybe_result;
break;
......@@ -151,9 +151,9 @@ MaybeHandle<Object> Object::GetProperty(LookupIterator* it) {
if (it->HasProperty()) {
switch (it->property_kind()) {
case LookupIterator::ACCESSOR:
return GetPropertyWithAccessor(
it->GetReceiver(), it->name(),
it->GetHolder(), it->GetAccessors());
return GetPropertyWithAccessor(it->GetReceiver(), it->name(),
it->GetHolder<JSObject>(),
it->GetAccessors());
case LookupIterator::DATA:
return it->GetDataValue();
}
......@@ -582,10 +582,11 @@ static bool FindAllCanReadHolder(LookupIterator* it) {
MaybeHandle<Object> JSObject::GetPropertyWithFailedAccessCheck(
LookupIterator* it) {
Handle<JSObject> checked = Handle<JSObject>::cast(it->GetHolder());
Handle<JSObject> checked = it->GetHolder<JSObject>();
if (FindAllCanReadHolder(it)) {
return GetPropertyWithAccessor(
it->GetReceiver(), it->name(), it->GetHolder(), it->GetAccessors());
return GetPropertyWithAccessor(it->GetReceiver(), it->name(),
it->GetHolder<JSObject>(),
it->GetAccessors());
}
it->isolate()->ReportFailedAccessCheck(checked, v8::ACCESS_GET);
RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(it->isolate(), Object);
......@@ -595,7 +596,7 @@ MaybeHandle<Object> JSObject::GetPropertyWithFailedAccessCheck(
PropertyAttributes JSObject::GetPropertyAttributesWithFailedAccessCheck(
LookupIterator* it) {
Handle<JSObject> checked = Handle<JSObject>::cast(it->GetHolder());
Handle<JSObject> checked = it->GetHolder<JSObject>();
if (FindAllCanReadHolder(it)) return it->property_details().attributes();
it->isolate()->ReportFailedAccessCheck(checked, v8::ACCESS_HAS);
// TODO(yangguo): Issue 3269, check for scheduled exception missing?
......@@ -621,11 +622,11 @@ static bool FindAllCanWriteHolder(LookupIterator* it) {
MaybeHandle<Object> JSObject::SetPropertyWithFailedAccessCheck(
LookupIterator* it, Handle<Object> value, StrictMode strict_mode) {
Handle<JSObject> checked = Handle<JSObject>::cast(it->GetHolder());
Handle<JSObject> checked = it->GetHolder<JSObject>();
if (FindAllCanWriteHolder(it)) {
return SetPropertyWithAccessor(it->GetReceiver(), it->name(), value,
it->GetHolder(), it->GetAccessors(),
strict_mode);
it->GetHolder<JSObject>(),
it->GetAccessors(), strict_mode);
}
it->isolate()->ReportFailedAccessCheck(checked, v8::ACCESS_SET);
......@@ -2941,7 +2942,7 @@ MaybeHandle<Object> JSObject::SetPropertyWithInterceptor(LookupIterator* it,
if (it->name()->IsSymbol()) return value;
Handle<String> name_string = Handle<String>::cast(it->name());
Handle<JSObject> holder = it->GetHolder();
Handle<JSObject> holder = it->GetHolder<JSObject>();
Handle<InterceptorInfo> interceptor(holder->GetNamedInterceptor());
if (interceptor->setter()->IsUndefined()) return MaybeHandle<Object>();
......@@ -2993,7 +2994,7 @@ MaybeHandle<Object> Object::SetProperty(LookupIterator* it,
case LookupIterator::JSPROXY:
if (it->HolderIsReceiver()) {
return JSProxy::SetPropertyWithHandler(it->GetJSProxy(),
return JSProxy::SetPropertyWithHandler(it->GetHolder<JSProxy>(),
it->GetReceiver(), it->name(),
value, strict_mode);
} else {
......@@ -3001,8 +3002,8 @@ MaybeHandle<Object> Object::SetProperty(LookupIterator* it,
bool has_result = false;
MaybeHandle<Object> maybe_result =
JSProxy::SetPropertyViaPrototypesWithHandler(
it->GetJSProxy(), it->GetReceiver(), it->name(), value,
strict_mode, &has_result);
it->GetHolder<JSProxy>(), it->GetReceiver(), it->name(),
value, strict_mode, &has_result);
if (has_result) return maybe_result;
done = true;
}
......@@ -3017,7 +3018,7 @@ MaybeHandle<Object> Object::SetProperty(LookupIterator* it,
} else {
Maybe<PropertyAttributes> maybe_attributes =
JSObject::GetPropertyAttributesWithInterceptor(
it->GetHolder(), it->GetReceiver(), it->name());
it->GetHolder<JSObject>(), it->GetReceiver(), it->name());
RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(it->isolate(), Object);
done = maybe_attributes.has_value;
if (done && (maybe_attributes.value & READ_ONLY) != 0) {
......@@ -3036,7 +3037,7 @@ MaybeHandle<Object> Object::SetProperty(LookupIterator* it,
if (it->HolderIsReceiver() ||
!it->GetAccessors()->IsDeclaredAccessorInfo()) {
return SetPropertyWithAccessor(it->GetReceiver(), it->name(),
value, it->GetHolder(),
value, it->GetHolder<JSObject>(),
it->GetAccessors(), strict_mode);
}
break;
......@@ -4333,11 +4334,11 @@ PropertyAttributes JSReceiver::GetPropertyAttributes(LookupIterator* it) {
UNREACHABLE();
case LookupIterator::JSPROXY:
return JSProxy::GetPropertyAttributesWithHandler(
it->GetJSProxy(), it->GetReceiver(), it->name());
it->GetHolder<JSProxy>(), it->GetReceiver(), it->name());
case LookupIterator::INTERCEPTOR: {
Maybe<PropertyAttributes> result =
JSObject::GetPropertyAttributesWithInterceptor(
it->GetHolder(), it->GetReceiver(), it->name());
it->GetHolder<JSObject>(), it->GetReceiver(), it->name());
if (result.has_value) return result.value;
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment