| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
| 8 | 8 |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1125 if (!Rewriter::Rewrite(info)) return false; | 1125 if (!Rewriter::Rewrite(info)) return false; |
| 1126 if (!Scope::Analyze(info)) return false; | 1126 if (!Scope::Analyze(info)) return false; |
| 1127 ASSERT(info->scope() != NULL); | 1127 ASSERT(info->scope() != NULL); |
| 1128 return true; | 1128 return true; |
| 1129 } | 1129 } |
| 1130 | 1130 |
| 1131 | 1131 |
| 1132 static bool GetOptimizedCodeNow(CompilationInfo* info) { | 1132 static bool GetOptimizedCodeNow(CompilationInfo* info) { |
| 1133 if (!CompileOptimizedPrologue(info)) return false; | 1133 if (!CompileOptimizedPrologue(info)) return false; |
| 1134 | 1134 |
| 1135 Logger::TimerEventScope timer( | 1135 TimerEventScope<TimerEventRecompileSynchronous> timer(info->isolate()); |
| 1136 info->isolate(), Logger::TimerEventScope::v8_recompile_synchronous); | |
| 1137 | 1136 |
| 1138 OptimizedCompileJob job(info); | 1137 OptimizedCompileJob job(info); |
| 1139 if (job.CreateGraph() != OptimizedCompileJob::SUCCEEDED) return false; | 1138 if (job.CreateGraph() != OptimizedCompileJob::SUCCEEDED) return false; |
| 1140 if (job.OptimizeGraph() != OptimizedCompileJob::SUCCEEDED) return false; | 1139 if (job.OptimizeGraph() != OptimizedCompileJob::SUCCEEDED) return false; |
| 1141 if (job.GenerateCode() != OptimizedCompileJob::SUCCEEDED) return false; | 1140 if (job.GenerateCode() != OptimizedCompileJob::SUCCEEDED) return false; |
| 1142 | 1141 |
| 1143 // Success! | 1142 // Success! |
| 1144 ASSERT(!info->isolate()->has_pending_exception()); | 1143 ASSERT(!info->isolate()->has_pending_exception()); |
| 1145 InsertCodeIntoOptimizedCodeMap(info); | 1144 InsertCodeIntoOptimizedCodeMap(info); |
| 1146 Compiler::RecordFunctionCompilation( | 1145 Compiler::RecordFunctionCompilation( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1157 info->closure()->PrintName(); | 1156 info->closure()->PrintName(); |
| 1158 PrintF(" later.\n"); | 1157 PrintF(" later.\n"); |
| 1159 } | 1158 } |
| 1160 return false; | 1159 return false; |
| 1161 } | 1160 } |
| 1162 | 1161 |
| 1163 CompilationHandleScope handle_scope(info); | 1162 CompilationHandleScope handle_scope(info); |
| 1164 if (!CompileOptimizedPrologue(info)) return false; | 1163 if (!CompileOptimizedPrologue(info)) return false; |
| 1165 info->SaveHandles(); // Copy handles to the compilation handle scope. | 1164 info->SaveHandles(); // Copy handles to the compilation handle scope. |
| 1166 | 1165 |
| 1167 Logger::TimerEventScope timer( | 1166 TimerEventScope<TimerEventRecompileSynchronous> timer(info->isolate()); |
| 1168 isolate, Logger::TimerEventScope::v8_recompile_synchronous); | |
| 1169 | 1167 |
| 1170 OptimizedCompileJob* job = new(info->zone()) OptimizedCompileJob(info); | 1168 OptimizedCompileJob* job = new(info->zone()) OptimizedCompileJob(info); |
| 1171 OptimizedCompileJob::Status status = job->CreateGraph(); | 1169 OptimizedCompileJob::Status status = job->CreateGraph(); |
| 1172 if (status != OptimizedCompileJob::SUCCEEDED) return false; | 1170 if (status != OptimizedCompileJob::SUCCEEDED) return false; |
| 1173 isolate->optimizing_compiler_thread()->QueueForOptimization(job); | 1171 isolate->optimizing_compiler_thread()->QueueForOptimization(job); |
| 1174 | 1172 |
| 1175 if (FLAG_trace_concurrent_recompilation) { | 1173 if (FLAG_trace_concurrent_recompilation) { |
| 1176 PrintF(" ** Queued "); | 1174 PrintF(" ** Queued "); |
| 1177 info->closure()->PrintName(); | 1175 info->closure()->PrintName(); |
| 1178 if (info->is_osr()) { | 1176 if (info->is_osr()) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1230 } | 1228 } |
| 1231 | 1229 |
| 1232 | 1230 |
| 1233 Handle<Code> Compiler::GetConcurrentlyOptimizedCode(OptimizedCompileJob* job) { | 1231 Handle<Code> Compiler::GetConcurrentlyOptimizedCode(OptimizedCompileJob* job) { |
| 1234 // Take ownership of compilation info. Deleting compilation info | 1232 // Take ownership of compilation info. Deleting compilation info |
| 1235 // also tears down the zone and the recompile job. | 1233 // also tears down the zone and the recompile job. |
| 1236 SmartPointer<CompilationInfo> info(job->info()); | 1234 SmartPointer<CompilationInfo> info(job->info()); |
| 1237 Isolate* isolate = info->isolate(); | 1235 Isolate* isolate = info->isolate(); |
| 1238 | 1236 |
| 1239 VMState<COMPILER> state(isolate); | 1237 VMState<COMPILER> state(isolate); |
| 1240 Logger::TimerEventScope timer( | 1238 TimerEventScope<TimerEventRecompileSynchronous> timer(info->isolate()); |
| 1241 isolate, Logger::TimerEventScope::v8_recompile_synchronous); | |
| 1242 | 1239 |
| 1243 Handle<SharedFunctionInfo> shared = info->shared_info(); | 1240 Handle<SharedFunctionInfo> shared = info->shared_info(); |
| 1244 shared->code()->set_profiler_ticks(0); | 1241 shared->code()->set_profiler_ticks(0); |
| 1245 | 1242 |
| 1246 // 1) Optimization may have failed. | 1243 // 1) Optimization may have failed. |
| 1247 // 2) The function may have already been optimized by OSR. Simply continue. | 1244 // 2) The function may have already been optimized by OSR. Simply continue. |
| 1248 // Except when OSR already disabled optimization for some reason. | 1245 // Except when OSR already disabled optimization for some reason. |
| 1249 // 3) The code may have already been invalidated due to dependency change. | 1246 // 3) The code may have already been invalidated due to dependency change. |
| 1250 // 4) Debugger may have been activated. | 1247 // 4) Debugger may have been activated. |
| 1251 | 1248 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1336 AllowHandleDereference allow_deref; | 1333 AllowHandleDereference allow_deref; |
| 1337 bool tracing_on = info()->IsStub() | 1334 bool tracing_on = info()->IsStub() |
| 1338 ? FLAG_trace_hydrogen_stubs | 1335 ? FLAG_trace_hydrogen_stubs |
| 1339 : (FLAG_trace_hydrogen && | 1336 : (FLAG_trace_hydrogen && |
| 1340 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1337 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
| 1341 return (tracing_on && | 1338 return (tracing_on && |
| 1342 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1339 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
| 1343 } | 1340 } |
| 1344 | 1341 |
| 1345 } } // namespace v8::internal | 1342 } } // namespace v8::internal |
| OLD | NEW |