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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 253 |
254 static bool AlwaysFullCompiler(Isolate* isolate) { | 254 static bool AlwaysFullCompiler(Isolate* isolate) { |
255 return FLAG_always_full_compiler || IsDebuggerActive(isolate); | 255 return FLAG_always_full_compiler || IsDebuggerActive(isolate); |
256 } | 256 } |
257 | 257 |
258 | 258 |
259 void OptimizingCompiler::RecordOptimizationStats() { | 259 void OptimizingCompiler::RecordOptimizationStats() { |
260 Handle<JSFunction> function = info()->closure(); | 260 Handle<JSFunction> function = info()->closure(); |
261 int opt_count = function->shared()->opt_count(); | 261 int opt_count = function->shared()->opt_count(); |
262 function->shared()->set_opt_count(opt_count + 1); | 262 function->shared()->set_opt_count(opt_count + 1); |
263 double ms_creategraph = | 263 double ms_creategraph = time_taken_to_create_graph_.InMillisecondsF(); |
264 static_cast<double>(time_taken_to_create_graph_) / 1000; | 264 double ms_optimize = time_taken_to_optimize_.InMillisecondsF(); |
265 double ms_optimize = static_cast<double>(time_taken_to_optimize_) / 1000; | 265 double ms_codegen = time_taken_to_codegen_.InMillisecondsF(); |
266 double ms_codegen = static_cast<double>(time_taken_to_codegen_) / 1000; | |
267 if (FLAG_trace_opt) { | 266 if (FLAG_trace_opt) { |
268 PrintF("[optimizing "); | 267 PrintF("[optimizing "); |
269 function->ShortPrint(); | 268 function->ShortPrint(); |
270 PrintF(" - took %0.3f, %0.3f, %0.3f ms]\n", ms_creategraph, ms_optimize, | 269 PrintF(" - took %0.3f, %0.3f, %0.3f ms]\n", ms_creategraph, ms_optimize, |
271 ms_codegen); | 270 ms_codegen); |
272 } | 271 } |
273 if (FLAG_trace_opt_stats) { | 272 if (FLAG_trace_opt_stats) { |
274 static double compilation_time = 0.0; | 273 static double compilation_time = 0.0; |
275 static int compiled_functions = 0; | 274 static int compiled_functions = 0; |
276 static int code_size = 0; | 275 static int code_size = 0; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 info()->AbortOptimization(); | 365 info()->AbortOptimization(); |
367 return SetLastStatus(BAILED_OUT); | 366 return SetLastStatus(BAILED_OUT); |
368 } | 367 } |
369 | 368 |
370 // Recompile the unoptimized version of the code if the current version | 369 // Recompile the unoptimized version of the code if the current version |
371 // doesn't have deoptimization support. Alternatively, we may decide to | 370 // doesn't have deoptimization support. Alternatively, we may decide to |
372 // run the full code generator to get a baseline for the compile-time | 371 // run the full code generator to get a baseline for the compile-time |
373 // performance of the hydrogen-based compiler. | 372 // performance of the hydrogen-based compiler. |
374 bool should_recompile = !info()->shared_info()->has_deoptimization_support(); | 373 bool should_recompile = !info()->shared_info()->has_deoptimization_support(); |
375 if (should_recompile || FLAG_hydrogen_stats) { | 374 if (should_recompile || FLAG_hydrogen_stats) { |
376 int64_t start_ticks = 0; | 375 ElapsedTimer timer; |
377 if (FLAG_hydrogen_stats) { | 376 if (FLAG_hydrogen_stats) { |
378 start_ticks = OS::Ticks(); | 377 timer.Start(); |
379 } | 378 } |
380 CompilationInfoWithZone unoptimized(info()->shared_info()); | 379 CompilationInfoWithZone unoptimized(info()->shared_info()); |
381 // Note that we use the same AST that we will use for generating the | 380 // Note that we use the same AST that we will use for generating the |
382 // optimized code. | 381 // optimized code. |
383 unoptimized.SetFunction(info()->function()); | 382 unoptimized.SetFunction(info()->function()); |
384 unoptimized.SetScope(info()->scope()); | 383 unoptimized.SetScope(info()->scope()); |
385 unoptimized.SetContext(info()->context()); | 384 unoptimized.SetContext(info()->context()); |
386 if (should_recompile) unoptimized.EnableDeoptimizationSupport(); | 385 if (should_recompile) unoptimized.EnableDeoptimizationSupport(); |
387 bool succeeded = FullCodeGenerator::MakeCode(&unoptimized); | 386 bool succeeded = FullCodeGenerator::MakeCode(&unoptimized); |
388 if (should_recompile) { | 387 if (should_recompile) { |
389 if (!succeeded) return SetLastStatus(FAILED); | 388 if (!succeeded) return SetLastStatus(FAILED); |
390 Handle<SharedFunctionInfo> shared = info()->shared_info(); | 389 Handle<SharedFunctionInfo> shared = info()->shared_info(); |
391 shared->EnableDeoptimizationSupport(*unoptimized.code()); | 390 shared->EnableDeoptimizationSupport(*unoptimized.code()); |
392 // The existing unoptimized code was replaced with the new one. | 391 // The existing unoptimized code was replaced with the new one. |
393 Compiler::RecordFunctionCompilation( | 392 Compiler::RecordFunctionCompilation( |
394 Logger::LAZY_COMPILE_TAG, &unoptimized, shared); | 393 Logger::LAZY_COMPILE_TAG, &unoptimized, shared); |
395 } | 394 } |
396 if (FLAG_hydrogen_stats) { | 395 if (FLAG_hydrogen_stats) { |
397 int64_t ticks = OS::Ticks() - start_ticks; | 396 isolate()->GetHStatistics()->IncrementFullCodeGen(timer.Elapsed()); |
398 isolate()->GetHStatistics()->IncrementFullCodeGen(ticks); | |
399 } | 397 } |
400 } | 398 } |
401 | 399 |
402 // Check that the unoptimized, shared code is ready for | 400 // Check that the unoptimized, shared code is ready for |
403 // optimizations. When using the always_opt flag we disregard the | 401 // optimizations. When using the always_opt flag we disregard the |
404 // optimizable marker in the code object and optimize anyway. This | 402 // optimizable marker in the code object and optimize anyway. This |
405 // is safe as long as the unoptimized code has deoptimization | 403 // is safe as long as the unoptimized code has deoptimization |
406 // support. | 404 // support. |
407 ASSERT(FLAG_always_opt || info()->shared_info()->code()->optimizable()); | 405 ASSERT(FLAG_always_opt || info()->shared_info()->code()->optimizable()); |
408 ASSERT(info()->shared_info()->has_deoptimization_support()); | 406 ASSERT(info()->shared_info()->has_deoptimization_support()); |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 Handle<Script>(info->script()), | 1235 Handle<Script>(info->script()), |
1238 Handle<Code>(info->code()), | 1236 Handle<Code>(info->code()), |
1239 info)); | 1237 info)); |
1240 } | 1238 } |
1241 | 1239 |
1242 | 1240 |
1243 CompilationPhase::CompilationPhase(const char* name, CompilationInfo* info) | 1241 CompilationPhase::CompilationPhase(const char* name, CompilationInfo* info) |
1244 : name_(name), info_(info), zone_(info->isolate()) { | 1242 : name_(name), info_(info), zone_(info->isolate()) { |
1245 if (FLAG_hydrogen_stats) { | 1243 if (FLAG_hydrogen_stats) { |
1246 info_zone_start_allocation_size_ = info->zone()->allocation_size(); | 1244 info_zone_start_allocation_size_ = info->zone()->allocation_size(); |
1247 start_ticks_ = OS::Ticks(); | 1245 timer_.Start(); |
1248 } | 1246 } |
1249 } | 1247 } |
1250 | 1248 |
1251 | 1249 |
1252 CompilationPhase::~CompilationPhase() { | 1250 CompilationPhase::~CompilationPhase() { |
1253 if (FLAG_hydrogen_stats) { | 1251 if (FLAG_hydrogen_stats) { |
1254 unsigned size = zone()->allocation_size(); | 1252 unsigned size = zone()->allocation_size(); |
1255 size += info_->zone()->allocation_size() - info_zone_start_allocation_size_; | 1253 size += info_->zone()->allocation_size() - info_zone_start_allocation_size_; |
1256 int64_t ticks = OS::Ticks() - start_ticks_; | 1254 isolate()->GetHStatistics()->SaveTiming(name_, timer_.Elapsed(), size); |
1257 isolate()->GetHStatistics()->SaveTiming(name_, ticks, size); | |
1258 } | 1255 } |
1259 } | 1256 } |
1260 | 1257 |
1261 | 1258 |
1262 bool CompilationPhase::ShouldProduceTraceOutput() const { | 1259 bool CompilationPhase::ShouldProduceTraceOutput() const { |
1263 // Trace if the appropriate trace flag is set and the phase name's first | 1260 // Trace if the appropriate trace flag is set and the phase name's first |
1264 // character is in the FLAG_trace_phase command line parameter. | 1261 // character is in the FLAG_trace_phase command line parameter. |
1265 AllowHandleDereference allow_deref; | 1262 AllowHandleDereference allow_deref; |
1266 bool tracing_on = info()->IsStub() | 1263 bool tracing_on = info()->IsStub() |
1267 ? FLAG_trace_hydrogen_stubs | 1264 ? FLAG_trace_hydrogen_stubs |
1268 : (FLAG_trace_hydrogen && | 1265 : (FLAG_trace_hydrogen && |
1269 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1266 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
1270 return (tracing_on && | 1267 return (tracing_on && |
1271 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1268 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
1272 } | 1269 } |
1273 | 1270 |
1274 } } // namespace v8::internal | 1271 } } // namespace v8::internal |
OLD | NEW |