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/interpreter/bytecode-utils.h" | 10 #include "test/unittests/interpreter/bytecode-utils.h" |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 CHECK(!Bytecodes::OperandScaleRequiresPrefixBytecode(OperandScale::kSingle)); | 325 CHECK(!Bytecodes::OperandScaleRequiresPrefixBytecode(OperandScale::kSingle)); |
326 CHECK(Bytecodes::OperandScaleRequiresPrefixBytecode(OperandScale::kDouble)); | 326 CHECK(Bytecodes::OperandScaleRequiresPrefixBytecode(OperandScale::kDouble)); |
327 CHECK( | 327 CHECK( |
328 Bytecodes::OperandScaleRequiresPrefixBytecode(OperandScale::kQuadruple)); | 328 Bytecodes::OperandScaleRequiresPrefixBytecode(OperandScale::kQuadruple)); |
329 CHECK(Bytecodes::OperandScaleToPrefixBytecode(OperandScale::kDouble) == | 329 CHECK(Bytecodes::OperandScaleToPrefixBytecode(OperandScale::kDouble) == |
330 Bytecode::kWide); | 330 Bytecode::kWide); |
331 CHECK(Bytecodes::OperandScaleToPrefixBytecode(OperandScale::kQuadruple) == | 331 CHECK(Bytecodes::OperandScaleToPrefixBytecode(OperandScale::kQuadruple) == |
332 Bytecode::kExtraWide); | 332 Bytecode::kExtraWide); |
333 } | 333 } |
334 | 334 |
| 335 TEST(Bytecodes, OperandSizesToScale) { |
| 336 CHECK_EQ(Bytecodes::OperandSizesToScale(OperandSize::kByte), |
| 337 OperandScale::kSingle); |
| 338 CHECK_EQ(Bytecodes::OperandSizesToScale(OperandSize::kShort), |
| 339 OperandScale::kDouble); |
| 340 CHECK_EQ(Bytecodes::OperandSizesToScale(OperandSize::kQuad), |
| 341 OperandScale::kQuadruple); |
| 342 CHECK_EQ( |
| 343 Bytecodes::OperandSizesToScale(OperandSize::kShort, OperandSize::kShort, |
| 344 OperandSize::kShort, OperandSize::kShort), |
| 345 OperandScale::kDouble); |
| 346 CHECK_EQ( |
| 347 Bytecodes::OperandSizesToScale(OperandSize::kQuad, OperandSize::kShort, |
| 348 OperandSize::kShort, OperandSize::kShort), |
| 349 OperandScale::kQuadruple); |
| 350 CHECK_EQ( |
| 351 Bytecodes::OperandSizesToScale(OperandSize::kShort, OperandSize::kQuad, |
| 352 OperandSize::kShort, OperandSize::kShort), |
| 353 OperandScale::kQuadruple); |
| 354 CHECK_EQ( |
| 355 Bytecodes::OperandSizesToScale(OperandSize::kShort, OperandSize::kShort, |
| 356 OperandSize::kQuad, OperandSize::kShort), |
| 357 OperandScale::kQuadruple); |
| 358 CHECK_EQ( |
| 359 Bytecodes::OperandSizesToScale(OperandSize::kShort, OperandSize::kShort, |
| 360 OperandSize::kShort, OperandSize::kQuad), |
| 361 OperandScale::kQuadruple); |
| 362 } |
| 363 |
335 TEST(AccumulatorUse, LogicalOperators) { | 364 TEST(AccumulatorUse, LogicalOperators) { |
336 CHECK_EQ(AccumulatorUse::kNone | AccumulatorUse::kRead, | 365 CHECK_EQ(AccumulatorUse::kNone | AccumulatorUse::kRead, |
337 AccumulatorUse::kRead); | 366 AccumulatorUse::kRead); |
338 CHECK_EQ(AccumulatorUse::kRead | AccumulatorUse::kWrite, | 367 CHECK_EQ(AccumulatorUse::kRead | AccumulatorUse::kWrite, |
339 AccumulatorUse::kReadWrite); | 368 AccumulatorUse::kReadWrite); |
340 CHECK_EQ(AccumulatorUse::kRead & AccumulatorUse::kReadWrite, | 369 CHECK_EQ(AccumulatorUse::kRead & AccumulatorUse::kReadWrite, |
341 AccumulatorUse::kRead); | 370 AccumulatorUse::kRead); |
342 CHECK_EQ(AccumulatorUse::kRead & AccumulatorUse::kWrite, | 371 CHECK_EQ(AccumulatorUse::kRead & AccumulatorUse::kWrite, |
343 AccumulatorUse::kNone); | 372 AccumulatorUse::kNone); |
344 } | 373 } |
(...skipping 14 matching lines...) Expand all Loading... |
359 } | 388 } |
360 | 389 |
361 TEST(AccumulatorUse, AccumulatorUseToString) { | 390 TEST(AccumulatorUse, AccumulatorUseToString) { |
362 std::set<std::string> names; | 391 std::set<std::string> names; |
363 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kNone)); | 392 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kNone)); |
364 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kRead)); | 393 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kRead)); |
365 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kWrite)); | 394 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kWrite)); |
366 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kReadWrite)); | 395 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kReadWrite)); |
367 CHECK_EQ(names.size(), 4); | 396 CHECK_EQ(names.size(), 4); |
368 } | 397 } |
369 | |
370 } // namespace interpreter | 398 } // namespace interpreter |
371 } // namespace internal | 399 } // namespace internal |
372 } // namespace v8 | 400 } // namespace v8 |
OLD | NEW |