Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(497)

Side by Side Diff: test/unittests/interpreter/bytecodes-unittest.cc

Issue 2100793003: [interpreter] Streamline bytecode array writing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/interpreter/bytecodes.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 <vector> 5 #include <vector>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/interpreter/bytecodes.h" 9 #include "src/interpreter/bytecodes.h"
10 #include "test/unittests/interpreter/bytecode-utils.h" 10 #include "test/unittests/interpreter/bytecode-utils.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 for (OperandScale operand_scale : kOperandScales) { 86 for (OperandScale operand_scale : kOperandScales) {
87 int scale = static_cast<int>(operand_scale); 87 int scale = static_cast<int>(operand_scale);
88 CHECK_EQ(Bytecodes::Size(Bytecode::kCallRuntime, operand_scale), 88 CHECK_EQ(Bytecodes::Size(Bytecode::kCallRuntime, operand_scale),
89 1 + 2 + 2 * scale); 89 1 + 2 + 2 * scale);
90 CHECK_EQ(Bytecodes::Size(Bytecode::kCreateObjectLiteral, operand_scale), 90 CHECK_EQ(Bytecodes::Size(Bytecode::kCreateObjectLiteral, operand_scale),
91 1 + 2 * scale + 1); 91 1 + 2 * scale + 1);
92 CHECK_EQ(Bytecodes::Size(Bytecode::kTestIn, operand_scale), 1 + scale); 92 CHECK_EQ(Bytecodes::Size(Bytecode::kTestIn, operand_scale), 1 + scale);
93 } 93 }
94 } 94 }
95 95
96 TEST(Bytecodes, HasAnyRegisterOperands) {
97 CHECK_EQ(Bytecodes::NumberOfRegisterOperands(Bytecode::kAdd), 1);
98 CHECK_EQ(Bytecodes::NumberOfRegisterOperands(Bytecode::kCall), 2);
99 CHECK_EQ(Bytecodes::NumberOfRegisterOperands(Bytecode::kCallRuntime), 1);
100 CHECK_EQ(Bytecodes::NumberOfRegisterOperands(Bytecode::kCallRuntimeForPair),
101 2);
102 CHECK_EQ(Bytecodes::NumberOfRegisterOperands(Bytecode::kDeletePropertyStrict),
103 1);
104 CHECK_EQ(Bytecodes::NumberOfRegisterOperands(Bytecode::kForInPrepare), 1);
105 CHECK_EQ(Bytecodes::NumberOfRegisterOperands(Bytecode::kInc), 0);
106 CHECK_EQ(Bytecodes::NumberOfRegisterOperands(Bytecode::kJumpIfTrue), 0);
107 CHECK_EQ(Bytecodes::NumberOfRegisterOperands(Bytecode::kNew), 2);
108 CHECK_EQ(Bytecodes::NumberOfRegisterOperands(Bytecode::kToName), 0);
109 }
110
111 TEST(Bytecodes, RegisterOperandBitmaps) {
112 CHECK_EQ(Bytecodes::GetRegisterOperandBitmap(Bytecode::kAdd), 1);
113 CHECK_EQ(Bytecodes::GetRegisterOperandBitmap(Bytecode::kCallRuntimeForPair),
114 10);
115 CHECK_EQ(Bytecodes::GetRegisterOperandBitmap(Bytecode::kStar), 1);
116 CHECK_EQ(Bytecodes::GetRegisterOperandBitmap(Bytecode::kMov), 3);
117 CHECK_EQ(Bytecodes::GetRegisterOperandBitmap(Bytecode::kTestIn), 1);
118 CHECK_EQ(Bytecodes::GetRegisterOperandBitmap(Bytecode::kForInPrepare), 1);
119 CHECK_EQ(Bytecodes::GetRegisterOperandBitmap(Bytecode::kForInDone), 3);
120 CHECK_EQ(Bytecodes::GetRegisterOperandBitmap(Bytecode::kForInNext), 7);
121 }
122
123 TEST(Bytecodes, RegisterOperands) { 96 TEST(Bytecodes, RegisterOperands) {
124 CHECK(Bytecodes::IsRegisterOperandType(OperandType::kReg)); 97 CHECK(Bytecodes::IsRegisterOperandType(OperandType::kReg));
125 CHECK(Bytecodes::IsRegisterInputOperandType(OperandType::kReg)); 98 CHECK(Bytecodes::IsRegisterInputOperandType(OperandType::kReg));
126 CHECK(!Bytecodes::IsRegisterOutputOperandType(OperandType::kReg)); 99 CHECK(!Bytecodes::IsRegisterOutputOperandType(OperandType::kReg));
127 CHECK(!Bytecodes::IsRegisterInputOperandType(OperandType::kRegOut)); 100 CHECK(!Bytecodes::IsRegisterInputOperandType(OperandType::kRegOut));
128 CHECK(Bytecodes::IsRegisterOutputOperandType(OperandType::kRegOut)); 101 CHECK(Bytecodes::IsRegisterOutputOperandType(OperandType::kRegOut));
129 102
130 #define IS_REGISTER_OPERAND_TYPE(Name, _) \ 103 #define IS_REGISTER_OPERAND_TYPE(Name, _) \
131 CHECK(Bytecodes::IsRegisterOperandType(OperandType::k##Name)); 104 CHECK(Bytecodes::IsRegisterOperandType(OperandType::k##Name));
132 REGISTER_OPERAND_TYPE_LIST(IS_REGISTER_OPERAND_TYPE) 105 REGISTER_OPERAND_TYPE_LIST(IS_REGISTER_OPERAND_TYPE)
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 std::set<std::string> names; 306 std::set<std::string> names;
334 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kNone)); 307 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kNone));
335 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kRead)); 308 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kRead));
336 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kWrite)); 309 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kWrite));
337 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kReadWrite)); 310 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kReadWrite));
338 CHECK_EQ(names.size(), 4); 311 CHECK_EQ(names.size(), 4);
339 } 312 }
340 } // namespace interpreter 313 } // namespace interpreter
341 } // namespace internal 314 } // namespace internal
342 } // namespace v8 315 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecodes.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698