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

Unified Diff: src/compiler.cc

Issue 101853003: Cache optimized code for OSR. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments, fixed a bug. 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
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index b9fe9870d6750a5383c72b955195bb9b4c2a4bb0..362cddbf19654348921605f18d40411042c476a9 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -1028,16 +1028,20 @@ Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal,
}
-static Handle<Code> GetCodeFromOptimizedCodeMap(Handle<JSFunction> function) {
+static Handle<Code> GetCodeFromOptimizedCodeMap(Handle<JSFunction> function,
+ BailoutId osr_ast_id) {
if (FLAG_cache_optimized_code) {
Handle<SharedFunctionInfo> shared(function->shared());
DisallowHeapAllocation no_gc;
int index = shared->SearchOptimizedCodeMap(
- function->context()->native_context());
+ function->context()->native_context(), osr_ast_id);
if (index > 0) {
if (FLAG_trace_opt) {
PrintF("[found optimized code for ");
function->ShortPrint();
+ if (!osr_ast_id.IsNone()) {
+ PrintF(" at OSR AST id %d", osr_ast_id.ToInt());
+ }
PrintF("]\n");
}
FixedArray* literals = shared->GetLiteralsFromOptimizedCodeMap(index);
@@ -1053,14 +1057,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());
}
}
@@ -1137,10 +1141,8 @@ Handle<Code> Compiler::GetOptimizedCode(Handle<JSFunction> function,
Handle<Code> current_code,
ConcurrencyMode mode,
BailoutId osr_ast_id) {
- if (osr_ast_id.IsNone()) { // No cache for OSR.
- Handle<Code> cached_code = GetCodeFromOptimizedCodeMap(function);
- if (!cached_code.is_null()) return cached_code;
- }
+ Handle<Code> cached_code = GetCodeFromOptimizedCodeMap(function, osr_ast_id);
+ if (!cached_code.is_null()) return cached_code;
SmartPointer<CompilationInfo> info(new CompilationInfoWithZone(function));
Isolate* isolate = info->isolate();
@@ -1210,7 +1212,7 @@ Handle<Code> Compiler::GetConcurrentlyOptimizedCode(OptimizedCompileJob* job) {
Compiler::RecordFunctionCompilation(
Logger::LAZY_COMPILE_TAG, info.get(), shared);
if (info->shared_info()->SearchOptimizedCodeMap(
- info->context()->native_context()) == -1) {
+ info->context()->native_context(), info->osr_ast_id()) == -1) {
InsertCodeIntoOptimizedCodeMap(info.get());
}
« no previous file with comments | « src/code-stubs-hydrogen.cc ('k') | src/factory.cc » ('j') | src/mark-compact.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698