Commit ce033d56 authored by ssanfilippo's avatar ssanfilippo Committed by Commit bot

[Interpreter] Move BytecodeHasHandler() from Interpreter to Bytecodes.

BUG=v8:4280
LOG=N

Review URL: https://codereview.chromium.org/1830593002

Cr-Commit-Position: refs/heads/master@{#35254}
parent 792bf2a0
......@@ -8,6 +8,7 @@
#include "src/frames.h"
#include "src/interpreter/bytecode-traits.h"
#include "src/interpreter/interpreter.h"
namespace v8 {
namespace internal {
......@@ -574,6 +575,13 @@ std::ostream& Bytecodes::Decode(std::ostream& os, const uint8_t* bytecode_start,
return os;
}
// static
bool Bytecodes::BytecodeHasHandler(Bytecode bytecode,
OperandScale operand_scale) {
return operand_scale == OperandScale::kSingle ||
Bytecodes::IsBytecodeWithScalableOperands(bytecode);
}
std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode) {
return os << Bytecodes::ToString(bytecode);
}
......
......@@ -512,6 +512,12 @@ class Bytecodes {
static std::ostream& Decode(std::ostream& os, const uint8_t* bytecode_start,
int number_of_parameters);
// Returns true if a handler is generated for a bytecode at a given
// operand scale. All bytecodes have handlers at OperandScale::kSingle,
// but only bytecodes with scalable operands have handlers with larger
// OperandScale values.
static bool BytecodeHasHandler(Bytecode bytecode, OperandScale operand_scale);
// Return the next larger operand scale.
static OperandScale NextOperandScale(OperandScale operand_scale);
......
......@@ -39,7 +39,7 @@ void Interpreter::Initialize() {
operand_scale = Bytecodes::NextOperandScale(operand_scale)) {
#define GENERATE_CODE(Name, ...) \
{ \
if (BytecodeHasHandler(Bytecode::k##Name, operand_scale)) { \
if (Bytecodes::BytecodeHasHandler(Bytecode::k##Name, operand_scale)) { \
InterpreterAssembler assembler(isolate_, &zone, Bytecode::k##Name, \
operand_scale); \
Do##Name(&assembler); \
......@@ -71,7 +71,7 @@ void Interpreter::Initialize() {
Code* Interpreter::GetBytecodeHandler(Bytecode bytecode,
OperandScale operand_scale) {
DCHECK(IsDispatchTableInitialized());
DCHECK(BytecodeHasHandler(bytecode, operand_scale));
DCHECK(Bytecodes::BytecodeHasHandler(bytecode, operand_scale));
size_t index = GetDispatchTableIndex(bytecode, operand_scale);
return dispatch_table_[index];
}
......@@ -89,13 +89,6 @@ size_t Interpreter::GetDispatchTableIndex(Bytecode bytecode,
return index;
}
// static
bool Interpreter::BytecodeHasHandler(Bytecode bytecode,
OperandScale operand_scale) {
return operand_scale == OperandScale::kSingle ||
Bytecodes::IsBytecodeWithScalableOperands(bytecode);
}
void Interpreter::IterateDispatchTable(ObjectVisitor* v) {
v->VisitPointers(
reinterpret_cast<Object**>(&dispatch_table_[0]),
......
......@@ -53,10 +53,6 @@ class Interpreter {
return reinterpret_cast<Address>(&dispatch_table_[0]);
}
// Returns true if a handler is generated for a bytecode at a given
// operand scale.
static bool BytecodeHasHandler(Bytecode bytecode, OperandScale operand_scale);
private:
// Bytecode handler generator functions.
#define DECLARE_BYTECODE_HANDLER_GENERATOR(Name, ...) \
......
......@@ -1615,8 +1615,7 @@ void Logger::LogBytecodeHandlers() {
interpreter::Bytecodes::NextOperandScale(operand_scale)) {
for (int index = 0; index <= last_index; ++index) {
interpreter::Bytecode bytecode = interpreter::Bytecodes::FromByte(index);
if (interpreter::Interpreter::BytecodeHasHandler(bytecode,
operand_scale)) {
if (interpreter::Bytecodes::BytecodeHasHandler(bytecode, operand_scale)) {
Code* code = interpreter->GetBytecodeHandler(bytecode, operand_scale);
std::string bytecode_name =
interpreter::Bytecodes::ToString(bytecode, operand_scale);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment