| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 156 |
| 157 // static | 157 // static |
| 158 int Interpreter::InterruptBudget() { | 158 int Interpreter::InterruptBudget() { |
| 159 return FLAG_interrupt_budget * kCodeSizeMultiplier; | 159 return FLAG_interrupt_budget * kCodeSizeMultiplier; |
| 160 } | 160 } |
| 161 | 161 |
| 162 InterpreterCompilationJob::InterpreterCompilationJob(CompilationInfo* info) | 162 InterpreterCompilationJob::InterpreterCompilationJob(CompilationInfo* info) |
| 163 : CompilationJob(info->isolate(), info, "Ignition"), generator_(info) {} | 163 : CompilationJob(info->isolate(), info, "Ignition"), generator_(info) {} |
| 164 | 164 |
| 165 InterpreterCompilationJob::Status InterpreterCompilationJob::PrepareJobImpl() { | 165 InterpreterCompilationJob::Status InterpreterCompilationJob::PrepareJobImpl() { |
| 166 if (FLAG_print_bytecode || FLAG_print_ast) { | 166 CodeGenerator::MakeCodePrologue(info(), "interpreter"); |
| 167 if (FLAG_print_bytecode) { |
| 167 OFStream os(stdout); | 168 OFStream os(stdout); |
| 168 std::unique_ptr<char[]> name = info()->GetDebugName(); | 169 std::unique_ptr<char[]> name = info()->GetDebugName(); |
| 169 os << "[generating bytecode for function: " << info()->GetDebugName().get() | 170 os << "[generating bytecode for function: " << info()->GetDebugName().get() |
| 170 << "]" << std::endl | 171 << "]" << std::endl |
| 171 << std::flush; | 172 << std::flush; |
| 172 } | 173 } |
| 173 | 174 |
| 174 #ifdef DEBUG | |
| 175 if (info()->parse_info() && FLAG_print_ast) { | |
| 176 OFStream os(stdout); | |
| 177 os << "--- AST ---" << std::endl | |
| 178 << AstPrinter(info()->isolate()).PrintProgram(info()->literal()) | |
| 179 << std::endl | |
| 180 << std::flush; | |
| 181 } | |
| 182 #endif // DEBUG | |
| 183 | |
| 184 return SUCCEEDED; | 175 return SUCCEEDED; |
| 185 } | 176 } |
| 186 | 177 |
| 187 InterpreterCompilationJob::Status InterpreterCompilationJob::ExecuteJobImpl() { | 178 InterpreterCompilationJob::Status InterpreterCompilationJob::ExecuteJobImpl() { |
| 188 // TODO(5203): These timers aren't thread safe, move to using the CompilerJob | 179 // TODO(5203): These timers aren't thread safe, move to using the CompilerJob |
| 189 // timers. | 180 // timers. |
| 190 RuntimeCallTimerScope runtimeTimer(info()->isolate(), | 181 RuntimeCallTimerScope runtimeTimer(info()->isolate(), |
| 191 &RuntimeCallStats::CompileIgnition); | 182 &RuntimeCallStats::CompileIgnition); |
| 192 TimerEventScope<TimerEventCompileIgnition> timer(info()->isolate()); | 183 TimerEventScope<TimerEventCompileIgnition> timer(info()->isolate()); |
| 193 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileIgnition"); | 184 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileIgnition"); |
| 194 | 185 |
| 195 generator()->GenerateBytecode(stack_limit()); | 186 generator()->GenerateBytecode(stack_limit()); |
| 196 | 187 |
| 197 if (generator()->HasStackOverflow()) { | 188 if (generator()->HasStackOverflow()) { |
| 198 return FAILED; | 189 return FAILED; |
| 199 } | 190 } |
| 200 return SUCCEEDED; | 191 return SUCCEEDED; |
| 201 } | 192 } |
| 202 | 193 |
| 203 InterpreterCompilationJob::Status InterpreterCompilationJob::FinalizeJobImpl() { | 194 InterpreterCompilationJob::Status InterpreterCompilationJob::FinalizeJobImpl() { |
| 204 Handle<BytecodeArray> bytecodes = generator()->FinalizeBytecode(isolate()); | 195 Handle<BytecodeArray> bytecodes = generator()->FinalizeBytecode(isolate()); |
| 205 if (generator()->HasStackOverflow()) { | 196 if (generator()->HasStackOverflow()) { |
| 206 return FAILED; | 197 return FAILED; |
| 207 } | 198 } |
| 208 | 199 |
| 209 CodeGenerator::MakeCodePrologue(info(), "interpreter"); | |
| 210 | |
| 211 if (FLAG_print_bytecode) { | 200 if (FLAG_print_bytecode) { |
| 212 OFStream os(stdout); | 201 OFStream os(stdout); |
| 213 bytecodes->Print(os); | 202 bytecodes->Print(os); |
| 214 os << std::flush; | 203 os << std::flush; |
| 215 } | 204 } |
| 216 | 205 |
| 217 info()->SetBytecodeArray(bytecodes); | 206 info()->SetBytecodeArray(bytecodes); |
| 218 info()->SetCode(info()->isolate()->builtins()->InterpreterEntryTrampoline()); | 207 info()->SetCode(info()->isolate()->builtins()->InterpreterEntryTrampoline()); |
| 219 return SUCCEEDED; | 208 return SUCCEEDED; |
| 220 } | 209 } |
| (...skipping 2569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2790 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, | 2779 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, |
| 2791 __ SmiTag(new_state)); | 2780 __ SmiTag(new_state)); |
| 2792 __ SetAccumulator(old_state); | 2781 __ SetAccumulator(old_state); |
| 2793 | 2782 |
| 2794 __ Dispatch(); | 2783 __ Dispatch(); |
| 2795 } | 2784 } |
| 2796 | 2785 |
| 2797 } // namespace interpreter | 2786 } // namespace interpreter |
| 2798 } // namespace internal | 2787 } // namespace internal |
| 2799 } // namespace v8 | 2788 } // namespace v8 |
| OLD | NEW |