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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 } | 389 } |
390 RecordOptimizationStats(); | 390 RecordOptimizationStats(); |
391 return SetLastStatus(SUCCEEDED); | 391 return SetLastStatus(SUCCEEDED); |
392 } | 392 } |
393 | 393 |
394 | 394 |
395 static bool GenerateCode(CompilationInfo* info) { | 395 static bool GenerateCode(CompilationInfo* info) { |
396 bool is_optimizing = V8::UseCrankshaft() && | 396 bool is_optimizing = V8::UseCrankshaft() && |
397 !info->IsCompilingForDebugging() && | 397 !info->IsCompilingForDebugging() && |
398 info->IsOptimizing(); | 398 info->IsOptimizing(); |
| 399 Logger* logger = info->isolate()->logger(); |
399 if (is_optimizing) { | 400 if (is_optimizing) { |
| 401 Logger::TimerEventScope timer( |
| 402 logger, Logger::TimerEventScope::v8_recompile_synchronous); |
400 return MakeCrankshaftCode(info); | 403 return MakeCrankshaftCode(info); |
401 } else { | 404 } else { |
402 if (info->IsOptimizing()) { | 405 if (info->IsOptimizing()) { |
403 // Have the CompilationInfo decide if the compilation should be | 406 // Have the CompilationInfo decide if the compilation should be |
404 // BASE or NONOPT. | 407 // BASE or NONOPT. |
405 info->DisableOptimization(); | 408 info->DisableOptimization(); |
406 } | 409 } |
| 410 Logger::TimerEventScope timer( |
| 411 logger, Logger::TimerEventScope::v8_compile_full_code); |
407 return FullCodeGenerator::MakeCode(info); | 412 return FullCodeGenerator::MakeCode(info); |
408 } | 413 } |
409 } | 414 } |
410 | 415 |
411 | 416 |
412 static bool MakeCode(CompilationInfo* info) { | 417 static bool MakeCode(CompilationInfo* info) { |
413 // Precondition: code has been parsed. Postcondition: the code field in | 418 // Precondition: code has been parsed. Postcondition: the code field in |
414 // the compilation info is set if compilation succeeded. | 419 // the compilation info is set if compilation succeeded. |
415 ASSERT(info->function() != NULL); | 420 ASSERT(info->function() != NULL); |
416 return Rewriter::Rewrite(info) && Scope::Analyze(info) && GenerateCode(info); | 421 return Rewriter::Rewrite(info) && Scope::Analyze(info) && GenerateCode(info); |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 ASSERT(info->code().is_null()); | 850 ASSERT(info->code().is_null()); |
846 return false; | 851 return false; |
847 } | 852 } |
848 | 853 |
849 | 854 |
850 void Compiler::RecompileParallel(Handle<JSFunction> closure) { | 855 void Compiler::RecompileParallel(Handle<JSFunction> closure) { |
851 if (closure->IsInRecompileQueue()) return; | 856 if (closure->IsInRecompileQueue()) return; |
852 ASSERT(closure->IsMarkedForParallelRecompilation()); | 857 ASSERT(closure->IsMarkedForParallelRecompilation()); |
853 | 858 |
854 Isolate* isolate = closure->GetIsolate(); | 859 Isolate* isolate = closure->GetIsolate(); |
| 860 Logger::TimerEventScope timer( |
| 861 isolate->logger(), Logger::TimerEventScope::v8_recompile_synchronous); |
| 862 |
855 if (!isolate->optimizing_compiler_thread()->IsQueueAvailable()) { | 863 if (!isolate->optimizing_compiler_thread()->IsQueueAvailable()) { |
856 if (FLAG_trace_parallel_recompilation) { | 864 if (FLAG_trace_parallel_recompilation) { |
857 PrintF(" ** Compilation queue, will retry opting on next run.\n"); | 865 PrintF(" ** Compilation queue, will retry opting on next run.\n"); |
858 } | 866 } |
859 return; | 867 return; |
860 } | 868 } |
861 | 869 |
862 SmartPointer<CompilationInfo> info(new CompilationInfoWithZone(closure)); | 870 SmartPointer<CompilationInfo> info(new CompilationInfoWithZone(closure)); |
863 VMState state(isolate, PARALLEL_COMPILER_PROLOGUE); | 871 VMState state(isolate, PARALLEL_COMPILER); |
864 PostponeInterruptsScope postpone(isolate); | 872 PostponeInterruptsScope postpone(isolate); |
865 | 873 |
866 Handle<SharedFunctionInfo> shared = info->shared_info(); | 874 Handle<SharedFunctionInfo> shared = info->shared_info(); |
867 int compiled_size = shared->end_position() - shared->start_position(); | 875 int compiled_size = shared->end_position() - shared->start_position(); |
868 isolate->counters()->total_compile_size()->Increment(compiled_size); | 876 isolate->counters()->total_compile_size()->Increment(compiled_size); |
869 info->SetOptimizing(BailoutId::None()); | 877 info->SetOptimizing(BailoutId::None()); |
870 | 878 |
871 { | 879 { |
872 CompilationHandleScope handle_scope(*info); | 880 CompilationHandleScope handle_scope(*info); |
873 | 881 |
(...skipping 27 matching lines...) Expand all Loading... |
901 } | 909 } |
902 | 910 |
903 if (isolate->has_pending_exception()) { | 911 if (isolate->has_pending_exception()) { |
904 isolate->clear_pending_exception(); | 912 isolate->clear_pending_exception(); |
905 } | 913 } |
906 } | 914 } |
907 | 915 |
908 | 916 |
909 void Compiler::InstallOptimizedCode(OptimizingCompiler* optimizing_compiler) { | 917 void Compiler::InstallOptimizedCode(OptimizingCompiler* optimizing_compiler) { |
910 SmartPointer<CompilationInfo> info(optimizing_compiler->info()); | 918 SmartPointer<CompilationInfo> info(optimizing_compiler->info()); |
| 919 Isolate* isolate = info->isolate(); |
| 920 VMState state(isolate, PARALLEL_COMPILER); |
| 921 Logger::TimerEventScope timer( |
| 922 isolate->logger(), Logger::TimerEventScope::v8_recompile_synchronous); |
911 // If crankshaft succeeded, install the optimized code else install | 923 // If crankshaft succeeded, install the optimized code else install |
912 // the unoptimized code. | 924 // the unoptimized code. |
913 OptimizingCompiler::Status status = optimizing_compiler->last_status(); | 925 OptimizingCompiler::Status status = optimizing_compiler->last_status(); |
914 if (status != OptimizingCompiler::SUCCEEDED) { | 926 if (status != OptimizingCompiler::SUCCEEDED) { |
915 optimizing_compiler->info()->set_bailout_reason( | 927 optimizing_compiler->info()->set_bailout_reason( |
916 "failed/bailed out last time"); | 928 "failed/bailed out last time"); |
917 status = optimizing_compiler->AbortOptimization(); | 929 status = optimizing_compiler->AbortOptimization(); |
918 } else { | 930 } else { |
919 status = optimizing_compiler->GenerateAndInstallCode(); | 931 status = optimizing_compiler->GenerateAndInstallCode(); |
920 ASSERT(status == OptimizingCompiler::SUCCEEDED || | 932 ASSERT(status == OptimizingCompiler::SUCCEEDED || |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 } | 1073 } |
1062 } | 1074 } |
1063 | 1075 |
1064 GDBJIT(AddCode(Handle<String>(shared->DebugName()), | 1076 GDBJIT(AddCode(Handle<String>(shared->DebugName()), |
1065 Handle<Script>(info->script()), | 1077 Handle<Script>(info->script()), |
1066 Handle<Code>(info->code()), | 1078 Handle<Code>(info->code()), |
1067 info)); | 1079 info)); |
1068 } | 1080 } |
1069 | 1081 |
1070 } } // namespace v8::internal | 1082 } } // namespace v8::internal |
OLD | NEW |