| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 91 |
| 92 // Initialization should have been successful. | 92 // Initialization should have been successful. |
| 93 DCHECK(IsDispatchTableInitialized()); | 93 DCHECK(IsDispatchTableInitialized()); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void Interpreter::InstallBytecodeHandler(Zone* zone, Bytecode bytecode, | 96 void Interpreter::InstallBytecodeHandler(Zone* zone, Bytecode bytecode, |
| 97 OperandScale operand_scale, | 97 OperandScale operand_scale, |
| 98 BytecodeGeneratorFunc generator) { | 98 BytecodeGeneratorFunc generator) { |
| 99 if (!Bytecodes::BytecodeHasHandler(bytecode, operand_scale)) return; | 99 if (!Bytecodes::BytecodeHasHandler(bytecode, operand_scale)) return; |
| 100 | 100 |
| 101 // TODO(ishell): remove this when code stub assembler graphs verification | |
| 102 // is enabled for all stubs. | |
| 103 bool sav_csa_verify = FLAG_csa_verify; | |
| 104 // Enable verification only in mksnapshot. | |
| 105 FLAG_csa_verify = DEBUG_BOOL && FLAG_startup_blob != nullptr; | |
| 106 | |
| 107 InterpreterDispatchDescriptor descriptor(isolate_); | 101 InterpreterDispatchDescriptor descriptor(isolate_); |
| 108 compiler::CodeAssemblerState state( | 102 compiler::CodeAssemblerState state( |
| 109 isolate_, zone, descriptor, Code::ComputeFlags(Code::BYTECODE_HANDLER), | 103 isolate_, zone, descriptor, Code::ComputeFlags(Code::BYTECODE_HANDLER), |
| 110 Bytecodes::ToString(bytecode), Bytecodes::ReturnCount(bytecode)); | 104 Bytecodes::ToString(bytecode), Bytecodes::ReturnCount(bytecode)); |
| 111 InterpreterAssembler assembler(&state, bytecode, operand_scale); | 105 InterpreterAssembler assembler(&state, bytecode, operand_scale); |
| 112 (this->*generator)(&assembler); | 106 (this->*generator)(&assembler); |
| 113 Handle<Code> code = compiler::CodeAssembler::GenerateCode(&state); | 107 Handle<Code> code = compiler::CodeAssembler::GenerateCode(&state); |
| 114 size_t index = GetDispatchTableIndex(bytecode, operand_scale); | 108 size_t index = GetDispatchTableIndex(bytecode, operand_scale); |
| 115 dispatch_table_[index] = code->entry(); | 109 dispatch_table_[index] = code->entry(); |
| 116 TraceCodegen(code); | 110 TraceCodegen(code); |
| 117 PROFILE(isolate_, CodeCreateEvent( | 111 PROFILE(isolate_, CodeCreateEvent( |
| 118 CodeEventListener::BYTECODE_HANDLER_TAG, | 112 CodeEventListener::BYTECODE_HANDLER_TAG, |
| 119 AbstractCode::cast(*code), | 113 AbstractCode::cast(*code), |
| 120 Bytecodes::ToString(bytecode, operand_scale).c_str())); | 114 Bytecodes::ToString(bytecode, operand_scale).c_str())); |
| 121 FLAG_csa_verify = sav_csa_verify; | |
| 122 } | 115 } |
| 123 | 116 |
| 124 Code* Interpreter::GetBytecodeHandler(Bytecode bytecode, | 117 Code* Interpreter::GetBytecodeHandler(Bytecode bytecode, |
| 125 OperandScale operand_scale) { | 118 OperandScale operand_scale) { |
| 126 DCHECK(IsDispatchTableInitialized()); | 119 DCHECK(IsDispatchTableInitialized()); |
| 127 DCHECK(Bytecodes::BytecodeHasHandler(bytecode, operand_scale)); | 120 DCHECK(Bytecodes::BytecodeHasHandler(bytecode, operand_scale)); |
| 128 size_t index = GetDispatchTableIndex(bytecode, operand_scale); | 121 size_t index = GetDispatchTableIndex(bytecode, operand_scale); |
| 129 Address code_entry = dispatch_table_[index]; | 122 Address code_entry = dispatch_table_[index]; |
| 130 return Code::GetCodeFromTargetAddress(code_entry); | 123 return Code::GetCodeFromTargetAddress(code_entry); |
| 131 } | 124 } |
| (...skipping 2731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2863 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, | 2856 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, |
| 2864 __ SmiTag(new_state)); | 2857 __ SmiTag(new_state)); |
| 2865 __ SetAccumulator(old_state); | 2858 __ SetAccumulator(old_state); |
| 2866 | 2859 |
| 2867 __ Dispatch(); | 2860 __ Dispatch(); |
| 2868 } | 2861 } |
| 2869 | 2862 |
| 2870 } // namespace interpreter | 2863 } // namespace interpreter |
| 2871 } // namespace internal | 2864 } // namespace internal |
| 2872 } // namespace v8 | 2865 } // namespace v8 |
| OLD | NEW |