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

[Interpreter] Readable representation of runtime function IDs.

The first operand to the CallRuntime class of bytecodes is the
ID of the runtime function being called. Before this commit
the ID was printed as plain uint16_t, now we get something like:

  B(CallRuntime) U16(Runtime::Add) ...

This change is intended to make both the golden files more
resistant to modifications of the i::Runtime::FunctionId enum
and the output of generate-bytecode-expectations more readable.

BUG=v8:4280
LOG=N

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

Cr-Commit-Position: refs/heads/master@{#34224}
parent 74cf7300
......@@ -282,6 +282,14 @@ bool Bytecodes::IsCallOrNew(Bytecode bytecode) {
bytecode == Bytecode::kTailCallWide || bytecode == Bytecode::kNewWide;
}
// static
bool Bytecodes::IsCallRuntime(Bytecode bytecode) {
return bytecode == Bytecode::kCallRuntime ||
bytecode == Bytecode::kCallRuntimeWide ||
bytecode == Bytecode::kCallRuntimeForPair ||
bytecode == Bytecode::kCallRuntimeForPairWide;
}
// static
bool Bytecodes::IsDebugBreak(Bytecode bytecode) {
switch (bytecode) {
......
......@@ -478,6 +478,9 @@ class Bytecodes {
// Returns true if the bytecode is a call or a constructor call.
static bool IsCallOrNew(Bytecode bytecode);
// Returns true if the bytecode is a call to the runtime.
static bool IsCallRuntime(Bytecode bytecode);
// Returns true if the bytecode is a debug break.
static bool IsDebugBreak(Bytecode bytecode);
......
......@@ -13,6 +13,7 @@
#include "src/base/logging.h"
#include "src/base/smart-pointers.h"
#include "src/compiler.h"
#include "src/runtime/runtime.h"
#include "src/interpreter/bytecode-array-iterator.h"
#include "src/interpreter/bytecode-generator.h"
......@@ -94,6 +95,12 @@ void BytecodeExpectationsPrinter::PrintEscapedString(
}
}
namespace {
i::Runtime::FunctionId IndexToFunctionId(int index) {
return static_cast<i::Runtime::FunctionId>(index);
}
} // namespace
void BytecodeExpectationsPrinter::PrintBytecodeOperand(
std::ostream& stream, const BytecodeArrayIterator& bytecode_iter,
const Bytecode& bytecode, int op_index, int parameter_count) const {
......@@ -136,7 +143,12 @@ void BytecodeExpectationsPrinter::PrintBytecodeOperand(
} else {
stream << 'U' << size_tag << '(';
if (Bytecodes::IsImmediateOperandType(op_type)) {
if (op_index == 0 && Bytecodes::IsCallRuntime(bytecode)) {
DCHECK_EQ(op_type, OperandType::kIdx16);
int operand = bytecode_iter.GetIndexOperand(op_index);
stream << "Runtime::k"
<< i::Runtime::FunctionForId(IndexToFunctionId(operand))->name;
} else if (Bytecodes::IsImmediateOperandType(op_type)) {
// We need a cast, otherwise the result is printed as char.
stream << static_cast<int>(bytecode_iter.GetImmediateOperand(op_index));
} else if (Bytecodes::IsRegisterCountOperandType(op_type)) {
......
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