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

Side by Side Diff: src/compiler.cc

Issue 23769007: Fix concurrent osr. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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/compiler.h ('k') | no next file » | 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 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 } 1047 }
1048 } 1048 }
1049 } 1049 }
1050 } 1050 }
1051 1051
1052 if (isolate->has_pending_exception()) isolate->clear_pending_exception(); 1052 if (isolate->has_pending_exception()) isolate->clear_pending_exception();
1053 return false; 1053 return false;
1054 } 1054 }
1055 1055
1056 1056
1057 bool Compiler::InstallOptimizedCode(OptimizingCompiler* optimizing_compiler) { 1057 Handle<Code> Compiler::InstallOptimizedCode(
1058 OptimizingCompiler* optimizing_compiler) {
1058 SmartPointer<CompilationInfo> info(optimizing_compiler->info()); 1059 SmartPointer<CompilationInfo> info(optimizing_compiler->info());
1059 // The function may have already been optimized by OSR. Simply continue. 1060 // The function may have already been optimized by OSR. Simply continue.
1060 // Except when OSR already disabled optimization for some reason. 1061 // Except when OSR already disabled optimization for some reason.
1061 if (info->shared_info()->optimization_disabled()) { 1062 if (info->shared_info()->optimization_disabled()) {
1062 info->AbortOptimization(); 1063 info->AbortOptimization();
1063 InstallFullCode(*info); 1064 InstallFullCode(*info);
1064 if (FLAG_trace_concurrent_recompilation) { 1065 if (FLAG_trace_concurrent_recompilation) {
1065 PrintF(" ** aborting optimization for "); 1066 PrintF(" ** aborting optimization for ");
1066 info->closure()->PrintName(); 1067 info->closure()->PrintName();
1067 PrintF(" as it has been disabled.\n"); 1068 PrintF(" as it has been disabled.\n");
1068 } 1069 }
1069 ASSERT(!info->closure()->IsMarkedForInstallingRecompiledCode()); 1070 ASSERT(!info->closure()->IsMarkedForInstallingRecompiledCode());
1070 return false; 1071 return Handle<Code>::null();
1071 } 1072 }
1072 1073
1073 Isolate* isolate = info->isolate(); 1074 Isolate* isolate = info->isolate();
1074 VMState<COMPILER> state(isolate); 1075 VMState<COMPILER> state(isolate);
1075 Logger::TimerEventScope timer( 1076 Logger::TimerEventScope timer(
1076 isolate, Logger::TimerEventScope::v8_recompile_synchronous); 1077 isolate, Logger::TimerEventScope::v8_recompile_synchronous);
1077 // If crankshaft succeeded, install the optimized code else install 1078 // If crankshaft succeeded, install the optimized code else install
1078 // the unoptimized code. 1079 // the unoptimized code.
1079 OptimizingCompiler::Status status = optimizing_compiler->last_status(); 1080 OptimizingCompiler::Status status = optimizing_compiler->last_status();
1080 if (info->HasAbortedDueToDependencyChange()) { 1081 if (info->HasAbortedDueToDependencyChange()) {
(...skipping 26 matching lines...) Expand all
1107 PrintF(" installed.\n"); 1108 PrintF(" installed.\n");
1108 } 1109 }
1109 } else { 1110 } else {
1110 info->AbortOptimization(); 1111 info->AbortOptimization();
1111 InstallFullCode(*info); 1112 InstallFullCode(*info);
1112 } 1113 }
1113 // Optimized code is finally replacing unoptimized code. Reset the latter's 1114 // Optimized code is finally replacing unoptimized code. Reset the latter's
1114 // profiler ticks to prevent too soon re-opt after a deopt. 1115 // profiler ticks to prevent too soon re-opt after a deopt.
1115 info->shared_info()->code()->set_profiler_ticks(0); 1116 info->shared_info()->code()->set_profiler_ticks(0);
1116 ASSERT(!info->closure()->IsMarkedForInstallingRecompiledCode()); 1117 ASSERT(!info->closure()->IsMarkedForInstallingRecompiledCode());
1117 return status == OptimizingCompiler::SUCCEEDED; 1118 return (status == OptimizingCompiler::SUCCEEDED) ? info->code()
1119 : Handle<Code>::null();
1118 } 1120 }
1119 1121
1120 1122
1121 static uint32_t CurrentPcOffset(Isolate* isolate, 1123 static uint32_t CurrentPcOffset(Isolate* isolate,
1122 Handle<JSFunction> function, 1124 Handle<JSFunction> function,
1123 Handle<Code> unoptimized) { 1125 Handle<Code> unoptimized) {
1124 JavaScriptFrameIterator it(isolate); 1126 JavaScriptFrameIterator it(isolate);
1125 JavaScriptFrame* frame = it.frame(); 1127 JavaScriptFrame* frame = it.frame();
1126 ASSERT(frame->function() == *function); 1128 ASSERT(frame->function() == *function);
1127 ASSERT(frame->LookupCode() == *unoptimized); 1129 ASSERT(frame->LookupCode() == *unoptimized);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 function->PrintName(); 1217 function->PrintName();
1216 PrintF("]\n"); 1218 PrintF("]\n");
1217 } 1219 }
1218 return Handle<Code>::null(); 1220 return Handle<Code>::null();
1219 } 1221 }
1220 1222
1221 OptimizingCompiler* compiler = isolate->optimizing_compiler_thread()-> 1223 OptimizingCompiler* compiler = isolate->optimizing_compiler_thread()->
1222 FindReadyOSRCandidate(function, pc_offset); 1224 FindReadyOSRCandidate(function, pc_offset);
1223 1225
1224 if (compiler != NULL) { 1226 if (compiler != NULL) {
1227 BailoutId ast_id = compiler->info()->osr_ast_id();
titzer 2013/09/10 11:02:42 I'm not sure why you pulled this variable out of i
1228
1225 if (FLAG_trace_osr) { 1229 if (FLAG_trace_osr) {
1226 PrintF("[COSR - optimization complete for "); 1230 PrintF("[COSR - optimization complete for ");
1227 function->PrintName(); 1231 function->PrintName();
1228 PrintF(", restoring interrupt calls]\n"); 1232 PrintF(", restoring interrupt calls]\n");
1229 } 1233 }
1230 Deoptimizer::RevertInterruptCode(isolate, *unoptimized); 1234 Deoptimizer::RevertInterruptCode(isolate, *unoptimized);
1231 1235
1232 // TODO(titzer): don't install the OSR code into the function. 1236 // TODO(titzer): don't install the OSR code into the function.
1233 bool succeeded = InstallOptimizedCode(compiler); 1237 Handle<Code> result = InstallOptimizedCode(compiler);
1234 1238
1235 isolate->optimizing_compiler_thread()->RemoveStaleOSRCandidates(); 1239 isolate->optimizing_compiler_thread()->RemoveStaleOSRCandidates();
1236 1240
1237 if (!succeeded) { 1241 if (result.is_null()) {
1238 if (FLAG_trace_osr) { 1242 if (FLAG_trace_osr) {
1239 PrintF("[COSR - optimization failed for "); 1243 PrintF("[COSR - optimization failed for ");
1240 function->PrintName(); 1244 function->PrintName();
1241 PrintF("]\n"); 1245 PrintF("]\n");
1242 } 1246 }
1243 return Handle<Code>::null(); 1247 return Handle<Code>::null();
1244 } 1248 }
1245 Handle<Code> result = compiler->info()->code();
1246
1247 // Check the result matches our expectations, and don't use it otherwise. 1249 // Check the result matches our expectations, and don't use it otherwise.
1248 if (result->kind() == Code::OPTIMIZED_FUNCTION) { 1250 if (result->kind() == Code::OPTIMIZED_FUNCTION) {
1249 DeoptimizationInputData* data = 1251 DeoptimizationInputData* data =
1250 DeoptimizationInputData::cast(result->deoptimization_data()); 1252 DeoptimizationInputData::cast(result->deoptimization_data());
1251 1253
1252 if (data->OsrPcOffset()->value() >= 0) { 1254 if (data->OsrPcOffset()->value() >= 0) {
1253 BailoutId ast_id = compiler->info()->osr_ast_id();
1254 ASSERT(BailoutId(data->OsrAstId()->value()) == ast_id); 1255 ASSERT(BailoutId(data->OsrAstId()->value()) == ast_id);
1255 if (FLAG_trace_osr) { 1256 if (FLAG_trace_osr) {
1256 PrintF("[COSR - entry at AST id %d, offset %d in optimized code]\n", 1257 PrintF("[COSR - entry at AST id %d, offset %d in optimized code]\n",
1257 ast_id.ToInt(), data->OsrPcOffset()->value()); 1258 ast_id.ToInt(), data->OsrPcOffset()->value());
1258 } 1259 }
1259 return result; 1260 return result;
1260 } 1261 }
1261 } 1262 }
1262 return Handle<Code>::null(); 1263 return Handle<Code>::null();
1263 } 1264 }
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 AllowHandleDereference allow_deref; 1442 AllowHandleDereference allow_deref;
1442 bool tracing_on = info()->IsStub() 1443 bool tracing_on = info()->IsStub()
1443 ? FLAG_trace_hydrogen_stubs 1444 ? FLAG_trace_hydrogen_stubs
1444 : (FLAG_trace_hydrogen && 1445 : (FLAG_trace_hydrogen &&
1445 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); 1446 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter));
1446 return (tracing_on && 1447 return (tracing_on &&
1447 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); 1448 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL);
1448 } 1449 }
1449 1450
1450 } } // namespace v8::internal 1451 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698