[turbofan] Fix typo in IrOpcode::Mnemonic.
authorbmeurer <bmeurer@chromium.org>
Fri, 9 Jan 2015 14:19:55 +0000 (06:19 -0800)
committerCommit bot <commit-bot@chromium.org>
Fri, 9 Jan 2015 14:20:03 +0000 (14:20 +0000)
TEST=unittests
R=svenpanne@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#26014}

src/compiler/opcodes.cc
test/unittests/compiler/opcodes-unittest.cc [new file with mode: 0644]
test/unittests/unittests.gyp

index 044395c..1c94c19 100644 (file)
@@ -25,7 +25,7 @@ char const* const kMnemonics[] = {
 
 // 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];
 }
 
diff --git a/test/unittests/compiler/opcodes-unittest.cc b/test/unittests/compiler/opcodes-unittest.cc
new file mode 100644 (file)
index 0000000..3a97178
--- /dev/null
@@ -0,0 +1,25 @@
+// 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
index 2ead44f..fe4a127 100644 (file)
@@ -60,6 +60,7 @@
         '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',