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

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

Issue 1707693003: [Interpreter] Enable runtime profiler support for Ignition. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Really fix --debug-code Created 4 years, 10 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 | « test/mjsunit/mjsunit.status ('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 "test/unittests/interpreter/interpreter-assembler-unittest.h" 5 #include "test/unittests/interpreter/interpreter-assembler-unittest.h"
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/compiler/graph.h" 8 #include "src/compiler/graph.h"
9 #include "src/compiler/node.h" 9 #include "src/compiler/node.h"
10 #include "src/interface-descriptors.h" 10 #include "src/interface-descriptors.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 IsParameter(InterpreterDispatchDescriptor::kRegisterFileParameter), 216 IsParameter(InterpreterDispatchDescriptor::kRegisterFileParameter),
217 next_bytecode_offset_matcher, 217 next_bytecode_offset_matcher,
218 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), 218 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter),
219 IsParameter(InterpreterDispatchDescriptor::kDispatchTableParameter), 219 IsParameter(InterpreterDispatchDescriptor::kDispatchTableParameter),
220 IsParameter(InterpreterDispatchDescriptor::kContextParameter), _, 220 IsParameter(InterpreterDispatchDescriptor::kContextParameter), _,
221 _)); 221 _));
222 } 222 }
223 } 223 }
224 224
225 TARGET_TEST_F(InterpreterAssemblerTest, Jump) { 225 TARGET_TEST_F(InterpreterAssemblerTest, Jump) {
226 // If debug code is enabled we emit extra code in Jump.
227 if (FLAG_debug_code) return;
228
226 int jump_offsets[] = {-9710, -77, 0, +3, +97109}; 229 int jump_offsets[] = {-9710, -77, 0, +3, +97109};
227 TRACED_FOREACH(int, jump_offset, jump_offsets) { 230 TRACED_FOREACH(int, jump_offset, jump_offsets) {
228 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { 231 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
229 InterpreterAssemblerForTest m(this, bytecode); 232 InterpreterAssemblerForTest m(this, bytecode);
230 m.Jump(m.Int32Constant(jump_offset)); 233 m.Jump(m.Int32Constant(jump_offset));
231 Graph* graph = m.graph(); 234 Graph* graph = m.graph();
232 Node* end = graph->end(); 235 Node* end = graph->end();
233 EXPECT_EQ(1, end->InputCount()); 236 EXPECT_EQ(1, end->InputCount());
234 Node* tail_call_node = end->InputAt(0); 237 Node* tail_call_node = end->InputAt(0);
235 238
236 Matcher<Node*> next_bytecode_offset_matcher = IsIntPtrAdd( 239 Matcher<Node*> next_bytecode_offset_matcher = IsIntPtrAdd(
237 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffsetParameter), 240 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffsetParameter),
238 IsInt32Constant(jump_offset)); 241 IsInt32Constant(jump_offset));
239 Matcher<Node*> target_bytecode_matcher = m.IsLoad( 242 Matcher<Node*> target_bytecode_matcher =
240 MachineType::Uint8(), 243 m.IsLoad(MachineType::Uint8(), _, next_bytecode_offset_matcher);
241 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter),
242 next_bytecode_offset_matcher);
243 Matcher<Node*> code_target_matcher = m.IsLoad( 244 Matcher<Node*> code_target_matcher = m.IsLoad(
244 MachineType::Pointer(), 245 MachineType::Pointer(),
245 IsParameter(InterpreterDispatchDescriptor::kDispatchTableParameter), 246 IsParameter(InterpreterDispatchDescriptor::kDispatchTableParameter),
246 IsWord32Shl(target_bytecode_matcher, 247 IsWord32Shl(target_bytecode_matcher,
247 IsInt32Constant(kPointerSizeLog2))); 248 IsInt32Constant(kPointerSizeLog2)));
248 249
249 EXPECT_THAT( 250 EXPECT_THAT(
250 tail_call_node, 251 tail_call_node,
251 IsTailCall( 252 IsTailCall(
252 _, code_target_matcher, 253 _, code_target_matcher,
253 IsParameter(InterpreterDispatchDescriptor::kAccumulatorParameter), 254 IsParameter(InterpreterDispatchDescriptor::kAccumulatorParameter),
254 IsParameter( 255 IsParameter(
255 InterpreterDispatchDescriptor::kRegisterFileParameter), 256 InterpreterDispatchDescriptor::kRegisterFileParameter),
256 next_bytecode_offset_matcher, 257 next_bytecode_offset_matcher, _,
257 IsParameter(
258 InterpreterDispatchDescriptor::kBytecodeArrayParameter),
259 IsParameter( 258 IsParameter(
260 InterpreterDispatchDescriptor::kDispatchTableParameter), 259 InterpreterDispatchDescriptor::kDispatchTableParameter),
261 IsParameter(InterpreterDispatchDescriptor::kContextParameter), _, 260 IsParameter(InterpreterDispatchDescriptor::kContextParameter), _,
262 _)); 261 _));
263 } 262 }
264 } 263 }
265 } 264 }
266 265
267 TARGET_TEST_F(InterpreterAssemblerTest, JumpIfWordEqual) { 266 TARGET_TEST_F(InterpreterAssemblerTest, JumpIfWordEqual) {
268 static const int kJumpIfTrueOffset = 73; 267 static const int kJumpIfTrueOffset = 73;
269 268
269 // If debug code is enabled we emit extra code in Jump.
270 if (FLAG_debug_code) return;
271
270 MachineOperatorBuilder machine(zone()); 272 MachineOperatorBuilder machine(zone());
271 273
272 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { 274 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
273 InterpreterAssemblerForTest m(this, bytecode); 275 InterpreterAssemblerForTest m(this, bytecode);
274 Node* lhs = m.IntPtrConstant(0); 276 Node* lhs = m.IntPtrConstant(0);
275 Node* rhs = m.IntPtrConstant(1); 277 Node* rhs = m.IntPtrConstant(1);
276 m.JumpIfWordEqual(lhs, rhs, m.Int32Constant(kJumpIfTrueOffset)); 278 m.JumpIfWordEqual(lhs, rhs, m.Int32Constant(kJumpIfTrueOffset));
277 Graph* graph = m.graph(); 279 Graph* graph = m.graph();
278 Node* end = graph->end(); 280 Node* end = graph->end();
279 EXPECT_EQ(2, end->InputCount()); 281 EXPECT_EQ(2, end->InputCount());
280 282
281 int jump_offsets[] = {kJumpIfTrueOffset, 283 int jump_offsets[] = {kJumpIfTrueOffset,
282 interpreter::Bytecodes::Size(bytecode)}; 284 interpreter::Bytecodes::Size(bytecode)};
283 for (int i = 0; i < static_cast<int>(arraysize(jump_offsets)); i++) { 285 for (int i = 0; i < static_cast<int>(arraysize(jump_offsets)); i++) {
284 Matcher<Node*> next_bytecode_offset_matcher = IsIntPtrAdd( 286 Matcher<Node*> next_bytecode_offset_matcher = IsIntPtrAdd(
285 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffsetParameter), 287 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffsetParameter),
286 IsInt32Constant(jump_offsets[i])); 288 IsInt32Constant(jump_offsets[i]));
287 Matcher<Node*> target_bytecode_matcher = m.IsLoad( 289 Matcher<Node*> target_bytecode_matcher =
288 MachineType::Uint8(), 290 m.IsLoad(MachineType::Uint8(), _, next_bytecode_offset_matcher);
289 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter),
290 next_bytecode_offset_matcher);
291 Matcher<Node*> code_target_matcher = m.IsLoad( 291 Matcher<Node*> code_target_matcher = m.IsLoad(
292 MachineType::Pointer(), 292 MachineType::Pointer(),
293 IsParameter(InterpreterDispatchDescriptor::kDispatchTableParameter), 293 IsParameter(InterpreterDispatchDescriptor::kDispatchTableParameter),
294 IsWord32Shl(target_bytecode_matcher, 294 IsWord32Shl(target_bytecode_matcher,
295 IsInt32Constant(kPointerSizeLog2))); 295 IsInt32Constant(kPointerSizeLog2)));
296 EXPECT_THAT( 296 EXPECT_THAT(
297 end->InputAt(i), 297 end->InputAt(i),
298 IsTailCall( 298 IsTailCall(
299 _, code_target_matcher, 299 _, code_target_matcher,
300 IsParameter(InterpreterDispatchDescriptor::kAccumulatorParameter), 300 IsParameter(InterpreterDispatchDescriptor::kAccumulatorParameter),
301 IsParameter( 301 IsParameter(
302 InterpreterDispatchDescriptor::kRegisterFileParameter), 302 InterpreterDispatchDescriptor::kRegisterFileParameter),
303 next_bytecode_offset_matcher, 303 next_bytecode_offset_matcher, _,
304 IsParameter(
305 InterpreterDispatchDescriptor::kBytecodeArrayParameter),
306 IsParameter( 304 IsParameter(
307 InterpreterDispatchDescriptor::kDispatchTableParameter), 305 InterpreterDispatchDescriptor::kDispatchTableParameter),
308 IsParameter(InterpreterDispatchDescriptor::kContextParameter), _, 306 IsParameter(InterpreterDispatchDescriptor::kContextParameter), _,
309 _)); 307 _));
310 } 308 }
311 309
312 // TODO(oth): test control flow paths. 310 // TODO(oth): test control flow paths.
313 } 311 }
314 } 312 }
315 313
316 TARGET_TEST_F(InterpreterAssemblerTest, InterpreterReturn) { 314 TARGET_TEST_F(InterpreterAssemblerTest, InterpreterReturn) {
315 // If debug code is enabled we emit extra code in InterpreterReturn.
316 if (FLAG_debug_code) return;
317
317 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { 318 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
318 InterpreterAssemblerForTest m(this, bytecode); 319 InterpreterAssemblerForTest m(this, bytecode);
319 m.InterpreterReturn(); 320 m.InterpreterReturn();
320 Graph* graph = m.graph(); 321 Graph* graph = m.graph();
321 322
322 Node* end = graph->end(); 323 Node* end = graph->end();
323 EXPECT_EQ(1, end->InputCount()); 324 EXPECT_EQ(1, end->InputCount());
324 Node* tail_call_node = end->InputAt(0); 325 Node* tail_call_node = end->InputAt(0);
325 326
326 Handle<HeapObject> exit_trampoline = 327 Handle<HeapObject> exit_trampoline =
327 isolate()->builtins()->InterpreterExitTrampoline(); 328 isolate()->builtins()->InterpreterExitTrampoline();
328 EXPECT_THAT( 329 EXPECT_THAT(
329 tail_call_node, 330 tail_call_node,
330 IsTailCall( 331 IsTailCall(
331 _, IsHeapConstant(exit_trampoline), 332 _, IsHeapConstant(exit_trampoline),
332 IsParameter(InterpreterDispatchDescriptor::kAccumulatorParameter), 333 IsParameter(InterpreterDispatchDescriptor::kAccumulatorParameter),
333 IsParameter(InterpreterDispatchDescriptor::kRegisterFileParameter), 334 IsParameter(InterpreterDispatchDescriptor::kRegisterFileParameter),
334 IsParameter( 335 IsParameter(
335 InterpreterDispatchDescriptor::kBytecodeOffsetParameter), 336 InterpreterDispatchDescriptor::kBytecodeOffsetParameter),
336 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), 337 _,
337 IsParameter(InterpreterDispatchDescriptor::kDispatchTableParameter), 338 IsParameter(InterpreterDispatchDescriptor::kDispatchTableParameter),
338 IsParameter(InterpreterDispatchDescriptor::kContextParameter), _, 339 IsParameter(InterpreterDispatchDescriptor::kContextParameter), _,
339 _)); 340 _));
340 } 341 }
341 } 342 }
342 343
343 TARGET_TEST_F(InterpreterAssemblerTest, BytecodeOperand) { 344 TARGET_TEST_F(InterpreterAssemblerTest, BytecodeOperand) {
344 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { 345 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
345 InterpreterAssemblerForTest m(this, bytecode); 346 InterpreterAssemblerForTest m(this, bytecode);
346 int number_of_operands = interpreter::Bytecodes::NumberOfOperands(bytecode); 347 int number_of_operands = interpreter::Bytecodes::NumberOfOperands(bytecode);
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 feedback_vector, 687 feedback_vector,
687 m.IsLoad(MachineType::AnyTagged(), load_shared_function_info_matcher, 688 m.IsLoad(MachineType::AnyTagged(), load_shared_function_info_matcher,
688 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset - 689 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset -
689 kHeapObjectTag))); 690 kHeapObjectTag)));
690 } 691 }
691 } 692 }
692 693
693 } // namespace interpreter 694 } // namespace interpreter
694 } // namespace internal 695 } // namespace internal
695 } // namespace v8 696 } // namespace v8
OLDNEW
« no previous file with comments | « test/mjsunit/mjsunit.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698