Reviewers: rossberg, Igor Sheludko,

Message:
PTAL

Description:
Rossberg's suggested changes to the LookupIterator.

BUG=

Please review this at https://codereview.chromium.org/324383005/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+36, -30 lines):
  M src/lookup.h
  M src/lookup.cc
  M src/objects.cc


Index: src/lookup.cc
diff --git a/src/lookup.cc b/src/lookup.cc
index 17a8ed0ed718c0b3d032f24334929a48511c4cd0..62abf35bc860b48fa2ac013e518184d0d2fd11c2 100644
--- a/src/lookup.cc
+++ b/src/lookup.cc
@@ -19,7 +19,7 @@ void LookupIterator::Next() {
 }


-Handle<JSReceiver> LookupIterator::GetOrigin() const {
+Handle<JSReceiver> LookupIterator::GetRoot() const {
   Handle<Object> receiver = GetReceiver();
   if (receiver->IsJSReceiver()) return Handle<JSReceiver>::cast(receiver);
   Context* native_context = isolate_->context()->native_context();
@@ -69,7 +69,6 @@ bool LookupIterator::NextHolder() {

 void LookupIterator::LookupInHolder() {
   State old_state = state_;
-  state_ = NOT_FOUND;
   switch (old_state) {
     case NOT_FOUND:
       if (holder_map_->IsJSProxyMap()) {
@@ -80,22 +79,29 @@ void LookupIterator::LookupInHolder() {
         state_ = ACCESS_CHECK;
         return;
       }
+      // Fall through.
     case ACCESS_CHECK:
       if (check_interceptor() && holder_map_->has_named_interceptor()) {
         state_ = INTERCEPTOR;
         return;
       }
+      // Fall through.
     case INTERCEPTOR:
       if (holder_map_->is_dictionary_map()) {
         property_encoding_ = DICTIONARY;
       } else {
         DescriptorArray* descriptors = holder_map_->instance_descriptors();
         number_ = descriptors->SearchWithCache(*name_, *holder_map_);
-        if (number_ == DescriptorArray::kNotFound) return;
+        if (number_ == DescriptorArray::kNotFound) {
+          state_ = NOT_FOUND;
+          return;
+        }
         property_encoding_ = DESCRIPTOR;
       }
       state_ = PROPERTY;
+      return;
     case PROPERTY:
+      state_ = NOT_FOUND;
       return;
     case JSPROXY:
       UNREACHABLE();
@@ -140,10 +146,10 @@ bool LookupIterator::HasProperty() {
     case v8::internal::FIELD:
     case v8::internal::NORMAL:
     case v8::internal::CONSTANT:
-      property_type_ = DATA;
+      property_kind_ = DATA;
       break;
     case v8::internal::CALLBACKS:
-      property_type_ = ACCESSORS;
+      property_kind_ = ACCESSOR;
       break;
     case v8::internal::HANDLER:
     case v8::internal::NONEXISTENT:
@@ -180,14 +186,14 @@ Handle<Object> LookupIterator::FetchValue() const {

 Handle<Object> LookupIterator::GetAccessors() const {
   ASSERT(has_property_);
-  ASSERT_EQ(ACCESSORS, property_type_);
+  ASSERT_EQ(ACCESSOR, property_kind_);
   return FetchValue();
 }


 Handle<Object> LookupIterator::GetDataValue() const {
   ASSERT(has_property_);
-  ASSERT_EQ(DATA, property_type_);
+  ASSERT_EQ(DATA, property_kind_);
   Handle<Object> value = FetchValue();
   if (value->IsTheHole()) {
     ASSERT_EQ(DICTIONARY, property_encoding_);
Index: src/lookup.h
diff --git a/src/lookup.h b/src/lookup.h
index fb91b4e51f55c149afdd17ea964e095cb2495635..e7f60acac2a220cb96d57164e8a080af2374a91b 100644
--- a/src/lookup.h
+++ b/src/lookup.h
@@ -14,7 +14,7 @@ namespace internal {

 class LookupIterator V8_FINAL BASE_EMBEDDED {
  public:
-  enum Type {
+  enum Configuration {
     CHECK_DERIVED      = 1 << 0,
     CHECK_INTERCEPTOR  = 1 << 1,
     CHECK_ACCESS_CHECK = 1 << 2,
@@ -31,9 +31,9 @@ class LookupIterator V8_FINAL BASE_EMBEDDED {
     JSPROXY
   };

-  enum PropertyType {
+  enum PropertyKind {
     DATA,
-    ACCESSORS
+    ACCESSOR
   };

   enum PropertyEncoding {
@@ -43,17 +43,17 @@ class LookupIterator V8_FINAL BASE_EMBEDDED {

   LookupIterator(Handle<Object> receiver,
                  Handle<Name> name,
-                 Type type = CHECK_ALL)
-      : type_(type),
+                 Configuration configuration = CHECK_ALL)
+      : configuration_(configuration),
         state_(NOT_FOUND),
-        property_type_(DATA),
+        property_kind_(DATA),
         property_encoding_(DESCRIPTOR),
         property_details_(NONE, NONEXISTENT, Representation::None()),
         isolate_(name->GetIsolate()),
         name_(name),
         maybe_receiver_(receiver),
         number_(DescriptorArray::kNotFound) {
-    Handle<JSReceiver> origin = GetOrigin();
+    Handle<JSReceiver> origin = GetRoot();
     holder_map_ = handle(origin->map());
     maybe_holder_ = origin;
     Next();
@@ -62,10 +62,10 @@ class LookupIterator V8_FINAL BASE_EMBEDDED {
   LookupIterator(Handle<Object> receiver,
                  Handle<Name> name,
                  Handle<JSReceiver> holder,
-                 Type type = CHECK_ALL)
-      : type_(type),
+                 Configuration configuration = CHECK_ALL)
+      : configuration_(configuration),
         state_(NOT_FOUND),
-        property_type_(DATA),
+        property_kind_(DATA),
         property_encoding_(DESCRIPTOR),
         property_details_(NONE, NONEXISTENT, Representation::None()),
         isolate_(name->GetIsolate()),
@@ -93,7 +93,7 @@ class LookupIterator V8_FINAL BASE_EMBEDDED {
     ASSERT(IsFound() && state_ != JSPROXY);
     return Handle<JSObject>::cast(maybe_holder_.ToHandleChecked());
   }
-  Handle<JSReceiver> GetOrigin() const;
+  Handle<JSReceiver> GetRoot() const;

   /* ACCESS_CHECK */
   bool HasAccess(v8::AccessType access_type) const;
@@ -103,9 +103,9 @@ class LookupIterator V8_FINAL BASE_EMBEDDED {
   // below can be used. It ensures that we are able to provide a definite
   // answer, and loads extra information about the property.
   bool HasProperty();
-  PropertyType property_type() const {
+  PropertyKind property_kind() const {
     ASSERT(has_property_);
-    return property_type_;
+    return property_kind_;
   }
   PropertyDetails property_details() const {
     ASSERT(has_property_);
@@ -137,19 +137,19 @@ class LookupIterator V8_FINAL BASE_EMBEDDED {
     return !maybe_receiver_.is_null();
   }
   bool check_interceptor() const {
-    return !IsBootstrapping() && (type_ & CHECK_INTERCEPTOR) != 0;
+    return !IsBootstrapping() && (configuration_ & CHECK_INTERCEPTOR) != 0;
   }
   bool check_derived() const {
-    return (type_ & CHECK_DERIVED) != 0;
+    return (configuration_ & CHECK_DERIVED) != 0;
   }
   bool check_access_check() const {
-    return (type_ & CHECK_ACCESS_CHECK) != 0;
+    return (configuration_ & CHECK_ACCESS_CHECK) != 0;
   }

-  Type type_;
+  Configuration configuration_;
   State state_;
   bool has_property_;
-  PropertyType property_type_;
+  PropertyKind property_kind_;
   PropertyEncoding property_encoding_;
   PropertyDetails property_details_;
   Isolate* isolate_;
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 274749d568393b95300ba9a666a57e3b4f32c08b..91d90a21554ceda86620763d80f3717a8c57ee8e 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -149,8 +149,8 @@ MaybeHandle<Object> Object::GetProperty(LookupIterator* it) {
       }
       case LookupIterator::PROPERTY:
         if (it->HasProperty()) {
-          switch (it->property_type()) {
-            case LookupIterator::ACCESSORS:
+          switch (it->property_kind()) {
+            case LookupIterator::ACCESSOR:
               return GetPropertyWithAccessor(
                   it->GetReceiver(), it->name(),
                   it->GetHolder(), it->GetAccessors());
@@ -570,7 +570,7 @@ static bool FindAllCanReadHolder(LookupIterator* it) {
   for (; it->IsFound(); it->Next()) {
     if (it->state() == LookupIterator::PROPERTY &&
         it->HasProperty() &&
-        it->property_type() == LookupIterator::ACCESSORS) {
+        it->property_kind() == LookupIterator::ACCESSOR) {
       Handle<Object> accessors = it->GetAccessors();
       if (accessors->IsAccessorInfo()) {
         if (AccessorInfo::cast(*accessors)->all_can_read()) return true;
@@ -601,10 +601,10 @@ PropertyAttributes JSObject::GetPropertyAttributeWithFailedAccessCheck(
     LookupResult* result,
     Handle<Name> name,
     bool check_prototype) {
-  LookupIterator::Type type = check_prototype
+  LookupIterator::Configuration configuration = check_prototype
       ? LookupIterator::CHECK_DERIVED
       : LookupIterator::CHECK_OWN_REAL;
-  LookupIterator it(object, name, object, type);
+  LookupIterator it(object, name, object, configuration);
   if (FindAllCanReadHolder(&it)) return it.property_details().attributes();
   it.isolate()->ReportFailedAccessCheck(object, v8::ACCESS_HAS);
   // TODO(yangguo): Issue 3269, check for scheduled exception missing?


--
--
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.

Reply via email to