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