Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: src/objects.cc

Issue 10878007: Index script compilation cache over context (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Respect language flags. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | test/cctest/test-compiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 11950 matching lines...) Expand 10 before | Expand all | Expand 10 after
11961 11961
11962 // Add the new symbol and return it along with the symbol table. 11962 // Add the new symbol and return it along with the symbol table.
11963 entry = table->FindInsertionEntry(key->Hash()); 11963 entry = table->FindInsertionEntry(key->Hash());
11964 table->set(EntryToIndex(entry), symbol); 11964 table->set(EntryToIndex(entry), symbol);
11965 table->ElementAdded(); 11965 table->ElementAdded();
11966 *s = symbol; 11966 *s = symbol;
11967 return table; 11967 return table;
11968 } 11968 }
11969 11969
11970 11970
11971 Object* CompilationCacheTable::Lookup(String* src) { 11971 // The key for the script compilation cache is dependent on the mode flags,
11972 StringKey key(src); 11972 // because they change the global language mode and thus binding behaviour.
11973 // If flags change at some point, we must ensure that we do not hit the cache
11974 // for code compiled with different settings.
11975 static LanguageMode CurrentGlobalLanguageMode() {
11976 return FLAG_use_strict
11977 ? (FLAG_harmony_scoping ? EXTENDED_MODE : STRICT_MODE)
11978 : CLASSIC_MODE;
11979 }
11980
11981
11982 Object* CompilationCacheTable::Lookup(String* src, Context* context) {
11983 SharedFunctionInfo* shared = context->closure()->shared();
11984 StringSharedKey key(src,
11985 shared,
11986 CurrentGlobalLanguageMode(),
11987 RelocInfo::kNoPosition);
11973 int entry = FindEntry(&key); 11988 int entry = FindEntry(&key);
11974 if (entry == kNotFound) return GetHeap()->undefined_value(); 11989 if (entry == kNotFound) return GetHeap()->undefined_value();
11975 return get(EntryToIndex(entry) + 1); 11990 return get(EntryToIndex(entry) + 1);
11976 } 11991 }
11977 11992
11978 11993
11979 Object* CompilationCacheTable::LookupEval(String* src, 11994 Object* CompilationCacheTable::LookupEval(String* src,
11980 Context* context, 11995 Context* context,
11981 LanguageMode language_mode, 11996 LanguageMode language_mode,
11982 int scope_position) { 11997 int scope_position) {
11983 StringSharedKey key(src, 11998 StringSharedKey key(src,
11984 context->closure()->shared(), 11999 context->closure()->shared(),
11985 language_mode, 12000 language_mode,
11986 scope_position); 12001 scope_position);
11987 int entry = FindEntry(&key); 12002 int entry = FindEntry(&key);
11988 if (entry == kNotFound) return GetHeap()->undefined_value(); 12003 if (entry == kNotFound) return GetHeap()->undefined_value();
11989 return get(EntryToIndex(entry) + 1); 12004 return get(EntryToIndex(entry) + 1);
11990 } 12005 }
11991 12006
11992 12007
11993 Object* CompilationCacheTable::LookupRegExp(String* src, 12008 Object* CompilationCacheTable::LookupRegExp(String* src,
11994 JSRegExp::Flags flags) { 12009 JSRegExp::Flags flags) {
11995 RegExpKey key(src, flags); 12010 RegExpKey key(src, flags);
11996 int entry = FindEntry(&key); 12011 int entry = FindEntry(&key);
11997 if (entry == kNotFound) return GetHeap()->undefined_value(); 12012 if (entry == kNotFound) return GetHeap()->undefined_value();
11998 return get(EntryToIndex(entry) + 1); 12013 return get(EntryToIndex(entry) + 1);
11999 } 12014 }
12000 12015
12001 12016
12002 MaybeObject* CompilationCacheTable::Put(String* src, Object* value) { 12017 MaybeObject* CompilationCacheTable::Put(String* src,
12003 StringKey key(src); 12018 Context* context,
12019 Object* value) {
12020 SharedFunctionInfo* shared = context->closure()->shared();
12021 StringSharedKey key(src,
12022 shared,
12023 CurrentGlobalLanguageMode(),
12024 RelocInfo::kNoPosition);
12004 Object* obj; 12025 Object* obj;
12005 { MaybeObject* maybe_obj = EnsureCapacity(1, &key); 12026 { MaybeObject* maybe_obj = EnsureCapacity(1, &key);
12006 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 12027 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
12007 } 12028 }
12008 12029
12009 CompilationCacheTable* cache = 12030 CompilationCacheTable* cache =
12010 reinterpret_cast<CompilationCacheTable*>(obj); 12031 reinterpret_cast<CompilationCacheTable*>(obj);
12011 int entry = cache->FindInsertionEntry(key.Hash()); 12032 int entry = cache->FindInsertionEntry(key.Hash());
12012 cache->set(EntryToIndex(entry), src); 12033
12034 Object* k;
12035 { MaybeObject* maybe_k = key.AsObject();
12036 if (!maybe_k->ToObject(&k)) return maybe_k;
12037 }
12038
12039 cache->set(EntryToIndex(entry), k);
12013 cache->set(EntryToIndex(entry) + 1, value); 12040 cache->set(EntryToIndex(entry) + 1, value);
12014 cache->ElementAdded(); 12041 cache->ElementAdded();
12015 return cache; 12042 return cache;
12016 } 12043 }
12017 12044
12018 12045
12019 MaybeObject* CompilationCacheTable::PutEval(String* src, 12046 MaybeObject* CompilationCacheTable::PutEval(String* src,
12020 Context* context, 12047 Context* context,
12021 SharedFunctionInfo* value, 12048 SharedFunctionInfo* value,
12022 int scope_position) { 12049 int scope_position) {
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after
13167 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 13194 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
13168 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 13195 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
13169 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 13196 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
13170 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 13197 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
13171 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 13198 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
13172 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 13199 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
13173 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 13200 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
13174 } 13201 }
13175 13202
13176 } } // namespace v8::internal 13203 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | test/cctest/test-compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698