OLD | NEW |
---|---|
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/test-utils.h" | 10 #include "test/unittests/test-utils.h" |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
273 CHECK(!Bytecodes::OperandScaleRequiresPrefixBytecode(OperandScale::kSingle)); | 273 CHECK(!Bytecodes::OperandScaleRequiresPrefixBytecode(OperandScale::kSingle)); |
274 CHECK(Bytecodes::OperandScaleRequiresPrefixBytecode(OperandScale::kDouble)); | 274 CHECK(Bytecodes::OperandScaleRequiresPrefixBytecode(OperandScale::kDouble)); |
275 CHECK( | 275 CHECK( |
276 Bytecodes::OperandScaleRequiresPrefixBytecode(OperandScale::kQuadruple)); | 276 Bytecodes::OperandScaleRequiresPrefixBytecode(OperandScale::kQuadruple)); |
277 CHECK(Bytecodes::OperandScaleToPrefixBytecode(OperandScale::kDouble) == | 277 CHECK(Bytecodes::OperandScaleToPrefixBytecode(OperandScale::kDouble) == |
278 Bytecode::kWide); | 278 Bytecode::kWide); |
279 CHECK(Bytecodes::OperandScaleToPrefixBytecode(OperandScale::kQuadruple) == | 279 CHECK(Bytecodes::OperandScaleToPrefixBytecode(OperandScale::kQuadruple) == |
280 Bytecode::kExtraWide); | 280 Bytecode::kExtraWide); |
281 } | 281 } |
282 | 282 |
283 TEST(AccumulatorUse, LogicalOperators) { | |
284 CHECK_EQ(AccumulatorUse::kNone | AccumulatorUse::kRead, | |
285 AccumulatorUse::kRead); | |
286 CHECK_EQ(AccumulatorUse::kRead | AccumulatorUse::kWrite, | |
287 AccumulatorUse::kReadWrite); | |
288 CHECK_EQ(AccumulatorUse::kRead & AccumulatorUse::kReadWrite, | |
289 AccumulatorUse::kRead); | |
290 CHECK_EQ(AccumulatorUse::kRead & AccumulatorUse::kWrite, | |
291 AccumulatorUse::kNone); | |
292 } | |
293 | |
294 TEST(AccumulatorUse, SampleBytecodes) { | |
295 CHECK(Bytecodes::ReadsAccumulator(Bytecode::kStar)); | |
296 CHECK(!Bytecodes::WritesAccumulator(Bytecode::kStar)); | |
297 CHECK_EQ(Bytecodes::GetAccumulatorUse(Bytecode::kStar), | |
298 AccumulatorUse::kRead); | |
299 CHECK(!Bytecodes::ReadsAccumulator(Bytecode::kLdar)); | |
300 CHECK(Bytecodes::WritesAccumulator(Bytecode::kLdar)); | |
301 CHECK_EQ(Bytecodes::GetAccumulatorUse(Bytecode::kLdar), | |
302 AccumulatorUse::kWrite); | |
303 CHECK(Bytecodes::ReadsAccumulator(Bytecode::kAdd)); | |
304 CHECK(Bytecodes::WritesAccumulator(Bytecode::kAdd)); | |
305 CHECK_EQ(Bytecodes::GetAccumulatorUse(Bytecode::kAdd), | |
306 AccumulatorUse::kReadWrite); | |
307 } | |
308 | |
309 TEST(AccumulatorUse, AccumulatorUseToString) { | |
310 std::set<std::string> names; | |
311 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kNone)); | |
312 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kRead)); | |
313 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kWrite)); | |
314 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kReadWrite)); | |
315 CHECK_EQ(names.size(), 4); | |
rmcilroy
2016/04/05 12:59:23
Not sure what this is testing?
oth
2016/04/05 14:12:10
It tests the associated names of the AccumulatorUs
| |
316 } | |
317 | |
283 } // namespace interpreter | 318 } // namespace interpreter |
284 } // namespace internal | 319 } // namespace internal |
285 } // namespace v8 | 320 } // namespace v8 |
OLD | NEW |