Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(320)

Side by Side Diff: src/compiler.cc

Issue 12831003: Parallel recompilation: fix concurrency issues. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/optimizing-compiler-thread.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 928 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 info->SaveHandles(); 939 info->SaveHandles();
940 940
941 if (Rewriter::Rewrite(*info) && Scope::Analyze(*info)) { 941 if (Rewriter::Rewrite(*info) && Scope::Analyze(*info)) {
942 OptimizingCompiler* compiler = 942 OptimizingCompiler* compiler =
943 new(info->zone()) OptimizingCompiler(*info); 943 new(info->zone()) OptimizingCompiler(*info);
944 OptimizingCompiler::Status status = compiler->CreateGraph(); 944 OptimizingCompiler::Status status = compiler->CreateGraph();
945 if (status == OptimizingCompiler::SUCCEEDED) { 945 if (status == OptimizingCompiler::SUCCEEDED) {
946 // Do a scavenge to put off the next scavenge as far as possible. 946 // Do a scavenge to put off the next scavenge as far as possible.
947 // This may ease the issue that GVN blocks the next scavenge. 947 // This may ease the issue that GVN blocks the next scavenge.
948 isolate->heap()->CollectGarbage(NEW_SPACE, "parallel recompile"); 948 isolate->heap()->CollectGarbage(NEW_SPACE, "parallel recompile");
949 closure->MarkInRecompileQueue();
950 shared->code()->set_profiler_ticks(0); 949 shared->code()->set_profiler_ticks(0);
951 info.Detach(); 950 info.Detach();
952 isolate->optimizing_compiler_thread()->QueueForOptimization(compiler); 951 isolate->optimizing_compiler_thread()->QueueForOptimization(compiler);
953 } else if (status == OptimizingCompiler::BAILED_OUT) { 952 } else if (status == OptimizingCompiler::BAILED_OUT) {
954 isolate->clear_pending_exception(); 953 isolate->clear_pending_exception();
955 InstallFullCode(*info); 954 InstallFullCode(*info);
956 } 955 }
957 } 956 }
958 } 957 }
959 } 958 }
(...skipping 11 matching lines...) Expand all
971 *check_code, 970 *check_code,
972 *replacement_code); 971 *replacement_code);
973 } 972 }
974 973
975 if (isolate->has_pending_exception()) isolate->clear_pending_exception(); 974 if (isolate->has_pending_exception()) isolate->clear_pending_exception();
976 } 975 }
977 976
978 977
979 void Compiler::InstallOptimizedCode(OptimizingCompiler* optimizing_compiler) { 978 void Compiler::InstallOptimizedCode(OptimizingCompiler* optimizing_compiler) {
980 SmartPointer<CompilationInfo> info(optimizing_compiler->info()); 979 SmartPointer<CompilationInfo> info(optimizing_compiler->info());
981 ASSERT(info->closure()->IsMarkedForInstallingRecompiledCode()); 980 // The function may have already been optimized by OSR. Simply continue.
982 // While waiting for the optimizer thread, OSR may have already done all 981 // Except when OSR already disabled optimization for some reason.
983 // the work and disabled optimization of this function for some reason.
984 if (info->shared_info()->optimization_disabled()) { 982 if (info->shared_info()->optimization_disabled()) {
985 info->SetCode(Handle<Code>(info->shared_info()->code())); 983 info->SetCode(Handle<Code>(info->shared_info()->code()));
986 InstallFullCode(*info); 984 InstallFullCode(*info);
985 if (FLAG_trace_parallel_recompilation) {
986 PrintF(" ** aborting optimization for ");
987 info->closure()->PrintName();
988 PrintF(" as it has been disabled.\n");
989 }
990 ASSERT(!info->closure()->IsMarkedForInstallingRecompiledCode());
987 return; 991 return;
988 } 992 }
989 993
990 Isolate* isolate = info->isolate(); 994 Isolate* isolate = info->isolate();
991 VMState state(isolate, PARALLEL_COMPILER); 995 VMState state(isolate, PARALLEL_COMPILER);
992 Logger::TimerEventScope timer( 996 Logger::TimerEventScope timer(
993 isolate, Logger::TimerEventScope::v8_recompile_synchronous); 997 isolate, Logger::TimerEventScope::v8_recompile_synchronous);
994 // If crankshaft succeeded, install the optimized code else install 998 // If crankshaft succeeded, install the optimized code else install
995 // the unoptimized code. 999 // the unoptimized code.
996 OptimizingCompiler::Status status = optimizing_compiler->last_status(); 1000 OptimizingCompiler::Status status = optimizing_compiler->last_status();
(...skipping 21 matching lines...) Expand all
1018 info->closure()->PrintName(); 1022 info->closure()->PrintName();
1019 PrintF(" installed.\n"); 1023 PrintF(" installed.\n");
1020 } 1024 }
1021 } else { 1025 } else {
1022 info->SetCode(Handle<Code>(info->shared_info()->code())); 1026 info->SetCode(Handle<Code>(info->shared_info()->code()));
1023 InstallFullCode(*info); 1027 InstallFullCode(*info);
1024 } 1028 }
1025 // Optimized code is finally replacing unoptimized code. Reset the latter's 1029 // Optimized code is finally replacing unoptimized code. Reset the latter's
1026 // profiler ticks to prevent too soon re-opt after a deopt. 1030 // profiler ticks to prevent too soon re-opt after a deopt.
1027 info->shared_info()->code()->set_profiler_ticks(0); 1031 info->shared_info()->code()->set_profiler_ticks(0);
1032 ASSERT(!info->closure()->IsMarkedForInstallingRecompiledCode());
1028 } 1033 }
1029 1034
1030 1035
1031 Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal, 1036 Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal,
1032 Handle<Script> script) { 1037 Handle<Script> script) {
1033 // Precondition: code has been parsed and scopes have been analyzed. 1038 // Precondition: code has been parsed and scopes have been analyzed.
1034 CompilationInfoWithZone info(script); 1039 CompilationInfoWithZone info(script);
1035 info.SetFunction(literal); 1040 info.SetFunction(literal);
1036 info.SetScope(literal->scope()); 1041 info.SetScope(literal->scope());
1037 info.SetLanguageMode(literal->scope()->language_mode()); 1042 info.SetLanguageMode(literal->scope()->language_mode());
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 } 1157 }
1153 } 1158 }
1154 1159
1155 GDBJIT(AddCode(Handle<String>(shared->DebugName()), 1160 GDBJIT(AddCode(Handle<String>(shared->DebugName()),
1156 Handle<Script>(info->script()), 1161 Handle<Script>(info->script()),
1157 Handle<Code>(info->code()), 1162 Handle<Code>(info->code()),
1158 info)); 1163 info));
1159 } 1164 }
1160 1165
1161 } } // namespace v8::internal 1166 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/optimizing-compiler-thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698