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

Unified Diff: src/compiler.cc

Issue 100613004: Use optimized code map to cache OSR code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: correctly upload stuff Created 7 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler.h ('k') | src/factory.cc » ('j') | src/runtime.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index 83f9ab2daffb78830e80a50e4aefe2aa171af624..a30bb903cae2fcda9cdaf709940d0a8f04f2148c 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -59,7 +59,6 @@ CompilationInfo::CompilationInfo(Handle<Script> script,
: flags_(LanguageModeField::encode(CLASSIC_MODE)),
script_(script),
osr_ast_id_(BailoutId::None()),
- osr_pc_offset_(0),
parameter_count_(0) {
Initialize(script->GetIsolate(), BASE, zone);
}
@@ -71,7 +70,6 @@ CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info,
shared_info_(shared_info),
script_(Handle<Script>(Script::cast(shared_info->script()))),
osr_ast_id_(BailoutId::None()),
- osr_pc_offset_(0),
parameter_count_(0) {
Initialize(script_->GetIsolate(), BASE, zone);
}
@@ -85,7 +83,6 @@ CompilationInfo::CompilationInfo(Handle<JSFunction> closure,
script_(Handle<Script>(Script::cast(shared_info_->script()))),
context_(closure->context()),
osr_ast_id_(BailoutId::None()),
- osr_pc_offset_(0),
parameter_count_(0) {
Initialize(script_->GetIsolate(), BASE, zone);
}
@@ -97,7 +94,6 @@ CompilationInfo::CompilationInfo(HydrogenCodeStub* stub,
: flags_(LanguageModeField::encode(CLASSIC_MODE) |
IsLazy::encode(true)),
osr_ast_id_(BailoutId::None()),
- osr_pc_offset_(0),
parameter_count_(0) {
Initialize(isolate, STUB, zone);
code_stub_ = stub;
@@ -964,14 +960,14 @@ static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) {
Handle<Code> code = info->code();
if (code->kind() != Code::OPTIMIZED_FUNCTION) return; // Nothing to do.
- // Cache non-OSR optimized code.
- if (FLAG_cache_optimized_code && !info->is_osr()) {
+ // Cache optimized code.
+ if (FLAG_cache_optimized_code) {
Handle<JSFunction> function = info->closure();
Handle<SharedFunctionInfo> shared(function->shared());
Handle<FixedArray> literals(function->literals());
Handle<Context> native_context(function->context()->native_context());
SharedFunctionInfo::AddToOptimizedCodeMap(
- shared, native_context, code, literals);
+ shared, native_context, code, literals, info->osr_ast_id());
}
}
@@ -979,17 +975,21 @@ static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) {
static bool InstallCodeFromOptimizedCodeMap(CompilationInfo* info) {
if (!info->IsOptimizing()) return false; // Nothing to look up.
- // Lookup non-OSR optimized code.
- if (FLAG_cache_optimized_code && !info->is_osr()) {
+ // Lookup optimized code.
+ if (FLAG_cache_optimized_code) {
Handle<SharedFunctionInfo> shared = info->shared_info();
Handle<JSFunction> function = info->closure();
ASSERT(!function.is_null());
Handle<Context> native_context(function->context()->native_context());
- int index = shared->SearchOptimizedCodeMap(*native_context);
+ int index = shared->SearchOptimizedCodeMap(*native_context,
+ info->osr_ast_id());
if (index > 0) {
if (FLAG_trace_opt) {
PrintF("[found optimized code for ");
function->ShortPrint();
+ if (info->is_osr()) {
+ PrintF(" with osr ast id %d ", info->osr_ast_id().ToInt());
+ }
PrintF("]\n");
}
// Caching of optimized code enabled and optimized code found.
@@ -1056,8 +1056,8 @@ bool Compiler::CompileLazy(CompilationInfo* info) {
bool Compiler::RecompileConcurrent(Handle<JSFunction> closure,
- uint32_t osr_pc_offset) {
- bool compiling_for_osr = (osr_pc_offset != 0);
+ BailoutId osr_ast_id) {
+ bool compiling_for_osr = !osr_ast_id.IsNone();
Isolate* isolate = closure->GetIsolate();
// Here we prepare compile data for the concurrent recompilation thread, but
@@ -1078,11 +1078,7 @@ bool Compiler::RecompileConcurrent(Handle<JSFunction> closure,
Handle<SharedFunctionInfo> shared = info->shared_info();
if (compiling_for_osr) {
- BailoutId osr_ast_id =
- shared->code()->TranslatePcOffsetToAstId(osr_pc_offset);
- ASSERT(!osr_ast_id.IsNone());
info->SetOptimizing(osr_ast_id);
- info->set_osr_pc_offset(osr_pc_offset);
if (FLAG_trace_osr) {
PrintF("[COSR - attempt to queue ");
@@ -1178,7 +1174,8 @@ Handle<Code> Compiler::InstallOptimizedCode(RecompileJob* job) {
ASSERT(info->shared_info()->scope_info() != ScopeInfo::Empty(isolate));
info->closure()->ReplaceCode(*code);
if (info->shared_info()->SearchOptimizedCodeMap(
- info->closure()->context()->native_context()) == -1) {
+ info->closure()->context()->native_context(),
+ info->osr_ast_id()) == -1) {
InsertCodeIntoOptimizedCodeMap(*info);
}
if (FLAG_trace_concurrent_recompilation) {
« no previous file with comments | « src/compiler.h ('k') | src/factory.cc » ('j') | src/runtime.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698