Reviewers: antonm,

Description:
Re-land patch r2110.

tbr=ant...@chromium.org

Please review this at http://codereview.chromium.org/118501

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

Affected files:
   M     src/ic.cc
   M     test/cctest/test-api.cc


Index: test/cctest/test-api.cc
===================================================================
--- test/cctest/test-api.cc     (revision 2135)
+++ test/cctest/test-api.cc     (working copy)
@@ -5008,7 +5008,23 @@
  }


+THREADED_TEST(InterceptorStoreICWithNoSetter) {
+  v8::HandleScope scope;
+  v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
+  templ->SetNamedPropertyHandler(InterceptorLoadXICGetter);
+  LocalContext context;
+  context->Global()->Set(v8_str("o"), templ->NewInstance());
+  v8::Handle<Value> value = CompileRun(
+    "for (var i = 0; i < 1000; i++) {"
+    "  o.y = 239;"
+    "}"
+    "42 + o.y");
+  CHECK_EQ(239 + 42, value->Int32Value());
+}

+
+
+
  v8::Handle<Value> call_ic_function;
  v8::Handle<Value> call_ic_function2;
  v8::Handle<Value> call_ic_function3;
Index: src/ic.cc
===================================================================
--- src/ic.cc   (revision 2135)
+++ src/ic.cc   (working copy)
@@ -849,6 +849,20 @@
  }


+static bool StoreICableLookup(LookupResult* lookup) {
+  // Bail out if we didn't find a result.
+  if (!lookup->IsValid() || !lookup->IsCacheable()) return false;
+
+  // If the property is read-only, we leave the IC in its current
+  // state.
+  if (lookup->IsReadOnly()) return false;
+
+  if (!lookup->IsLoaded()) return false;
+
+  return true;
+}
+
+
  Object* StoreIC::Store(State state,
                         Handle<Object> object,
                         Handle<String> name,
@@ -873,12 +887,12 @@
    }

    // Lookup the property locally in the receiver.
-  LookupResult lookup;
-  receiver->LocalLookup(*name, &lookup);
-
-  // Update inline cache and stub cache.
-  if (FLAG_use_ic && lookup.IsLoaded()) {
-    UpdateCaches(&lookup, state, receiver, name, value);
+  if (FLAG_use_ic && !receiver->IsJSGlobalProxy()) {
+    LookupResult lookup;
+    receiver->LocalLookup(*name, &lookup);
+    if (StoreICableLookup(&lookup)) {
+      UpdateCaches(&lookup, state, receiver, name, value);
+    }
    }

    // Set the property.
@@ -893,15 +907,10 @@
                             Handle<Object> value) {
    ASSERT(lookup->IsLoaded());
    // Skip JSGlobalProxy.
-  if (receiver->IsJSGlobalProxy()) return;
+  ASSERT(!receiver->IsJSGlobalProxy());

-  // Bail out if we didn't find a result.
-  if (!lookup->IsValid() || !lookup->IsCacheable()) return;
+  ASSERT(StoreICableLookup(lookup));

-  // If the property is read-only, we leave the IC in its current
-  // state.
-  if (lookup->IsReadOnly()) return;
-
    // If the property has a non-field type allowing map transitions
    // where there is extra room in the object, we leave the IC in its
    // current state.



--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to