[unittests] Reduce compilation overhead of opcodes-unittest.cc.

Reduce compilation time (with clang) for opcodes-unittest.cc from
1m38s to roughly 1s by not overusing the macro expansion magic.

TBR=jarin@chromium.org

Review-Url: https://codereview.chromium.org/2331413002
Cr-Commit-Position: refs/heads/master@{#39365}
This commit is contained in:
bmeurer 2016-09-12 22:15:28 -07:00 committed by Commit bot
parent fe952ee169
commit a63997599e

View File

@ -3,7 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "src/compiler/opcodes.h" #include "src/compiler/opcodes.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest-support.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
@ -81,65 +81,60 @@ bool IsComparisonOpcode(IrOpcode::Value opcode) {
const IrOpcode::Value kInvalidOpcode = static_cast<IrOpcode::Value>(123456789); const IrOpcode::Value kInvalidOpcode = static_cast<IrOpcode::Value>(123456789);
} // namespace char const* const kMnemonics[] = {
#define OPCODE(Opcode) #Opcode,
ALL_OP_LIST(OPCODE)
#undef OPCODE
};
const IrOpcode::Value kOpcodes[] = {
#define OPCODE(Opcode) IrOpcode::k##Opcode,
ALL_OP_LIST(OPCODE)
#undef OPCODE
};
} // namespace
TEST(IrOpcodeTest, IsCommonOpcode) { TEST(IrOpcodeTest, IsCommonOpcode) {
EXPECT_FALSE(IrOpcode::IsCommonOpcode(kInvalidOpcode)); EXPECT_FALSE(IrOpcode::IsCommonOpcode(kInvalidOpcode));
#define OPCODE(Opcode) \ TRACED_FOREACH(IrOpcode::Value, opcode, kOpcodes) {
EXPECT_EQ(IsCommonOpcode(IrOpcode::k##Opcode), \ EXPECT_EQ(IsCommonOpcode(opcode), IrOpcode::IsCommonOpcode(opcode));
IrOpcode::IsCommonOpcode(IrOpcode::k##Opcode)); }
ALL_OP_LIST(OPCODE)
#undef OPCODE
} }
TEST(IrOpcodeTest, IsControlOpcode) { TEST(IrOpcodeTest, IsControlOpcode) {
EXPECT_FALSE(IrOpcode::IsControlOpcode(kInvalidOpcode)); EXPECT_FALSE(IrOpcode::IsControlOpcode(kInvalidOpcode));
#define OPCODE(Opcode) \ TRACED_FOREACH(IrOpcode::Value, opcode, kOpcodes) {
EXPECT_EQ(IsControlOpcode(IrOpcode::k##Opcode), \ EXPECT_EQ(IsControlOpcode(opcode), IrOpcode::IsControlOpcode(opcode));
IrOpcode::IsControlOpcode(IrOpcode::k##Opcode)); }
ALL_OP_LIST(OPCODE)
#undef OPCODE
} }
TEST(IrOpcodeTest, IsJsOpcode) { TEST(IrOpcodeTest, IsJsOpcode) {
EXPECT_FALSE(IrOpcode::IsJsOpcode(kInvalidOpcode)); EXPECT_FALSE(IrOpcode::IsJsOpcode(kInvalidOpcode));
#define OPCODE(Opcode) \ TRACED_FOREACH(IrOpcode::Value, opcode, kOpcodes) {
EXPECT_EQ(IsJsOpcode(IrOpcode::k##Opcode), \ EXPECT_EQ(IsJsOpcode(opcode), IrOpcode::IsJsOpcode(opcode));
IrOpcode::IsJsOpcode(IrOpcode::k##Opcode)); }
ALL_OP_LIST(OPCODE)
#undef OPCODE
} }
TEST(IrOpcodeTest, IsConstantOpcode) { TEST(IrOpcodeTest, IsConstantOpcode) {
EXPECT_FALSE(IrOpcode::IsConstantOpcode(kInvalidOpcode)); EXPECT_FALSE(IrOpcode::IsConstantOpcode(kInvalidOpcode));
#define OPCODE(Opcode) \ TRACED_FOREACH(IrOpcode::Value, opcode, kOpcodes) {
EXPECT_EQ(IsConstantOpcode(IrOpcode::k##Opcode), \ EXPECT_EQ(IsConstantOpcode(opcode), IrOpcode::IsConstantOpcode(opcode));
IrOpcode::IsConstantOpcode(IrOpcode::k##Opcode)); }
ALL_OP_LIST(OPCODE)
#undef OPCODE
} }
TEST(IrOpcodeTest, IsComparisonOpcode) { TEST(IrOpcodeTest, IsComparisonOpcode) {
EXPECT_FALSE(IrOpcode::IsComparisonOpcode(kInvalidOpcode)); EXPECT_FALSE(IrOpcode::IsComparisonOpcode(kInvalidOpcode));
#define OPCODE(Opcode) \ TRACED_FOREACH(IrOpcode::Value, opcode, kOpcodes) {
EXPECT_EQ(IsComparisonOpcode(IrOpcode::k##Opcode), \ EXPECT_EQ(IsComparisonOpcode(opcode), IrOpcode::IsComparisonOpcode(opcode));
IrOpcode::IsComparisonOpcode(IrOpcode::k##Opcode)); }
ALL_OP_LIST(OPCODE)
#undef OPCODE
} }
TEST(IrOpcodeTest, Mnemonic) { TEST(IrOpcodeTest, Mnemonic) {
EXPECT_STREQ("UnknownOpcode", IrOpcode::Mnemonic(kInvalidOpcode)); EXPECT_STREQ("UnknownOpcode", IrOpcode::Mnemonic(kInvalidOpcode));
#define OPCODE(Opcode) \ TRACED_FOREACH(IrOpcode::Value, opcode, kOpcodes) {
EXPECT_STREQ(#Opcode, IrOpcode::Mnemonic(IrOpcode::k##Opcode)); EXPECT_STREQ(kMnemonics[opcode], IrOpcode::Mnemonic(opcode));
ALL_OP_LIST(OPCODE) }
#undef OPCODE
} }
} // namespace compiler } // namespace compiler