Commit c0651535 authored by neis's avatar neis Committed by Commit bot

[interpreter] Teach --print-bytecode the names of runtime functions and intrinsics.

This changes the bytecode decoder such that --print-bytecode will print

    ... CallRuntime [GeneratorGetResumeMode] ...
    ... InvokeIntrinsic [CreateIterResultObject] ...

instead of

    ... CallRuntime [762] ...
    ... InvokeIntrinsic [2] ...

The printing of CallJSRuntime remains unchanged.

R=gsathya@chromium.org, rmcilroy@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2712943002
Cr-Commit-Position: refs/heads/master@{#43391}
parent 68960eeb
......@@ -6,7 +6,7 @@
#include <iomanip>
#include "src/utils.h"
#include "src/interpreter/interpreter-intrinsics.h"
namespace v8 {
namespace internal {
......@@ -67,6 +67,23 @@ uint32_t BytecodeDecoder::DecodeUnsignedOperand(const uint8_t* operand_start,
return 0;
}
namespace {
const char* NameForRuntimeId(uint32_t idx) {
switch (idx) {
#define CASE(name, nargs, ressize) \
case Runtime::k##name: \
return #name; \
case Runtime::kInline##name: \
return #name;
FOR_EACH_INTRINSIC(CASE)
#undef CASE
default:
UNREACHABLE();
return nullptr;
}
}
} // anonymous namespace
// static
std::ostream& BytecodeDecoder::Decode(std::ostream& os,
const uint8_t* bytecode_start,
......@@ -112,12 +129,21 @@ std::ostream& BytecodeDecoder::Decode(std::ostream& os,
switch (op_type) {
case interpreter::OperandType::kIdx:
case interpreter::OperandType::kUImm:
case interpreter::OperandType::kRuntimeId:
case interpreter::OperandType::kIntrinsicId:
os << "["
<< DecodeUnsignedOperand(operand_start, op_type, operand_scale)
<< "]";
break;
case interpreter::OperandType::kIntrinsicId: {
auto id = static_cast<IntrinsicsHelper::IntrinsicId>(
DecodeUnsignedOperand(operand_start, op_type, operand_scale));
os << "[" << NameForRuntimeId(IntrinsicsHelper::ToRuntimeId(id)) << "]";
break;
}
case interpreter::OperandType::kRuntimeId:
os << "[" << NameForRuntimeId(DecodeUnsignedOperand(
operand_start, op_type, operand_scale))
<< "]";
break;
case interpreter::OperandType::kImm:
os << "[" << DecodeSignedOperand(operand_start, op_type, operand_scale)
<< "]";
......
......@@ -7,6 +7,7 @@
#include "src/v8.h"
#include "src/interpreter/bytecode-decoder.h"
#include "src/runtime/runtime.h"
#include "test/unittests/interpreter/bytecode-utils.h"
#include "test/unittests/test-utils.h"
......@@ -45,10 +46,10 @@ TEST(BytecodeDecoder, DecodeBytecodeAndOperands) {
3,
0,
" ForInPrepare r10, r11-r13"},
{{B(CallRuntime), U16(134), R8(0), U8(0)},
{{B(CallRuntime), U16(Runtime::FunctionId::kIsDate), R8(0), U8(0)},
5,
0,
" CallRuntime [134], r0-r0"},
" CallRuntime [IsDate], r0-r0"},
{{B(Ldar),
static_cast<uint8_t>(Register::FromParameterIndex(2, 3).ToOperand())},
2,
......
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