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

Side by Side 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: remove extra slot per entry for osr ast id. 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 unified diff | Download patch | Annotate | Revision Log
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 946 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 return; 957 return;
958 } 958 }
959 Compiler::RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared); 959 Compiler::RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared);
960 } 960 }
961 961
962 962
963 static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) { 963 static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) {
964 Handle<Code> code = info->code(); 964 Handle<Code> code = info->code();
965 if (code->kind() != Code::OPTIMIZED_FUNCTION) return; // Nothing to do. 965 if (code->kind() != Code::OPTIMIZED_FUNCTION) return; // Nothing to do.
966 966
967 // Cache non-OSR optimized code. 967 // Cache optimized code.
968 if (FLAG_cache_optimized_code && !info->is_osr()) { 968 if (FLAG_cache_optimized_code) {
969 Handle<JSFunction> function = info->closure(); 969 Handle<JSFunction> function = info->closure();
970 Handle<SharedFunctionInfo> shared(function->shared()); 970 Handle<SharedFunctionInfo> shared(function->shared());
971 Handle<FixedArray> literals(function->literals()); 971 Handle<FixedArray> literals(function->literals());
972 Handle<Context> native_context(function->context()->native_context()); 972 Handle<Context> native_context(function->context()->native_context());
973 SharedFunctionInfo::AddToOptimizedCodeMap( 973 SharedFunctionInfo::AddToOptimizedCodeMap(
974 shared, native_context, code, literals); 974 shared, native_context, code, literals, info->osr_ast_id());
975 } 975 }
976 } 976 }
977 977
978 978
979 static bool InstallCodeFromOptimizedCodeMap(CompilationInfo* info) { 979 static bool InstallCodeFromOptimizedCodeMap(CompilationInfo* info) {
980 if (!info->IsOptimizing()) return false; // Nothing to look up. 980 if (!info->IsOptimizing()) return false; // Nothing to look up.
981 981
982 // Lookup non-OSR optimized code. 982 // Lookup optimized code.
983 if (FLAG_cache_optimized_code && !info->is_osr()) { 983 if (FLAG_cache_optimized_code) {
984 Handle<SharedFunctionInfo> shared = info->shared_info(); 984 Handle<SharedFunctionInfo> shared = info->shared_info();
985 Handle<JSFunction> function = info->closure(); 985 Handle<JSFunction> function = info->closure();
986 ASSERT(!function.is_null()); 986 ASSERT(!function.is_null());
987 Handle<Context> native_context(function->context()->native_context()); 987 Handle<Context> native_context(function->context()->native_context());
988 int index = shared->SearchOptimizedCodeMap(*native_context); 988 int index = shared->SearchOptimizedCodeMap(*native_context,
989 info->osr_ast_id());
989 if (index > 0) { 990 if (index > 0) {
990 if (FLAG_trace_opt) { 991 if (FLAG_trace_opt) {
991 PrintF("[found optimized code for "); 992 PrintF("[found optimized code for ");
992 function->ShortPrint(); 993 function->ShortPrint();
994 if (info->is_osr()) {
995 PrintF(" with osr ast id %d ", info->osr_ast_id().ToInt());
996 }
993 PrintF("]\n"); 997 PrintF("]\n");
994 } 998 }
995 // Caching of optimized code enabled and optimized code found. 999 // Caching of optimized code enabled and optimized code found.
996 shared->InstallFromOptimizedCodeMap(*function, index); 1000 shared->InstallFromOptimizedCodeMap(*function, index);
1001 info->SetCode(Handle<Code>(function->code()));
997 return true; 1002 return true;
998 } 1003 }
999 } 1004 }
1000 return false; 1005 return false;
1001 } 1006 }
1002 1007
1003 1008
1004 bool Compiler::CompileLazy(CompilationInfo* info) { 1009 bool Compiler::CompileLazy(CompilationInfo* info) {
1005 Isolate* isolate = info->isolate(); 1010 Isolate* isolate = info->isolate();
1006 1011
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 1100
1096 VMState<COMPILER> state(isolate); 1101 VMState<COMPILER> state(isolate);
1097 PostponeInterruptsScope postpone(isolate); 1102 PostponeInterruptsScope postpone(isolate);
1098 1103
1099 int compiled_size = shared->end_position() - shared->start_position(); 1104 int compiled_size = shared->end_position() - shared->start_position();
1100 isolate->counters()->total_compile_size()->Increment(compiled_size); 1105 isolate->counters()->total_compile_size()->Increment(compiled_size);
1101 1106
1102 { 1107 {
1103 CompilationHandleScope handle_scope(*info); 1108 CompilationHandleScope handle_scope(*info);
1104 1109
1105 if (!compiling_for_osr && InstallCodeFromOptimizedCodeMap(*info)) { 1110 if (InstallCodeFromOptimizedCodeMap(*info)) {
1106 return true; 1111 return true;
1107 } 1112 }
1108 1113
1109 if (Parser::Parse(*info)) { 1114 if (Parser::Parse(*info)) {
1110 LanguageMode language_mode = info->function()->language_mode(); 1115 LanguageMode language_mode = info->function()->language_mode();
1111 info->SetLanguageMode(language_mode); 1116 info->SetLanguageMode(language_mode);
1112 shared->set_language_mode(language_mode); 1117 shared->set_language_mode(language_mode);
1113 info->SaveHandles(); 1118 info->SaveHandles();
1114 1119
1115 if (Rewriter::Rewrite(*info) && Scope::Analyze(*info)) { 1120 if (Rewriter::Rewrite(*info) && Scope::Analyze(*info)) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 ASSERT(status == RecompileJob::SUCCEEDED || 1176 ASSERT(status == RecompileJob::SUCCEEDED ||
1172 status == RecompileJob::BAILED_OUT); 1177 status == RecompileJob::BAILED_OUT);
1173 } 1178 }
1174 1179
1175 InstallCodeCommon(*info); 1180 InstallCodeCommon(*info);
1176 if (status == RecompileJob::SUCCEEDED) { 1181 if (status == RecompileJob::SUCCEEDED) {
1177 Handle<Code> code = info->code(); 1182 Handle<Code> code = info->code();
1178 ASSERT(info->shared_info()->scope_info() != ScopeInfo::Empty(isolate)); 1183 ASSERT(info->shared_info()->scope_info() != ScopeInfo::Empty(isolate));
1179 info->closure()->ReplaceCode(*code); 1184 info->closure()->ReplaceCode(*code);
1180 if (info->shared_info()->SearchOptimizedCodeMap( 1185 if (info->shared_info()->SearchOptimizedCodeMap(
1181 info->closure()->context()->native_context()) == -1) { 1186 info->closure()->context()->native_context(),
1187 info->osr_ast_id()) == -1) {
1182 InsertCodeIntoOptimizedCodeMap(*info); 1188 InsertCodeIntoOptimizedCodeMap(*info);
1183 } 1189 }
1184 if (FLAG_trace_concurrent_recompilation) { 1190 if (FLAG_trace_concurrent_recompilation) {
1185 PrintF(" ** Optimized code for "); 1191 PrintF(" ** Optimized code for ");
1186 info->closure()->PrintName(); 1192 info->closure()->PrintName();
1187 PrintF(" installed.\n"); 1193 PrintF(" installed.\n");
1188 } 1194 }
1189 } else { 1195 } else {
1190 info->AbortOptimization(); 1196 info->AbortOptimization();
1191 InstallFullCode(*info); 1197 InstallFullCode(*info);
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 AllowHandleDereference allow_deref; 1367 AllowHandleDereference allow_deref;
1362 bool tracing_on = info()->IsStub() 1368 bool tracing_on = info()->IsStub()
1363 ? FLAG_trace_hydrogen_stubs 1369 ? FLAG_trace_hydrogen_stubs
1364 : (FLAG_trace_hydrogen && 1370 : (FLAG_trace_hydrogen &&
1365 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); 1371 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter));
1366 return (tracing_on && 1372 return (tracing_on &&
1367 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); 1373 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL);
1368 } 1374 }
1369 1375
1370 } } // namespace v8::internal 1376 } } // namespace v8::internal
OLDNEW
« src/code-stubs-hydrogen.cc ('K') | « src/code-stubs-hydrogen.cc ('k') | src/factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698