OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/opcodes.h" | 5 #include "src/compiler/opcodes.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "src/base/macros.h" | 9 #include "src/base/macros.h" |
10 | 10 |
11 namespace v8 { | 11 namespace v8 { |
12 namespace internal { | 12 namespace internal { |
13 namespace compiler { | 13 namespace compiler { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 char const* const kMnemonics[] = { | 17 char const* const kMnemonics[] = { |
18 #define DECLARE_MNEMONIC(x) #x, | 18 #define DECLARE_MNEMONIC(x) #x, |
19 ALL_OP_LIST(DECLARE_MNEMONIC) | 19 ALL_OP_LIST(DECLARE_MNEMONIC) |
20 #undef DECLARE_MNEMONIC | 20 #undef DECLARE_MNEMONIC |
21 "UnknownOpcode"}; | 21 "UnknownOpcode"}; |
22 | 22 |
23 } // namespace | 23 } // namespace |
24 | 24 |
25 | 25 |
26 // static | 26 // static |
27 char const* IrOpcode::Mnemonic(Value value) { | 27 char const* IrOpcode::Mnemonic(Value value) { |
28 size_t const n = std::max<size_t>(value, arraysize(kMnemonics) - 1); | 28 size_t const n = std::min<size_t>(value, arraysize(kMnemonics) - 1); |
29 return kMnemonics[n]; | 29 return kMnemonics[n]; |
30 } | 30 } |
31 | 31 |
32 } // namespace compiler | 32 } // namespace compiler |
33 } // namespace internal | 33 } // namespace internal |
34 } // namespace v8 | 34 } // namespace v8 |
OLD | NEW |