| OLD | NEW |
| 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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 // optimizations. When using the always_opt flag we disregard the | 453 // optimizations. When using the always_opt flag we disregard the |
| 454 // optimizable marker in the code object and optimize anyway. This | 454 // optimizable marker in the code object and optimize anyway. This |
| 455 // is safe as long as the unoptimized code has deoptimization | 455 // is safe as long as the unoptimized code has deoptimization |
| 456 // support. | 456 // support. |
| 457 ASSERT(FLAG_always_opt || info()->shared_info()->code()->optimizable()); | 457 ASSERT(FLAG_always_opt || info()->shared_info()->code()->optimizable()); |
| 458 ASSERT(info()->shared_info()->has_deoptimization_support()); | 458 ASSERT(info()->shared_info()->has_deoptimization_support()); |
| 459 | 459 |
| 460 if (FLAG_trace_hydrogen) { | 460 if (FLAG_trace_hydrogen) { |
| 461 Handle<String> name = info()->function()->debug_name(); | 461 Handle<String> name = info()->function()->debug_name(); |
| 462 PrintF("-----------------------------------------------------------\n"); | 462 PrintF("-----------------------------------------------------------\n"); |
| 463 PrintF("Compiling method %s using hydrogen\n", *name->ToCString()); | 463 PrintF("Compiling method %s using hydrogen\n", name->ToCString().get()); |
| 464 isolate()->GetHTracer()->TraceCompilation(info()); | 464 isolate()->GetHTracer()->TraceCompilation(info()); |
| 465 } | 465 } |
| 466 | 466 |
| 467 // Type-check the function. | 467 // Type-check the function. |
| 468 AstTyper::Run(info()); | 468 AstTyper::Run(info()); |
| 469 | 469 |
| 470 graph_builder_ = FLAG_emit_opt_code_positions | 470 graph_builder_ = FLAG_emit_opt_code_positions |
| 471 ? new(info()->zone()) HOptimizedGraphBuilderWithPositions(info()) | 471 ? new(info()->zone()) HOptimizedGraphBuilderWithPositions(info()) |
| 472 : new(info()->zone()) HOptimizedGraphBuilder(info()); | 472 : new(info()->zone()) HOptimizedGraphBuilder(info()); |
| 473 | 473 |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 info->SetOptimizing(BailoutId::None()); | 1093 info->SetOptimizing(BailoutId::None()); |
| 1094 } | 1094 } |
| 1095 | 1095 |
| 1096 VMState<COMPILER> state(isolate); | 1096 VMState<COMPILER> state(isolate); |
| 1097 PostponeInterruptsScope postpone(isolate); | 1097 PostponeInterruptsScope postpone(isolate); |
| 1098 | 1098 |
| 1099 int compiled_size = shared->end_position() - shared->start_position(); | 1099 int compiled_size = shared->end_position() - shared->start_position(); |
| 1100 isolate->counters()->total_compile_size()->Increment(compiled_size); | 1100 isolate->counters()->total_compile_size()->Increment(compiled_size); |
| 1101 | 1101 |
| 1102 { | 1102 { |
| 1103 CompilationHandleScope handle_scope(*info); | 1103 CompilationHandleScope handle_scope(info.get()); |
| 1104 | 1104 |
| 1105 if (!compiling_for_osr && InstallCodeFromOptimizedCodeMap(*info)) { | 1105 if (!compiling_for_osr && InstallCodeFromOptimizedCodeMap(info.get())) { |
| 1106 return true; | 1106 return true; |
| 1107 } | 1107 } |
| 1108 | 1108 |
| 1109 if (Parser::Parse(*info)) { | 1109 if (Parser::Parse(info.get())) { |
| 1110 LanguageMode language_mode = info->function()->language_mode(); | 1110 LanguageMode language_mode = info->function()->language_mode(); |
| 1111 info->SetLanguageMode(language_mode); | 1111 info->SetLanguageMode(language_mode); |
| 1112 shared->set_language_mode(language_mode); | 1112 shared->set_language_mode(language_mode); |
| 1113 info->SaveHandles(); | 1113 info->SaveHandles(); |
| 1114 | 1114 |
| 1115 if (Rewriter::Rewrite(*info) && Scope::Analyze(*info)) { | 1115 if (Rewriter::Rewrite(info.get()) && Scope::Analyze(info.get())) { |
| 1116 RecompileJob* job = new(info->zone()) RecompileJob(*info); | 1116 RecompileJob* job = new(info->zone()) RecompileJob(info.get()); |
| 1117 RecompileJob::Status status = job->CreateGraph(); | 1117 RecompileJob::Status status = job->CreateGraph(); |
| 1118 if (status == RecompileJob::SUCCEEDED) { | 1118 if (status == RecompileJob::SUCCEEDED) { |
| 1119 info.Detach(); | 1119 info.Detach(); |
| 1120 shared->code()->set_profiler_ticks(0); | 1120 shared->code()->set_profiler_ticks(0); |
| 1121 isolate->optimizing_compiler_thread()->QueueForOptimization(job); | 1121 isolate->optimizing_compiler_thread()->QueueForOptimization(job); |
| 1122 ASSERT(!isolate->has_pending_exception()); | 1122 ASSERT(!isolate->has_pending_exception()); |
| 1123 return true; | 1123 return true; |
| 1124 } else if (status == RecompileJob::BAILED_OUT) { | 1124 } else if (status == RecompileJob::BAILED_OUT) { |
| 1125 isolate->clear_pending_exception(); | 1125 isolate->clear_pending_exception(); |
| 1126 InstallFullCode(*info); | 1126 InstallFullCode(info.get()); |
| 1127 } | 1127 } |
| 1128 } | 1128 } |
| 1129 } | 1129 } |
| 1130 } | 1130 } |
| 1131 | 1131 |
| 1132 if (isolate->has_pending_exception()) isolate->clear_pending_exception(); | 1132 if (isolate->has_pending_exception()) isolate->clear_pending_exception(); |
| 1133 return false; | 1133 return false; |
| 1134 } | 1134 } |
| 1135 | 1135 |
| 1136 | 1136 |
| 1137 Handle<Code> Compiler::InstallOptimizedCode(RecompileJob* job) { | 1137 Handle<Code> Compiler::InstallOptimizedCode(RecompileJob* job) { |
| 1138 SmartPointer<CompilationInfo> info(job->info()); | 1138 SmartPointer<CompilationInfo> info(job->info()); |
| 1139 // The function may have already been optimized by OSR. Simply continue. | 1139 // The function may have already been optimized by OSR. Simply continue. |
| 1140 // Except when OSR already disabled optimization for some reason. | 1140 // Except when OSR already disabled optimization for some reason. |
| 1141 if (info->shared_info()->optimization_disabled()) { | 1141 if (info->shared_info()->optimization_disabled()) { |
| 1142 info->AbortOptimization(); | 1142 info->AbortOptimization(); |
| 1143 InstallFullCode(*info); | 1143 InstallFullCode(info.get()); |
| 1144 if (FLAG_trace_concurrent_recompilation) { | 1144 if (FLAG_trace_concurrent_recompilation) { |
| 1145 PrintF(" ** aborting optimization for "); | 1145 PrintF(" ** aborting optimization for "); |
| 1146 info->closure()->PrintName(); | 1146 info->closure()->PrintName(); |
| 1147 PrintF(" as it has been disabled.\n"); | 1147 PrintF(" as it has been disabled.\n"); |
| 1148 } | 1148 } |
| 1149 ASSERT(!info->closure()->IsInRecompileQueue()); | 1149 ASSERT(!info->closure()->IsInRecompileQueue()); |
| 1150 return Handle<Code>::null(); | 1150 return Handle<Code>::null(); |
| 1151 } | 1151 } |
| 1152 | 1152 |
| 1153 Isolate* isolate = info->isolate(); | 1153 Isolate* isolate = info->isolate(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1165 status = job->AbortOptimization(); | 1165 status = job->AbortOptimization(); |
| 1166 } else if (isolate->DebuggerHasBreakPoints()) { | 1166 } else if (isolate->DebuggerHasBreakPoints()) { |
| 1167 info->set_bailout_reason(kDebuggerIsActive); | 1167 info->set_bailout_reason(kDebuggerIsActive); |
| 1168 status = job->AbortOptimization(); | 1168 status = job->AbortOptimization(); |
| 1169 } else { | 1169 } else { |
| 1170 status = job->GenerateAndInstallCode(); | 1170 status = job->GenerateAndInstallCode(); |
| 1171 ASSERT(status == RecompileJob::SUCCEEDED || | 1171 ASSERT(status == RecompileJob::SUCCEEDED || |
| 1172 status == RecompileJob::BAILED_OUT); | 1172 status == RecompileJob::BAILED_OUT); |
| 1173 } | 1173 } |
| 1174 | 1174 |
| 1175 InstallCodeCommon(*info); | 1175 InstallCodeCommon(info.get()); |
| 1176 if (status == RecompileJob::SUCCEEDED) { | 1176 if (status == RecompileJob::SUCCEEDED) { |
| 1177 Handle<Code> code = info->code(); | 1177 Handle<Code> code = info->code(); |
| 1178 ASSERT(info->shared_info()->scope_info() != ScopeInfo::Empty(isolate)); | 1178 ASSERT(info->shared_info()->scope_info() != ScopeInfo::Empty(isolate)); |
| 1179 info->closure()->ReplaceCode(*code); | 1179 info->closure()->ReplaceCode(*code); |
| 1180 if (info->shared_info()->SearchOptimizedCodeMap( | 1180 if (info->shared_info()->SearchOptimizedCodeMap( |
| 1181 info->closure()->context()->native_context()) == -1) { | 1181 info->closure()->context()->native_context()) == -1) { |
| 1182 InsertCodeIntoOptimizedCodeMap(*info); | 1182 InsertCodeIntoOptimizedCodeMap(info.get()); |
| 1183 } | 1183 } |
| 1184 if (FLAG_trace_concurrent_recompilation) { | 1184 if (FLAG_trace_concurrent_recompilation) { |
| 1185 PrintF(" ** Optimized code for "); | 1185 PrintF(" ** Optimized code for "); |
| 1186 info->closure()->PrintName(); | 1186 info->closure()->PrintName(); |
| 1187 PrintF(" installed.\n"); | 1187 PrintF(" installed.\n"); |
| 1188 } | 1188 } |
| 1189 } else { | 1189 } else { |
| 1190 info->AbortOptimization(); | 1190 info->AbortOptimization(); |
| 1191 InstallFullCode(*info); | 1191 InstallFullCode(info.get()); |
| 1192 } | 1192 } |
| 1193 // Optimized code is finally replacing unoptimized code. Reset the latter's | 1193 // Optimized code is finally replacing unoptimized code. Reset the latter's |
| 1194 // profiler ticks to prevent too soon re-opt after a deopt. | 1194 // profiler ticks to prevent too soon re-opt after a deopt. |
| 1195 info->shared_info()->code()->set_profiler_ticks(0); | 1195 info->shared_info()->code()->set_profiler_ticks(0); |
| 1196 ASSERT(!info->closure()->IsInRecompileQueue()); | 1196 ASSERT(!info->closure()->IsInRecompileQueue()); |
| 1197 return (status == RecompileJob::SUCCEEDED) ? info->code() | 1197 return (status == RecompileJob::SUCCEEDED) ? info->code() |
| 1198 : Handle<Code>::null(); | 1198 : Handle<Code>::null(); |
| 1199 } | 1199 } |
| 1200 | 1200 |
| 1201 | 1201 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1361 AllowHandleDereference allow_deref; | 1361 AllowHandleDereference allow_deref; |
| 1362 bool tracing_on = info()->IsStub() | 1362 bool tracing_on = info()->IsStub() |
| 1363 ? FLAG_trace_hydrogen_stubs | 1363 ? FLAG_trace_hydrogen_stubs |
| 1364 : (FLAG_trace_hydrogen && | 1364 : (FLAG_trace_hydrogen && |
| 1365 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1365 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
| 1366 return (tracing_on && | 1366 return (tracing_on && |
| 1367 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1367 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
| 1368 } | 1368 } |
| 1369 | 1369 |
| 1370 } } // namespace v8::internal | 1370 } } // namespace v8::internal |
| OLD | NEW |