Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index 64f5a452d7c74ae961b6af3ec44a48d981f30fd1..d798f5b19d4cb4519bd854f252d81d0339e5b8ba 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -11968,8 +11968,23 @@ MaybeObject* SymbolTable::LookupKey(HashTableKey* key, Object** s) { |
} |
-Object* CompilationCacheTable::Lookup(String* src) { |
- StringKey key(src); |
+// The key for the script compilation cache is dependent on the mode flags, |
+// because they change the global language mode and thus binding behaviour. |
+// If flags change at some point, we must ensure that we do not hit the cache |
+// for code compiled with different settings. |
+static LanguageMode CurrentGlobalLanguageMode() { |
+ return FLAG_use_strict |
+ ? (FLAG_harmony_scoping ? EXTENDED_MODE : STRICT_MODE) |
+ : CLASSIC_MODE; |
+} |
+ |
+ |
+Object* CompilationCacheTable::Lookup(String* src, Context* context) { |
+ SharedFunctionInfo* shared = context->closure()->shared(); |
+ StringSharedKey key(src, |
+ shared, |
+ CurrentGlobalLanguageMode(), |
+ RelocInfo::kNoPosition); |
int entry = FindEntry(&key); |
if (entry == kNotFound) return GetHeap()->undefined_value(); |
return get(EntryToIndex(entry) + 1); |
@@ -11999,8 +12014,14 @@ Object* CompilationCacheTable::LookupRegExp(String* src, |
} |
-MaybeObject* CompilationCacheTable::Put(String* src, Object* value) { |
- StringKey key(src); |
+MaybeObject* CompilationCacheTable::Put(String* src, |
+ Context* context, |
+ Object* value) { |
+ SharedFunctionInfo* shared = context->closure()->shared(); |
+ StringSharedKey key(src, |
+ shared, |
+ CurrentGlobalLanguageMode(), |
+ RelocInfo::kNoPosition); |
Object* obj; |
{ MaybeObject* maybe_obj = EnsureCapacity(1, &key); |
if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
@@ -12009,7 +12030,13 @@ MaybeObject* CompilationCacheTable::Put(String* src, Object* value) { |
CompilationCacheTable* cache = |
reinterpret_cast<CompilationCacheTable*>(obj); |
int entry = cache->FindInsertionEntry(key.Hash()); |
- cache->set(EntryToIndex(entry), src); |
+ |
+ Object* k; |
+ { MaybeObject* maybe_k = key.AsObject(); |
+ if (!maybe_k->ToObject(&k)) return maybe_k; |
+ } |
+ |
+ cache->set(EntryToIndex(entry), k); |
cache->set(EntryToIndex(entry) + 1, value); |
cache->ElementAdded(); |
return cache; |