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

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

Issue 2351763002: [Interpreter] Optimize BytecodeArrayBuilder and BytecodeArrayWriter. (Closed)
Patch Set: Fix Chromium Windows bots. Created 4 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
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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 "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/interpreter/bytecode-pipeline.h" 7 #include "src/interpreter/bytecode-pipeline.h"
8 #include "src/interpreter/bytecode-register-allocator.h" 8 #include "src/interpreter/bytecode-register-allocator.h"
9 #include "src/isolate.h" 9 #include "src/isolate.h"
10 #include "test/unittests/test-utils.h" 10 #include "test/unittests/test-utils.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 y.set_invalid(); 44 y.set_invalid();
45 y.MakeExpressionPosition(3); 45 y.MakeExpressionPosition(3);
46 CHECK_EQ(y.source_position(), 3); 46 CHECK_EQ(y.source_position(), 3);
47 CHECK_EQ(y.is_statement(), false); 47 CHECK_EQ(y.is_statement(), false);
48 48
49 y.MakeStatementPosition(3); 49 y.MakeStatementPosition(3);
50 CHECK_EQ(y.source_position(), 3); 50 CHECK_EQ(y.source_position(), 3);
51 CHECK_EQ(y.is_statement(), true); 51 CHECK_EQ(y.is_statement(), true);
52 } 52 }
53 53
54 TEST_F(BytecodeNodeTest, Constructor0) {
55 BytecodeNode node;
56 CHECK_EQ(node.bytecode(), Bytecode::kIllegal);
57 CHECK(!node.source_info().is_valid());
58 }
59
60 TEST_F(BytecodeNodeTest, Constructor1) { 54 TEST_F(BytecodeNodeTest, Constructor1) {
61 BytecodeNode node(Bytecode::kLdaZero); 55 BytecodeNode node(Bytecode::kLdaZero);
62 CHECK_EQ(node.bytecode(), Bytecode::kLdaZero); 56 CHECK_EQ(node.bytecode(), Bytecode::kLdaZero);
63 CHECK_EQ(node.operand_count(), 0); 57 CHECK_EQ(node.operand_count(), 0);
64 CHECK(!node.source_info().is_valid()); 58 CHECK(!node.source_info().is_valid());
65 } 59 }
66 60
67 TEST_F(BytecodeNodeTest, Constructor2) { 61 TEST_F(BytecodeNodeTest, Constructor2) {
68 uint32_t operands[] = {0x11}; 62 uint32_t operands[] = {0x11};
69 BytecodeNode node(Bytecode::kJumpIfTrue, operands[0]); 63 BytecodeNode node(Bytecode::kJumpIfTrue, operands[0]);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2], 106 BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2],
113 operands[3]); 107 operands[3]);
114 CHECK_EQ(node, node); 108 CHECK_EQ(node, node);
115 BytecodeNode other(Bytecode::kForInNext, operands[0], operands[1], 109 BytecodeNode other(Bytecode::kForInNext, operands[0], operands[1],
116 operands[2], operands[3]); 110 operands[2], operands[3]);
117 CHECK_EQ(node, other); 111 CHECK_EQ(node, other);
118 } 112 }
119 113
120 TEST_F(BytecodeNodeTest, EqualityWithSourceInfo) { 114 TEST_F(BytecodeNodeTest, EqualityWithSourceInfo) {
121 uint32_t operands[] = {0x71, 0xa5, 0x5a, 0xfc}; 115 uint32_t operands[] = {0x71, 0xa5, 0x5a, 0xfc};
116 BytecodeSourceInfo first_source_info(3, true);
122 BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2], 117 BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2],
123 operands[3]); 118 operands[3], &first_source_info);
124 node.source_info().MakeStatementPosition(3);
125 CHECK_EQ(node, node); 119 CHECK_EQ(node, node);
120 BytecodeSourceInfo second_source_info(3, true);
126 BytecodeNode other(Bytecode::kForInNext, operands[0], operands[1], 121 BytecodeNode other(Bytecode::kForInNext, operands[0], operands[1],
127 operands[2], operands[3]); 122 operands[2], operands[3], &second_source_info);
128 other.source_info().MakeStatementPosition(3);
129 CHECK_EQ(node, other); 123 CHECK_EQ(node, other);
130 } 124 }
131 125
132 TEST_F(BytecodeNodeTest, NoEqualityWithDifferentSourceInfo) { 126 TEST_F(BytecodeNodeTest, NoEqualityWithDifferentSourceInfo) {
133 uint32_t operands[] = {0x71, 0xa5, 0x5a, 0xfc}; 127 uint32_t operands[] = {0x71, 0xa5, 0x5a, 0xfc};
128 BytecodeSourceInfo source_info(77, true);
134 BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2], 129 BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2],
135 operands[3]); 130 operands[3], &source_info);
136 node.source_info().MakeStatementPosition(3);
137 BytecodeNode other(Bytecode::kForInNext, operands[0], operands[1], 131 BytecodeNode other(Bytecode::kForInNext, operands[0], operands[1],
138 operands[2], operands[3]); 132 operands[2], operands[3]);
139 CHECK_NE(node, other); 133 CHECK_NE(node, other);
140 } 134 }
141 135
142 TEST_F(BytecodeNodeTest, Clone) { 136 TEST_F(BytecodeNodeTest, Clone) {
143 uint32_t operands[] = {0x71, 0xa5, 0x5a, 0xfc}; 137 uint32_t operands[] = {0x71, 0xa5, 0x5a, 0xfc};
144 BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2], 138 BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2],
145 operands[3]); 139 operands[3]);
146 BytecodeNode clone; 140 BytecodeNode clone(Bytecode::kIllegal);
147 clone.Clone(&node); 141 clone.Clone(&node);
148 CHECK_EQ(clone, node); 142 CHECK_EQ(clone, node);
149 } 143 }
150 144
151 TEST_F(BytecodeNodeTest, SetBytecode0) { 145 TEST_F(BytecodeNodeTest, SetBytecode0) {
152 uint32_t operands[] = {0x71, 0xa5, 0x5a, 0xfc}; 146 uint32_t operands[] = {0x71, 0xa5, 0x5a, 0xfc};
147 BytecodeSourceInfo source_info(77, false);
153 BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2], 148 BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2],
154 operands[3]); 149 operands[3], &source_info);
155 BytecodeSourceInfo source_info(77, false); 150 CHECK_EQ(node.source_info(), BytecodeSourceInfo(77, false));
156 node.source_info().Clone(source_info);
157 CHECK_EQ(node.source_info(), source_info);
158 151
159 BytecodeNode clone; 152 BytecodeNode clone(Bytecode::kIllegal);
160 clone.Clone(&node); 153 clone.Clone(&node);
161 clone.set_bytecode(Bytecode::kNop); 154 clone.set_bytecode(Bytecode::kNop);
162 CHECK_EQ(clone.bytecode(), Bytecode::kNop); 155 CHECK_EQ(clone.bytecode(), Bytecode::kNop);
163 CHECK_EQ(clone.operand_count(), 0); 156 CHECK_EQ(clone.operand_count(), 0);
164 CHECK_EQ(clone.source_info(), source_info); 157 CHECK_EQ(clone.source_info(), BytecodeSourceInfo(77, false));
165 } 158 }
166 159
167 TEST_F(BytecodeNodeTest, SetBytecode1) { 160 TEST_F(BytecodeNodeTest, SetBytecode1) {
168 uint32_t operands[] = {0x71, 0xa5, 0x5a, 0xfc}; 161 uint32_t operands[] = {0x71, 0xa5, 0x5a, 0xfc};
162 BytecodeSourceInfo source_info(77, false);
169 BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2], 163 BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2],
170 operands[3]); 164 operands[3], &source_info);
171 BytecodeSourceInfo source_info(77, false);
172 node.source_info().Clone(source_info);
173 165
174 BytecodeNode clone; 166 BytecodeNode clone(Bytecode::kIllegal);
175 clone.Clone(&node); 167 clone.Clone(&node);
176 clone.set_bytecode(Bytecode::kJump, 0x01aabbcc); 168 clone.set_bytecode(Bytecode::kJump, 0x01aabbcc);
177 CHECK_EQ(clone.bytecode(), Bytecode::kJump); 169 CHECK_EQ(clone.bytecode(), Bytecode::kJump);
178 CHECK_EQ(clone.operand_count(), 1); 170 CHECK_EQ(clone.operand_count(), 1);
179 CHECK_EQ(clone.operand(0), 0x01aabbcc); 171 CHECK_EQ(clone.operand(0), 0x01aabbcc);
180 CHECK_EQ(clone.source_info(), source_info); 172 CHECK_EQ(clone.source_info(), BytecodeSourceInfo(77, false));
181 } 173 }
182 174
183 } // namespace interpreter 175 } // namespace interpreter
184 } // namespace internal 176 } // namespace internal
185 } // namespace v8 177 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698