Reviewers: Yang,
Message:
PTAL
Description:
Get rid of all non-IC uses of LookupOwnRealNamedProperty
BUG=
Please review this at https://codereview.chromium.org/491023002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+17, -35 lines):
M src/lookup-inl.h
M src/objects.cc
M test/cctest/test-api.cc
Index: src/lookup-inl.h
diff --git a/src/lookup-inl.h b/src/lookup-inl.h
index
cdd32f7ed64c1b70b9291d88dc9de7518644b5be..06509975baba6f1f20ee57365441fd274ed2cd4e
100644
--- a/src/lookup-inl.h
+++ b/src/lookup-inl.h
@@ -20,7 +20,10 @@ JSReceiver* LookupIterator::NextHolder(Map* map) {
next->map()->is_hidden_prototype());
if (!check_derived() &&
- !(check_hidden() && next->map()->is_hidden_prototype())) {
+ !(check_hidden() && next->map()->is_hidden_prototype()) &&
+ // Always lookup behind the JSGlobalProxy into the JSGlobalObject,
even
+ // when not checking other hidden prototypes.
+ !(map->IsJSGlobalProxyMap() && next->IsJSGlobalObject())) {
return NULL;
}
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index
f77384a90a57acab6909897f5a009d5a63afcec9..1f8c70eb7d37e7bf383265ef305f7c0997cb0faa
100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -12951,11 +12951,11 @@ bool
JSArray::WouldChangeReadOnlyLength(Handle<JSArray> array,
uint32_t length = 0;
CHECK(array->length()->ToArrayIndex(&length));
if (length <= index) {
- Isolate* isolate = array->GetIsolate();
- LookupResult lookup(isolate);
- Handle<Name> length_string = isolate->factory()->length_string();
- array->LookupOwnRealNamedProperty(length_string, &lookup);
- return lookup.IsReadOnly();
+ LookupIterator it(array,
array->GetIsolate()->factory()->length_string(),
+ LookupIterator::CHECK_PROPERTY);
+ CHECK(it.IsFound());
+ CHECK(it.HasProperty());
+ return it.IsReadOnly();
}
return false;
}
@@ -13339,20 +13339,10 @@ MaybeHandle<JSObject>
JSObject::GetKeysForIndexedInterceptor(
Maybe<bool> JSObject::HasRealNamedProperty(Handle<JSObject> object,
Handle<Name> key) {
- Isolate* isolate = object->GetIsolate();
- SealHandleScope shs(isolate);
- // Check access rights if needed.
- if (object->IsAccessCheckNeeded()) {
- if (!isolate->MayNamedAccess(object, key, v8::ACCESS_HAS)) {
- isolate->ReportFailedAccessCheck(object, v8::ACCESS_HAS);
- RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Maybe<bool>());
- return maybe(false);
- }
- }
-
- LookupResult result(isolate);
- object->LookupOwnRealNamedProperty(key, &result);
- return maybe(result.IsFound() && !result.IsInterceptor());
+ LookupIterator it(object, key, LookupIterator::CHECK_ACCESS_CHECK);
+ Maybe<PropertyAttributes> maybe_result = GetPropertyAttributes(&it);
+ if (!maybe_result.has_value) return Maybe<bool>();
+ return maybe(it.IsFound());
}
@@ -13387,20 +13377,10 @@ Maybe<bool>
JSObject::HasRealElementProperty(Handle<JSObject> object,
Maybe<bool> JSObject::HasRealNamedCallbackProperty(Handle<JSObject> object,
Handle<Name> key) {
- Isolate* isolate = object->GetIsolate();
- SealHandleScope shs(isolate);
- // Check access rights if needed.
- if (object->IsAccessCheckNeeded()) {
- if (!isolate->MayNamedAccess(object, key, v8::ACCESS_HAS)) {
- isolate->ReportFailedAccessCheck(object, v8::ACCESS_HAS);
- RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Maybe<bool>());
- return maybe(false);
- }
- }
-
- LookupResult result(isolate);
- object->LookupOwnRealNamedProperty(key, &result);
- return maybe(result.IsPropertyCallbacks());
+ LookupIterator it(object, key, LookupIterator::CHECK_ACCESS_CHECK);
+ Maybe<PropertyAttributes> maybe_result = GetPropertyAttributes(&it);
+ if (!maybe_result.has_value) return Maybe<bool>();
+ return maybe(it.IsFound() && it.property_kind() ==
LookupIterator::ACCESSOR);
}
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index
50ce753db869947089012d42c9710ace2ac70818..73d39cea8dc03c7f7b0359e492eb1e59d7d5c721
100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -21724,7 +21724,6 @@ TEST(AccessCheckThrows) {
// Create a context and set an x property on it's global object.
LocalContext context0(NULL, global_template);
- context0->Global()->Set(v8_str("x"), v8_num(42));
v8::Handle<v8::Object> global0 = context0->Global();
// Create a context with a different security token so that the
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.