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

Side by Side Diff: src/interpreter/interpreter.cc

Issue 1640213002: [Interpreter] Add option to trace bytecode execution. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Review comments Created 4 years, 10 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
« no previous file with comments | « src/interpreter/bytecodes.cc ('k') | src/objects.h » ('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 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 "src/ast/prettyprinter.h"
7 #include "src/code-factory.h" 8 #include "src/code-factory.h"
8 #include "src/compiler.h" 9 #include "src/compiler.h"
9 #include "src/compiler/interpreter-assembler.h" 10 #include "src/compiler/interpreter-assembler.h"
10 #include "src/factory.h" 11 #include "src/factory.h"
11 #include "src/interpreter/bytecode-generator.h" 12 #include "src/interpreter/bytecode-generator.h"
12 #include "src/interpreter/bytecodes.h" 13 #include "src/interpreter/bytecodes.h"
13 #include "src/zone.h" 14 #include "src/zone.h"
14 15
15 namespace v8 { 16 namespace v8 {
16 namespace internal { 17 namespace internal {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 Handle<Code> code = assembler.GenerateCode(); \ 54 Handle<Code> code = assembler.GenerateCode(); \
54 handler_table->set(static_cast<int>(Bytecode::k##Name), *code); \ 55 handler_table->set(static_cast<int>(Bytecode::k##Name), *code); \
55 } 56 }
56 BYTECODE_LIST(GENERATE_CODE) 57 BYTECODE_LIST(GENERATE_CODE)
57 #undef GENERATE_CODE 58 #undef GENERATE_CODE
58 } 59 }
59 } 60 }
60 61
61 62
62 bool Interpreter::MakeBytecode(CompilationInfo* info) { 63 bool Interpreter::MakeBytecode(CompilationInfo* info) {
64 if (FLAG_print_bytecode || FLAG_print_source || FLAG_print_ast) {
65 OFStream os(stdout);
66 base::SmartArrayPointer<char> name = info->GetDebugName();
67 os << "[generating bytecode for function: " << info->GetDebugName().get()
68 << "]" << std::endl
69 << std::flush;
70 }
71
72 #ifdef DEBUG
73 if (info->parse_info() && FLAG_print_source) {
74 OFStream os(stdout);
75 os << "--- Source from AST ---" << std::endl
76 << PrettyPrinter(info->isolate()).PrintProgram(info->literal())
77 << std::endl
78 << std::flush;
79 }
80
81 if (info->parse_info() && FLAG_print_ast) {
82 OFStream os(stdout);
83 os << "--- AST ---" << std::endl
84 << AstPrinter(info->isolate()).PrintProgram(info->literal()) << std::endl
85 << std::flush;
86 }
87 #endif // DEBUG
88
63 BytecodeGenerator generator(info->isolate(), info->zone()); 89 BytecodeGenerator generator(info->isolate(), info->zone());
64 info->EnsureFeedbackVector(); 90 info->EnsureFeedbackVector();
65 Handle<BytecodeArray> bytecodes = generator.MakeBytecode(info); 91 Handle<BytecodeArray> bytecodes = generator.MakeBytecode(info);
66 if (FLAG_print_bytecode) { 92 if (FLAG_print_bytecode) {
67 OFStream os(stdout); 93 OFStream os(stdout);
68 os << "Function: " << info->GetDebugName().get() << std::endl; 94 os << "Function: " << info->GetDebugName().get() << std::endl;
69 bytecodes->Print(os); 95 bytecodes->Print(os);
70 os << std::flush; 96 os << std::flush;
71 } 97 }
72 98
73 info->SetBytecodeArray(bytecodes); 99 info->SetBytecodeArray(bytecodes);
74 info->SetCode(info->isolate()->builtins()->InterpreterEntryTrampoline()); 100 info->SetCode(info->isolate()->builtins()->InterpreterEntryTrampoline());
75 return true; 101 return true;
76 } 102 }
77 103
78 104
79 bool Interpreter::IsInterpreterTableInitialized( 105 bool Interpreter::IsInterpreterTableInitialized(
80 Handle<FixedArray> handler_table) { 106 Handle<FixedArray> handler_table) {
107 if (FLAG_trace_ignition) {
108 // Regenerate table to add bytecode tracing operations.
109 return false;
110 }
81 DCHECK(handler_table->length() == static_cast<int>(Bytecode::kLast) + 1); 111 DCHECK(handler_table->length() == static_cast<int>(Bytecode::kLast) + 1);
82 return handler_table->get(0) != isolate_->heap()->undefined_value(); 112 return handler_table->get(0) != isolate_->heap()->undefined_value();
83 } 113 }
84 114
85
86 // LdaZero 115 // LdaZero
87 // 116 //
88 // Load literal '0' into the accumulator. 117 // Load literal '0' into the accumulator.
89 void Interpreter::DoLdaZero(compiler::InterpreterAssembler* assembler) { 118 void Interpreter::DoLdaZero(compiler::InterpreterAssembler* assembler) {
90 Node* zero_value = __ NumberConstant(0.0); 119 Node* zero_value = __ NumberConstant(0.0);
91 __ SetAccumulator(zero_value); 120 __ SetAccumulator(zero_value);
92 __ Dispatch(); 121 __ Dispatch();
93 } 122 }
94 123
95 124
(...skipping 1761 matching lines...) Expand 10 before | Expand all | Expand 10 after
1857 Node* index_reg = __ BytecodeOperandReg(0); 1886 Node* index_reg = __ BytecodeOperandReg(0);
1858 Node* index = __ LoadRegister(index_reg); 1887 Node* index = __ LoadRegister(index_reg);
1859 Node* result = __ CallRuntime(Runtime::kForInStep, index); 1888 Node* result = __ CallRuntime(Runtime::kForInStep, index);
1860 __ SetAccumulator(result); 1889 __ SetAccumulator(result);
1861 __ Dispatch(); 1890 __ Dispatch();
1862 } 1891 }
1863 1892
1864 } // namespace interpreter 1893 } // namespace interpreter
1865 } // namespace internal 1894 } // namespace internal
1866 } // namespace v8 1895 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecodes.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698