Revision: 22853
Author:   [email protected]
Date:     Tue Aug  5 09:32:55 2014 UTC
Log:      Inline LookupInHolder and NextHolder

BUG=
[email protected]

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

Added:
 /branches/bleeding_edge/src/lookup-inl.h
Modified:
 /branches/bleeding_edge/BUILD.gn
 /branches/bleeding_edge/src/lookup.cc
 /branches/bleeding_edge/src/lookup.h
 /branches/bleeding_edge/tools/gyp/v8.gyp

=======================================
--- /dev/null
+++ /branches/bleeding_edge/src/lookup-inl.h    Tue Aug  5 09:32:55 2014 UTC
@@ -0,0 +1,68 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_LOOKUP_INL_H_
+#define V8_LOOKUP_INL_H_
+
+#include "src/lookup.h"
+
+namespace v8 {
+namespace internal {
+
+
+JSReceiver* LookupIterator::NextHolder(Map* map) {
+  DisallowHeapAllocation no_gc;
+  if (map->prototype()->IsNull()) return NULL;
+
+  JSReceiver* next = JSReceiver::cast(map->prototype());
+  DCHECK(!next->map()->IsGlobalObjectMap() ||
+         next->map()->is_hidden_prototype());
+
+  if (!check_derived() &&
+      !(check_hidden() && next->map()->is_hidden_prototype())) {
+    return NULL;
+  }
+
+  return next;
+}
+
+
+LookupIterator::State LookupIterator::LookupInHolder(Map* map) {
+  DisallowHeapAllocation no_gc;
+  switch (state_) {
+    case NOT_FOUND:
+      if (map->IsJSProxyMap()) {
+        return JSPROXY;
+      }
+      if (check_access_check() && map->is_access_check_needed()) {
+        return ACCESS_CHECK;
+      }
+    // Fall through.
+    case ACCESS_CHECK:
+      if (check_interceptor() && map->has_named_interceptor()) {
+        return INTERCEPTOR;
+      }
+    // Fall through.
+    case INTERCEPTOR:
+      if (map->is_dictionary_map()) {
+        property_encoding_ = DICTIONARY;
+      } else {
+        DescriptorArray* descriptors = map->instance_descriptors();
+        number_ = descriptors->SearchWithCache(*name_, map);
+        if (number_ == DescriptorArray::kNotFound) return NOT_FOUND;
+        property_encoding_ = DESCRIPTOR;
+      }
+      return PROPERTY;
+    case PROPERTY:
+      return NOT_FOUND;
+    case JSPROXY:
+      UNREACHABLE();
+  }
+  UNREACHABLE();
+  return state_;
+}
+}
+}  // namespace v8::internal
+
+#endif  // V8_LOOKUP_INL_H_
=======================================
--- /branches/bleeding_edge/BUILD.gn    Tue Aug  5 08:18:22 2014 UTC
+++ /branches/bleeding_edge/BUILD.gn    Tue Aug  5 09:32:55 2014 UTC
@@ -747,6 +747,7 @@
     "src/log-utils.h",
     "src/log.cc",
     "src/log.h",
+    "src/lookup-inl.h",
     "src/lookup.cc",
     "src/lookup.h",
     "src/macro-assembler.h",
=======================================
--- /branches/bleeding_edge/src/lookup.cc       Mon Aug  4 11:34:54 2014 UTC
+++ /branches/bleeding_edge/src/lookup.cc       Tue Aug  5 09:32:55 2014 UTC
@@ -6,16 +6,36 @@

 #include "src/bootstrapper.h"
 #include "src/lookup.h"
+#include "src/lookup-inl.h"

 namespace v8 {
 namespace internal {


 void LookupIterator::Next() {
+  DisallowHeapAllocation no_gc;
   has_property_ = false;
-  do {
-    state_ = LookupInHolder();
-  } while (!IsFound() && NextHolder());
+
+  JSReceiver* holder = NULL;
+  Map* map = *holder_map_;
+
+  // Perform lookup on current holder.
+  state_ = LookupInHolder(map);
+
+  // Continue lookup if lookup on current holder failed.
+  while (!IsFound()) {
+    JSReceiver* maybe_holder = NextHolder(map);
+    if (maybe_holder == NULL) break;
+    holder = maybe_holder;
+    map = holder->map();
+    state_ = LookupInHolder(map);
+  }
+
+  // Either was found in the receiver, or the receiver has no prototype.
+  if (holder == NULL) return;
+
+  maybe_holder_ = handle(holder);
+  holder_map_ = handle(map);
 }


@@ -34,62 +54,6 @@
   if (receiver->IsNumber()) return isolate_->factory()->heap_number_map();
   return handle(Handle<HeapObject>::cast(receiver)->map());
 }
-
-
-bool LookupIterator::NextHolder() {
-  if (holder_map_->prototype()->IsNull()) return false;
-
-  Handle<JSReceiver> next(JSReceiver::cast(holder_map_->prototype()));
-
-  if (!check_derived() &&
-      !(check_hidden() &&
- // TODO(verwaest): Check if this is actually necessary currently. If it - // is, this should be handled by setting is_hidden_prototype on the
-         // global object behind the proxy.
-        (holder_map_->IsJSGlobalProxyMap() ||
-         next->map()->is_hidden_prototype()))) {
-    return false;
-  }
-
-  holder_map_ = handle(next->map());
-  maybe_holder_ = next;
-  return true;
-}
-
-
-LookupIterator::State LookupIterator::LookupInHolder() {
-  switch (state_) {
-    case NOT_FOUND:
-      if (holder_map_->IsJSProxyMap()) {
-        return JSPROXY;
-      }
-      if (check_access_check() && holder_map_->is_access_check_needed()) {
-        return ACCESS_CHECK;
-      }
-      // Fall through.
-    case ACCESS_CHECK:
-      if (check_interceptor() && holder_map_->has_named_interceptor()) {
-        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 NOT_FOUND;
-        property_encoding_ = DESCRIPTOR;
-      }
-      return PROPERTY;
-    case PROPERTY:
-      return NOT_FOUND;
-    case JSPROXY:
-      UNREACHABLE();
-  }
-  UNREACHABLE();
-  return state_;
-}


 bool LookupIterator::IsBootstrapping() const {
@@ -190,7 +154,7 @@
   // Reload the information.
   state_ = NOT_FOUND;
   configuration_ = CHECK_OWN_REAL;
-  state_ = LookupInHolder();
+  state_ = LookupInHolder(*holder_map_);
   DCHECK(IsFound());
   HasProperty();
 }
=======================================
--- /branches/bleeding_edge/src/lookup.h        Mon Aug  4 11:34:54 2014 UTC
+++ /branches/bleeding_edge/src/lookup.h        Tue Aug  5 09:32:55 2014 UTC
@@ -150,8 +150,8 @@
  private:
   Handle<Map> GetReceiverMap() const;

-  MUST_USE_RESULT bool NextHolder();
-  State LookupInHolder();
+  MUST_USE_RESULT inline JSReceiver* NextHolder(Map* map);
+  inline State LookupInHolder(Map* map);
   Handle<Object> FetchValue() const;

   bool IsBootstrapping() const;
=======================================
--- /branches/bleeding_edge/tools/gyp/v8.gyp    Tue Aug  5 08:18:22 2014 UTC
+++ /branches/bleeding_edge/tools/gyp/v8.gyp    Tue Aug  5 09:32:55 2014 UTC
@@ -649,6 +649,7 @@
         '../../src/log-utils.h',
         '../../src/log.cc',
         '../../src/log.h',
+        '../../src/lookup-inl.h',
         '../../src/lookup.cc',
         '../../src/lookup.h',
         '../../src/macro-assembler.h',

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