Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/interpreter/interpreter.h" | 5 #include "src/interpreter/interpreter.h" |
| 6 | 6 |
| 7 #include <fstream> | 7 #include <fstream> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 | 37 |
| 38 protected: | 38 protected: |
| 39 Status PrepareJobImpl() final; | 39 Status PrepareJobImpl() final; |
| 40 Status ExecuteJobImpl() final; | 40 Status ExecuteJobImpl() final; |
| 41 Status FinalizeJobImpl() final; | 41 Status FinalizeJobImpl() final; |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 BytecodeGenerator* generator() { return &generator_; } | 44 BytecodeGenerator* generator() { return &generator_; } |
| 45 | 45 |
| 46 BytecodeGenerator generator_; | 46 BytecodeGenerator generator_; |
| 47 RuntimeCallStats* runtime_call_stats_; | |
| 47 | 48 |
| 48 DISALLOW_COPY_AND_ASSIGN(InterpreterCompilationJob); | 49 DISALLOW_COPY_AND_ASSIGN(InterpreterCompilationJob); |
| 49 }; | 50 }; |
| 50 | 51 |
| 51 Interpreter::Interpreter(Isolate* isolate) : isolate_(isolate) { | 52 Interpreter::Interpreter(Isolate* isolate) : isolate_(isolate) { |
| 52 memset(dispatch_table_, 0, sizeof(dispatch_table_)); | 53 memset(dispatch_table_, 0, sizeof(dispatch_table_)); |
| 53 } | 54 } |
| 54 | 55 |
| 55 void Interpreter::Initialize() { | 56 void Interpreter::Initialize() { |
| 56 if (!ShouldInitializeDispatchTable()) return; | 57 if (!ShouldInitializeDispatchTable()) return; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 } | 154 } |
| 154 } | 155 } |
| 155 } | 156 } |
| 156 | 157 |
| 157 // static | 158 // static |
| 158 int Interpreter::InterruptBudget() { | 159 int Interpreter::InterruptBudget() { |
| 159 return FLAG_interrupt_budget * kCodeSizeMultiplier; | 160 return FLAG_interrupt_budget * kCodeSizeMultiplier; |
| 160 } | 161 } |
| 161 | 162 |
| 162 InterpreterCompilationJob::InterpreterCompilationJob(CompilationInfo* info) | 163 InterpreterCompilationJob::InterpreterCompilationJob(CompilationInfo* info) |
| 163 : CompilationJob(info->isolate(), info, "Ignition"), generator_(info) {} | 164 : CompilationJob(info->isolate(), info, "Ignition"), |
| 165 generator_(info), | |
| 166 runtime_call_stats_(info->isolate()->counters()->runtime_call_stats()) {} | |
| 164 | 167 |
| 165 InterpreterCompilationJob::Status InterpreterCompilationJob::PrepareJobImpl() { | 168 InterpreterCompilationJob::Status InterpreterCompilationJob::PrepareJobImpl() { |
| 166 CodeGenerator::MakeCodePrologue(info(), "interpreter"); | 169 CodeGenerator::MakeCodePrologue(info(), "interpreter"); |
| 167 if (FLAG_print_bytecode) { | 170 if (FLAG_print_bytecode) { |
| 168 OFStream os(stdout); | 171 OFStream os(stdout); |
| 169 std::unique_ptr<char[]> name = info()->GetDebugName(); | 172 std::unique_ptr<char[]> name = info()->GetDebugName(); |
| 170 os << "[generating bytecode for function: " << info()->GetDebugName().get() | 173 os << "[generating bytecode for function: " << info()->GetDebugName().get() |
| 171 << "]" << std::endl | 174 << "]" << std::endl |
| 172 << std::flush; | 175 << std::flush; |
| 173 } | 176 } |
| 174 | 177 |
| 175 return SUCCEEDED; | 178 return SUCCEEDED; |
| 176 } | 179 } |
| 177 | 180 |
| 178 InterpreterCompilationJob::Status InterpreterCompilationJob::ExecuteJobImpl() { | 181 InterpreterCompilationJob::Status InterpreterCompilationJob::ExecuteJobImpl() { |
| 179 // TODO(5203): These timers aren't thread safe, move to using the CompilerJob | 182 if (FLAG_runtime_stats && executed_on_background_thread()) { |
| 180 // timers. | 183 // Create separate runtime stats for background compilation. |
| 181 RuntimeCallTimerScope runtimeTimer(info()->isolate(), | 184 runtime_call_stats_ = new (info()->zone()) RuntimeCallStats(); |
|
jochen (gone - plz use gerrit)
2016/12/16 10:47:38
this allocates a potentially pretty large object e
Camillo Bruni
2016/12/16 11:42:54
I think we initially discussed to do exactly that,
rmcilroy
2016/12/16 23:48:05
Yeah good point. I was basing this on the approach
| |
| 182 &RuntimeCallStats::CompileIgnition); | 185 } |
| 183 TimerEventScope<TimerEventCompileIgnition> timer(info()->isolate()); | 186 RuntimeCallTimerScope runtimeTimer( |
| 187 runtime_call_stats_, executed_on_background_thread() | |
| 188 ? &RuntimeCallStats::CompileBackgroundIgnition | |
| 189 : &RuntimeCallStats::CompileIgnition); | |
| 184 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileIgnition"); | 190 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileIgnition"); |
|
Camillo Bruni
2016/12/16 09:25:05
Please add: TODO(lpy): add support for background
rmcilroy
2016/12/16 23:48:05
Done.
| |
| 185 | 191 |
| 186 generator()->GenerateBytecode(stack_limit()); | 192 generator()->GenerateBytecode(stack_limit()); |
| 187 | 193 |
| 188 if (generator()->HasStackOverflow()) { | 194 if (generator()->HasStackOverflow()) { |
| 189 return FAILED; | 195 return FAILED; |
| 190 } | 196 } |
| 191 return SUCCEEDED; | 197 return SUCCEEDED; |
| 192 } | 198 } |
| 193 | 199 |
| 194 InterpreterCompilationJob::Status InterpreterCompilationJob::FinalizeJobImpl() { | 200 InterpreterCompilationJob::Status InterpreterCompilationJob::FinalizeJobImpl() { |
| 201 // Add background runtime call stats. | |
| 202 if (executed_on_background_thread() && | |
| 203 FLAG_runtime_stats == | |
| 204 v8::tracing::TracingCategoryObserver::ENABLED_BY_NATIVE) { | |
| 205 info()->isolate()->counters()->runtime_call_stats()->Add( | |
| 206 runtime_call_stats_); | |
| 207 // Reset runtime_call_stats_. | |
| 208 runtime_call_stats_ = info()->isolate()->counters()->runtime_call_stats(); | |
| 209 } | |
| 210 | |
| 211 RuntimeCallTimerScope runtimeTimer( | |
| 212 runtime_call_stats_, &RuntimeCallStats::CompileIgnitionFinalization); | |
| 213 | |
| 195 Handle<BytecodeArray> bytecodes = generator()->FinalizeBytecode(isolate()); | 214 Handle<BytecodeArray> bytecodes = generator()->FinalizeBytecode(isolate()); |
| 196 if (generator()->HasStackOverflow()) { | 215 if (generator()->HasStackOverflow()) { |
| 197 return FAILED; | 216 return FAILED; |
| 198 } | 217 } |
| 199 | 218 |
| 200 if (FLAG_print_bytecode) { | 219 if (FLAG_print_bytecode) { |
| 201 OFStream os(stdout); | 220 OFStream os(stdout); |
| 202 bytecodes->Print(os); | 221 bytecodes->Print(os); |
| 203 os << std::flush; | 222 os << std::flush; |
| 204 } | 223 } |
| (...skipping 2661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2866 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, | 2885 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, |
| 2867 __ SmiTag(new_state)); | 2886 __ SmiTag(new_state)); |
| 2868 __ SetAccumulator(old_state); | 2887 __ SetAccumulator(old_state); |
| 2869 | 2888 |
| 2870 __ Dispatch(); | 2889 __ Dispatch(); |
| 2871 } | 2890 } |
| 2872 | 2891 |
| 2873 } // namespace interpreter | 2892 } // namespace interpreter |
| 2874 } // namespace internal | 2893 } // namespace internal |
| 2875 } // namespace v8 | 2894 } // namespace v8 |
| OLD | NEW |