Commit 4a8623c6 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Turn IrOpcode::Mnemonic() into a table lookup.

R=ishell@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#25939}
parent bbe8b00d
......@@ -564,6 +564,7 @@ source_set("v8_base") {
"src/compiler/node-properties.h",
"src/compiler/node.cc",
"src/compiler/node.h",
"src/compiler/opcodes.cc",
"src/compiler/opcodes.h",
"src/compiler/operator-properties.cc",
"src/compiler/operator-properties.h",
......
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/compiler/opcodes.h"
#include <algorithm>
#include "src/base/macros.h"
namespace v8 {
namespace internal {
namespace compiler {
namespace {
char const* const kMnemonics[] = {
#define DECLARE_MNEMONIC(x) #x,
ALL_OP_LIST(DECLARE_MNEMONIC)
#undef DECLARE_MNEMONIC
"UnknownOpcode"};
} // namespace
// static
char const* IrOpcode::Mnemonic(Value value) {
size_t const n = std::max<size_t>(value, arraysize(kMnemonics) - 1);
return kMnemonics[n];
}
} // namespace compiler
} // namespace internal
} // namespace v8
......@@ -268,18 +268,7 @@ class IrOpcode {
};
// Returns the mnemonic name of an opcode.
static const char* Mnemonic(Value val) {
// TODO(turbofan): make this a table lookup.
switch (val) {
#define RETURN_NAME(x) \
case k##x: \
return #x;
ALL_OP_LIST(RETURN_NAME)
#undef RETURN_NAME
default:
return "UnknownOpcode";
}
}
static char const* Mnemonic(Value value);
static bool IsJsOpcode(Value val) {
switch (val) {
......
......@@ -491,6 +491,7 @@
'../../src/compiler/node-properties.h',
'../../src/compiler/node.cc',
'../../src/compiler/node.h',
'../../src/compiler/opcodes.cc',
'../../src/compiler/opcodes.h',
'../../src/compiler/operator-properties.cc',
'../../src/compiler/operator-properties.h',
......
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