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

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

Issue 1325983002: [Intepreter] Extend and move Register class. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix test, bug spotted by bots. Created 5 years, 3 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/objects.cc ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <vector>
6
7 #include "src/v8.h"
8
9 #include "src/interpreter/bytecodes.h"
10 #include "test/unittests/test-utils.h"
11
12
13 namespace v8 {
14 namespace internal {
15 namespace interpreter {
16
17 TEST(OperandConversion, Registers) {
18 for (int i = 0; i < 128; i++) {
19 uint8_t operand_value = Register(i).ToOperand();
20 Register r = Register::FromOperand(operand_value);
21 CHECK_EQ(i, r.index());
22 }
23 }
24
25
26 TEST(OperandConversion, Parameters) {
27 int parameter_counts[] = {7, 13, 99};
28
29 size_t count = sizeof(parameter_counts) / sizeof(parameter_counts[0]);
30 for (size_t p = 0; p < count; p++) {
31 int parameter_count = parameter_counts[p];
32 for (int i = 0; i < parameter_count; i++) {
33 Register r = Register::FromParameterIndex(i, parameter_count);
34 uint8_t operand_value = r.ToOperand();
35 Register s = Register::FromOperand(operand_value);
36 CHECK_EQ(i, s.ToParameterIndex(parameter_count));
37 }
38 }
39 }
40
41
42 TEST(OperandConversion, RegistersParametersNoOverlap) {
43 std::vector<uint8_t> operand_count(256);
44
45 for (int i = 0; i <= Register::kMaxRegisterIndex; i++) {
46 Register r = Register(i);
47 uint8_t operand = r.ToOperand();
48 operand_count[operand] += 1;
49 CHECK_EQ(operand_count[operand], 1);
50 }
51
52 int parameter_count = Register::MaxParameterIndex() + 1;
53 for (int i = 0; i < parameter_count; i++) {
54 Register r = Register::FromParameterIndex(i, parameter_count);
55 uint8_t operand = r.ToOperand();
56 operand_count[operand] += 1;
57 CHECK_EQ(operand_count[operand], 1);
58 }
59 }
60
61 } // namespace interpreter
62 } // namespace internal
63 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698