Commit cbd31001 authored by kasperl@chromium.org's avatar kasperl@chromium.org

Re-land patch r2110.

TBR=antonm@chromium.org
Review URL: http://codereview.chromium.org/118501

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2136 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 35b5aab3
...@@ -849,6 +849,20 @@ void KeyedLoadIC::UpdateCaches(LookupResult* lookup, State state, ...@@ -849,6 +849,20 @@ void KeyedLoadIC::UpdateCaches(LookupResult* lookup, State state,
} }
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, Object* StoreIC::Store(State state,
Handle<Object> object, Handle<Object> object,
Handle<String> name, Handle<String> name,
...@@ -873,12 +887,12 @@ Object* StoreIC::Store(State state, ...@@ -873,12 +887,12 @@ Object* StoreIC::Store(State state,
} }
// Lookup the property locally in the receiver. // Lookup the property locally in the receiver.
LookupResult lookup; if (FLAG_use_ic && !receiver->IsJSGlobalProxy()) {
receiver->LocalLookup(*name, &lookup); LookupResult lookup;
receiver->LocalLookup(*name, &lookup);
// Update inline cache and stub cache. if (StoreICableLookup(&lookup)) {
if (FLAG_use_ic && lookup.IsLoaded()) { UpdateCaches(&lookup, state, receiver, name, value);
UpdateCaches(&lookup, state, receiver, name, value); }
} }
// Set the property. // Set the property.
...@@ -893,14 +907,9 @@ void StoreIC::UpdateCaches(LookupResult* lookup, ...@@ -893,14 +907,9 @@ void StoreIC::UpdateCaches(LookupResult* lookup,
Handle<Object> value) { Handle<Object> value) {
ASSERT(lookup->IsLoaded()); ASSERT(lookup->IsLoaded());
// Skip JSGlobalProxy. // Skip JSGlobalProxy.
if (receiver->IsJSGlobalProxy()) return; ASSERT(!receiver->IsJSGlobalProxy());
// Bail out if we didn't find a result. ASSERT(StoreICableLookup(lookup));
if (!lookup->IsValid() || !lookup->IsCacheable()) return;
// 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 // 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 // where there is extra room in the object, we leave the IC in its
......
...@@ -5008,6 +5008,22 @@ THREADED_TEST(InterceptorStoreIC) { ...@@ -5008,6 +5008,22 @@ THREADED_TEST(InterceptorStoreIC) {
} }
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_function;
v8::Handle<Value> call_ic_function2; v8::Handle<Value> call_ic_function2;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment