Immediately cache compiled scripts.
Usually, script compilation is expensive enough to warrant the extra overhead of caching scripts immediatly. BUG=chromium:588900 R=yangguo@chromium.org LOG=n Review URL: https://codereview.chromium.org/1890083002 Cr-Commit-Position: refs/heads/master@{#35527}
This commit is contained in:
parent
5df9406a07
commit
3533c084d4
@ -17636,23 +17636,11 @@ Handle<CompilationCacheTable> CompilationCacheTable::Put(
|
||||
Isolate* isolate = cache->GetIsolate();
|
||||
Handle<SharedFunctionInfo> shared(context->closure()->shared());
|
||||
StringSharedKey key(src, shared, language_mode, RelocInfo::kNoPosition);
|
||||
{
|
||||
Handle<Object> k = key.AsHandle(isolate);
|
||||
DisallowHeapAllocation no_allocation_scope;
|
||||
int entry = cache->FindEntry(&key);
|
||||
if (entry != kNotFound) {
|
||||
cache->set(EntryToIndex(entry), *k);
|
||||
cache->set(EntryToIndex(entry) + 1, *value);
|
||||
return cache;
|
||||
}
|
||||
}
|
||||
|
||||
Handle<Object> k = key.AsHandle(isolate);
|
||||
cache = EnsureCapacity(cache, 1, &key);
|
||||
int entry = cache->FindInsertionEntry(key.Hash());
|
||||
Handle<Object> k =
|
||||
isolate->factory()->NewNumber(static_cast<double>(key.Hash()));
|
||||
cache->set(EntryToIndex(entry), *k);
|
||||
cache->set(EntryToIndex(entry) + 1, Smi::FromInt(kHashGenerations));
|
||||
cache->set(EntryToIndex(entry) + 1, *value);
|
||||
cache->ElementAdded();
|
||||
return cache;
|
||||
}
|
||||
|
@ -1587,25 +1587,11 @@ TEST(CompilationCacheCachingBehavior) {
|
||||
CompileRun(raw_source);
|
||||
}
|
||||
|
||||
// On first compilation, only a hash is inserted in the code cache. We can't
|
||||
// find that value.
|
||||
// The script should be in the cache now.
|
||||
MaybeHandle<SharedFunctionInfo> info = compilation_cache->LookupScript(
|
||||
source, Handle<Object>(), 0, 0,
|
||||
v8::ScriptOriginOptions(false, true, false), native_context,
|
||||
language_mode);
|
||||
CHECK(info.is_null());
|
||||
|
||||
{
|
||||
v8::HandleScope scope(CcTest::isolate());
|
||||
CompileRun(raw_source);
|
||||
}
|
||||
|
||||
// On second compilation, the hash is replaced by a real cache entry mapping
|
||||
// the source to the shared function info containing the code.
|
||||
info = compilation_cache->LookupScript(
|
||||
source, Handle<Object>(), 0, 0,
|
||||
v8::ScriptOriginOptions(false, true, false), native_context,
|
||||
language_mode);
|
||||
CHECK(!info.is_null());
|
||||
|
||||
// Check that the code cache entry survives at least on GC.
|
||||
@ -1637,36 +1623,6 @@ TEST(CompilationCacheCachingBehavior) {
|
||||
v8::ScriptOriginOptions(false, true, false), native_context,
|
||||
language_mode);
|
||||
CHECK(info.is_null());
|
||||
|
||||
{
|
||||
v8::HandleScope scope(CcTest::isolate());
|
||||
CompileRun(raw_source);
|
||||
}
|
||||
|
||||
// On first compilation, only a hash is inserted in the code cache. We can't
|
||||
// find that value.
|
||||
info = compilation_cache->LookupScript(
|
||||
source, Handle<Object>(), 0, 0,
|
||||
v8::ScriptOriginOptions(false, true, false), native_context,
|
||||
language_mode);
|
||||
CHECK(info.is_null());
|
||||
|
||||
for (int i = 0; i < CompilationCacheTable::kHashGenerations; i++) {
|
||||
compilation_cache->MarkCompactPrologue();
|
||||
}
|
||||
|
||||
{
|
||||
v8::HandleScope scope(CcTest::isolate());
|
||||
CompileRun(raw_source);
|
||||
}
|
||||
|
||||
// If we aged the cache before caching the script, ensure that we didn't cache
|
||||
// on next compilation.
|
||||
info = compilation_cache->LookupScript(
|
||||
source, Handle<Object>(), 0, 0,
|
||||
v8::ScriptOriginOptions(false, true, false), native_context,
|
||||
language_mode);
|
||||
CHECK(info.is_null());
|
||||
}
|
||||
|
||||
|
||||
|
@ -24064,8 +24064,7 @@ void TestInvalidCacheData(v8::ScriptCompiler::CompileOptions option) {
|
||||
script->Run(context).ToLocalChecked()->Int32Value(context).FromJust());
|
||||
}
|
||||
|
||||
|
||||
TEST(InvalidCacheData) {
|
||||
TEST(InvalidParserCacheData) {
|
||||
v8::V8::Initialize();
|
||||
v8::HandleScope scope(CcTest::isolate());
|
||||
LocalContext context;
|
||||
@ -24073,6 +24072,12 @@ TEST(InvalidCacheData) {
|
||||
// Cached parser data is not consumed while parsing eagerly.
|
||||
TestInvalidCacheData(v8::ScriptCompiler::kConsumeParserCache);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(InvalidCodeCacheData) {
|
||||
v8::V8::Initialize();
|
||||
v8::HandleScope scope(CcTest::isolate());
|
||||
LocalContext context;
|
||||
TestInvalidCacheData(v8::ScriptCompiler::kConsumeCodeCache);
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
// Limit the number of stress runs to reduce polymorphism it defeats some of the
|
||||
// assumptions made about how elements transitions work because transition stubs
|
||||
// end up going generic.
|
||||
// Flags: --stress-runs=2
|
||||
// Flags: --stress-runs=1
|
||||
|
||||
var elements_kind = {
|
||||
fast_smi_only : 'fast smi only elements',
|
||||
|
Loading…
Reference in New Issue
Block a user