Revision: 21778
Author:   [email protected]
Date:     Wed Jun 11 18:02:38 2014 UTC
Log:      Rossberg's suggested changes to the LookupIterator.

BUG=
[email protected]

Review URL: https://codereview.chromium.org/324383005
http://code.google.com/p/v8/source/detail?r=21778

Modified:
 /branches/bleeding_edge/src/lookup.cc
 /branches/bleeding_edge/src/lookup.h
 /branches/bleeding_edge/src/objects.cc

=======================================
--- /branches/bleeding_edge/src/lookup.cc       Wed Jun 11 09:59:14 2014 UTC
+++ /branches/bleeding_edge/src/lookup.cc       Wed Jun 11 18:02:38 2014 UTC
@@ -14,12 +14,12 @@
 void LookupIterator::Next() {
   has_property_ = false;
   do {
-    LookupInHolder();
+    state_ = LookupInHolder();
   } while (!IsFound() && NextHolder());
 }


-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();
@@ -67,39 +67,38 @@
 }


-void LookupIterator::LookupInHolder() {
-  State old_state = state_;
-  state_ = NOT_FOUND;
-  switch (old_state) {
+LookupIterator::State LookupIterator::LookupInHolder() {
+  switch (state_) {
     case NOT_FOUND:
       if (holder_map_->IsJSProxyMap()) {
-        state_ = JSPROXY;
-        return;
+        return JSPROXY;
       }
       if (check_access_check() && holder_map_->is_access_check_needed()) {
-        state_ = ACCESS_CHECK;
-        return;
+        return ACCESS_CHECK;
       }
+      // Fall through.
     case ACCESS_CHECK:
       if (check_interceptor() && holder_map_->has_named_interceptor()) {
-        state_ = INTERCEPTOR;
-        return;
+        return INTERCEPTOR;
       }
+      // 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) return NOT_FOUND;
         property_encoding_ = DESCRIPTOR;
       }
-      state_ = PROPERTY;
+      return PROPERTY;
     case PROPERTY:
-      return;
+      return NOT_FOUND;
     case JSPROXY:
       UNREACHABLE();
   }
+  UNREACHABLE();
+  return state_;
 }


@@ -140,10 +139,10 @@
     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 +179,14 @@

 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_);
=======================================
--- /branches/bleeding_edge/src/lookup.h        Wed Jun 11 09:59:14 2014 UTC
+++ /branches/bleeding_edge/src/lookup.h        Wed Jun 11 18:02:38 2014 UTC
@@ -14,7 +14,7 @@

 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 @@
     JSPROXY
   };

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

   enum PropertyEncoding {
@@ -43,17 +43,17 @@

   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 @@
   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 @@
     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 @@
   // 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_);
@@ -124,7 +124,7 @@
   Handle<Map> GetReceiverMap() const;

   MUST_USE_RESULT bool NextHolder();
-  void LookupInHolder();
+  State LookupInHolder();
   Handle<Object> FetchValue() const;

   bool IsBootstrapping() const;
@@ -137,19 +137,19 @@
     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_;
=======================================
--- /branches/bleeding_edge/src/objects.cc      Wed Jun 11 09:59:14 2014 UTC
+++ /branches/bleeding_edge/src/objects.cc      Wed Jun 11 18:02:38 2014 UTC
@@ -149,8 +149,8 @@
       }
       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 @@
   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 @@
     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