Commit b0c9738f authored by sgjesse@chromium.org's avatar sgjesse@chromium.org

Fix code cache lookup for keyed IC's

For keyed IC's the name is not necessarily a string.

BUG=http://crbug.com/37853
TEST=test/mjsunit/regress/regress-crbug-37853.js
Review URL: http://codereview.chromium.org/872001

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4094 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 4fd99d23
...@@ -150,7 +150,7 @@ IC::State IC::StateFrom(Code* target, Object* receiver, Object* name) { ...@@ -150,7 +150,7 @@ IC::State IC::StateFrom(Code* target, Object* receiver, Object* name) {
// the receiver map's code cache. Therefore, if the current target // the receiver map's code cache. Therefore, if the current target
// is in the receiver map's code cache, the inline cache failed due // is in the receiver map's code cache, the inline cache failed due
// to prototype check failure. // to prototype check failure.
int index = map->IndexInCodeCache(String::cast(name), target); int index = map->IndexInCodeCache(name, target);
if (index >= 0) { if (index >= 0) {
// For keyed load/store, the most likely cause of cache failure is // For keyed load/store, the most likely cause of cache failure is
// that the key has changed. We do not distinguish between // that the key has changed. We do not distinguish between
......
...@@ -3055,7 +3055,7 @@ Object* Map::FindInCodeCache(String* name, Code::Flags flags) { ...@@ -3055,7 +3055,7 @@ Object* Map::FindInCodeCache(String* name, Code::Flags flags) {
} }
int Map::IndexInCodeCache(String* name, Code* code) { int Map::IndexInCodeCache(Object* name, Code* code) {
// Get the internal index if a code cache exists. // Get the internal index if a code cache exists.
if (!code_cache()->IsFixedArray()) { if (!code_cache()->IsFixedArray()) {
return CodeCache::cast(code_cache())->GetIndex(name, code); return CodeCache::cast(code_cache())->GetIndex(name, code);
...@@ -3200,12 +3200,11 @@ Object* CodeCache::LookupNormalTypeCache(String* name, Code::Flags flags) { ...@@ -3200,12 +3200,11 @@ Object* CodeCache::LookupNormalTypeCache(String* name, Code::Flags flags) {
} }
int CodeCache::GetIndex(String* name, Code* code) { int CodeCache::GetIndex(Object* name, Code* code) {
// This is not used for normal load/store/call IC's.
if (code->type() == NORMAL) { if (code->type() == NORMAL) {
if (normal_type_cache()->IsUndefined()) return -1; if (normal_type_cache()->IsUndefined()) return -1;
CodeCacheHashTable* cache = CodeCacheHashTable::cast(normal_type_cache()); CodeCacheHashTable* cache = CodeCacheHashTable::cast(normal_type_cache());
return cache->GetIndex(name, code->flags()); return cache->GetIndex(String::cast(name), code->flags());
} }
FixedArray* array = default_cache(); FixedArray* array = default_cache();
...@@ -3217,11 +3216,11 @@ int CodeCache::GetIndex(String* name, Code* code) { ...@@ -3217,11 +3216,11 @@ int CodeCache::GetIndex(String* name, Code* code) {
} }
void CodeCache::RemoveByIndex(String* name, Code* code, int index) { void CodeCache::RemoveByIndex(Object* name, Code* code, int index) {
if (code->type() == NORMAL) { if (code->type() == NORMAL) {
ASSERT(!normal_type_cache()->IsUndefined()); ASSERT(!normal_type_cache()->IsUndefined());
CodeCacheHashTable* cache = CodeCacheHashTable::cast(normal_type_cache()); CodeCacheHashTable* cache = CodeCacheHashTable::cast(normal_type_cache());
ASSERT(cache->GetIndex(name, code->flags()) == index); ASSERT(cache->GetIndex(String::cast(name), code->flags()) == index);
cache->RemoveByIndex(index); cache->RemoveByIndex(index);
} else { } else {
FixedArray* array = default_cache(); FixedArray* array = default_cache();
......
...@@ -2971,7 +2971,7 @@ class Map: public HeapObject { ...@@ -2971,7 +2971,7 @@ class Map: public HeapObject {
// Returns the non-negative index of the code object if it is in the // Returns the non-negative index of the code object if it is in the
// cache and -1 otherwise. // cache and -1 otherwise.
int IndexInCodeCache(String* name, Code* code); int IndexInCodeCache(Object* name, Code* code);
// Removes a code object from the code cache at the given index. // Removes a code object from the code cache at the given index.
void RemoveFromCodeCache(String* name, Code* code, int index); void RemoveFromCodeCache(String* name, Code* code, int index);
...@@ -3743,10 +3743,10 @@ class CodeCache: public Struct { ...@@ -3743,10 +3743,10 @@ class CodeCache: public Struct {
// code object is not in that cache. This index can be used to later call // code object is not in that cache. This index can be used to later call
// RemoveByIndex. The cache cannot be modified between a call to GetIndex and // RemoveByIndex. The cache cannot be modified between a call to GetIndex and
// RemoveByIndex. // RemoveByIndex.
int GetIndex(String* name, Code* code); int GetIndex(Object* name, Code* code);
// Remove an object from the cache with the provided internal index. // Remove an object from the cache with the provided internal index.
void RemoveByIndex(String* name, Code* code, int index); void RemoveByIndex(Object* name, Code* code, int index);
static inline CodeCache* cast(Object* obj); static inline CodeCache* cast(Object* obj);
......
// Copyright 2009 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// See http://crbug.com/37853
function f(o, k) { return o[k]; }
a = {'a':1, 1:'a'}
f(a, 'a')
f(a, 'a')
f(a, 1);
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