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

Side by Side Diff: src/optimizing-compiler-thread.cc

Issue 11419012: Introduce helper functions to test parallel recompilation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 1 month 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
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 Barrier_AtomicIncrement(&queue_length_, static_cast<Atomic32>(-1)); 65 Barrier_AtomicIncrement(&queue_length_, static_cast<Atomic32>(-1));
66 66
67 ASSERT(!optimizing_compiler->info()->closure()->IsOptimized()); 67 ASSERT(!optimizing_compiler->info()->closure()->IsOptimized());
68 68
69 OptimizingCompiler::Status status = optimizing_compiler->OptimizeGraph(); 69 OptimizingCompiler::Status status = optimizing_compiler->OptimizeGraph();
70 ASSERT(status != OptimizingCompiler::FAILED); 70 ASSERT(status != OptimizingCompiler::FAILED);
71 // Prevent an unused-variable error in release mode. 71 // Prevent an unused-variable error in release mode.
72 USE(status); 72 USE(status);
73 73
74 output_queue_.Enqueue(optimizing_compiler); 74 output_queue_.Enqueue(optimizing_compiler);
75 isolate_->stack_guard()->RequestCodeReadyEvent(); 75 if (!FLAG_manual_parallel_recompilation) {
76 isolate_->stack_guard()->RequestCodeReadyEvent();
77 } else {
78 // In manual mode, do not trigger a code ready event.
79 // Instead, wait for the optimized functions to be installed manually.
80 output_queue_semaphore_->Signal();
81 }
76 82
77 if (FLAG_trace_parallel_recompilation) { 83 if (FLAG_trace_parallel_recompilation) {
78 time_spent_compiling_ += OS::Ticks() - compiling_start; 84 time_spent_compiling_ += OS::Ticks() - compiling_start;
79 } 85 }
80 } 86 }
81 } 87 }
82 88
83 89
84 void OptimizingCompilerThread::Stop() { 90 void OptimizingCompilerThread::Stop() {
85 Release_Store(&stop_thread_, static_cast<AtomicWord>(true)); 91 Release_Store(&stop_thread_, static_cast<AtomicWord>(true));
86 input_queue_semaphore_->Signal(); 92 input_queue_semaphore_->Signal();
87 stop_semaphore_->Wait(); 93 stop_semaphore_->Wait();
88 94
89 if (FLAG_trace_parallel_recompilation) { 95 if (FLAG_trace_parallel_recompilation) {
90 double compile_time = static_cast<double>(time_spent_compiling_); 96 double compile_time = static_cast<double>(time_spent_compiling_);
91 double total_time = static_cast<double>(time_spent_total_); 97 double total_time = static_cast<double>(time_spent_total_);
92 double percentage = (compile_time * 100) / total_time; 98 double percentage = (compile_time * 100) / total_time;
93 PrintF(" ** Compiler thread did %.2f%% useful work\n", percentage); 99 PrintF(" ** Compiler thread did %.2f%% useful work\n", percentage);
94 } 100 }
95 } 101 }
96 102
97 103
98 void OptimizingCompilerThread::InstallOptimizedFunctions() { 104 void OptimizingCompilerThread::InstallOptimizedFunctions() {
99 HandleScope handle_scope(isolate_); 105 HandleScope handle_scope(isolate_);
100 int functions_installed = 0; 106 int functions_installed = 0;
101 while (!output_queue_.IsEmpty()) { 107 while (!output_queue_.IsEmpty()) {
108 if (FLAG_manual_parallel_recompilation) {
109 output_queue_semaphore_->Wait();
110 }
102 OptimizingCompiler* compiler = NULL; 111 OptimizingCompiler* compiler = NULL;
103 output_queue_.Dequeue(&compiler); 112 output_queue_.Dequeue(&compiler);
104 Compiler::InstallOptimizedCode(compiler); 113 Compiler::InstallOptimizedCode(compiler);
105 functions_installed++; 114 functions_installed++;
106 } 115 }
107 if (FLAG_trace_parallel_recompilation && functions_installed != 0) { 116 if (FLAG_trace_parallel_recompilation && functions_installed != 0) {
108 PrintF(" ** Installed %d function(s).\n", functions_installed); 117 PrintF(" ** Installed %d function(s).\n", functions_installed);
109 } 118 }
110 } 119 }
111 120
112 121
122 Handle<SharedFunctionInfo>
123 OptimizingCompilerThread::InstallNextOptimizedFunction() {
124 ASSERT(FLAG_manual_parallel_recompilation);
125 output_queue_semaphore_->Wait();
126 OptimizingCompiler* compiler = NULL;
127 output_queue_.Dequeue(&compiler);
128 Compiler::InstallOptimizedCode(compiler);
129 return compiler->info()->shared_info();
130 }
131
132
113 void OptimizingCompilerThread::QueueForOptimization( 133 void OptimizingCompilerThread::QueueForOptimization(
114 OptimizingCompiler* optimizing_compiler) { 134 OptimizingCompiler* optimizing_compiler) {
115 input_queue_.Enqueue(optimizing_compiler); 135 input_queue_.Enqueue(optimizing_compiler);
116 input_queue_semaphore_->Signal(); 136 input_queue_semaphore_->Signal();
117 } 137 }
118 138
119 #ifdef DEBUG 139 #ifdef DEBUG
120 bool OptimizingCompilerThread::IsOptimizerThread() { 140 bool OptimizingCompilerThread::IsOptimizerThread() {
121 if (!FLAG_parallel_recompilation) return false; 141 if (!FLAG_parallel_recompilation) return false;
122 return ThreadId::Current().ToInteger() == thread_id_; 142 return ThreadId::Current().ToInteger() == thread_id_;
123 } 143 }
124 #endif 144 #endif
125 145
126 146
127 } } // namespace v8::internal 147 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/optimizing-compiler-thread.h ('k') | src/runtime.h » ('j') | src/runtime.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698