// static
char const* IrOpcode::Mnemonic(Value value) {
- size_t const n = std::max<size_t>(value, arraysize(kMnemonics) - 1);
+ size_t const n = std::min<size_t>(value, arraysize(kMnemonics) - 1);
return kMnemonics[n];
}
--- /dev/null
+// Copyright 2015 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 <cstring>
+
+#include "src/compiler/opcodes.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace v8 {
+namespace internal {
+namespace compiler {
+
+TEST(IrOpcodeTest, Mnemonic) {
+ EXPECT_STREQ("UnknownOpcode",
+ IrOpcode::Mnemonic(static_cast<IrOpcode::Value>(123456789)));
+#define OPCODE(Opcode) \
+ EXPECT_STREQ(#Opcode, IrOpcode::Mnemonic(IrOpcode::k##Opcode));
+ ALL_OP_LIST(OPCODE)
+#undef OPCODE
+}
+
+} // namespace compiler
+} // namespace internal
+} // namespace v8
'compiler/node-matchers-unittest.cc',
'compiler/node-test-utils.cc',
'compiler/node-test-utils.h',
+ 'compiler/opcodes-unittest.cc',
'compiler/register-allocator-unittest.cc',
'compiler/select-lowering-unittest.cc',
'compiler/simplified-operator-reducer-unittest.cc',