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

Side by Side Diff: src/compiler/instruction-selector-unittest.cc

Issue 528963002: Revert "Make FrameStates recursive (to be used for inlining)." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/compiler/instruction-selector-impl.h ('k') | src/compiler/node.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 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 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/compiler/instruction-selector-unittest.h" 5 #include "src/compiler/instruction-selector-unittest.h"
6 6
7 #include "src/flags.h" 7 #include "src/flags.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 BailoutId bailout_id(42); 323 BailoutId bailout_id(42);
324 324
325 Node* function_node = m.Parameter(0); 325 Node* function_node = m.Parameter(0);
326 Node* receiver = m.Parameter(1); 326 Node* receiver = m.Parameter(1);
327 327
328 Node* parameters = m.NewNode(m.common()->StateValues(1), m.Int32Constant(1)); 328 Node* parameters = m.NewNode(m.common()->StateValues(1), m.Int32Constant(1));
329 Node* locals = m.NewNode(m.common()->StateValues(0)); 329 Node* locals = m.NewNode(m.common()->StateValues(0));
330 Node* stack = m.NewNode(m.common()->StateValues(0)); 330 Node* stack = m.NewNode(m.common()->StateValues(0));
331 Node* context_dummy = m.Int32Constant(0); 331 Node* context_dummy = m.Int32Constant(0);
332 332
333 Node* state_node = 333 Node* state_node = m.NewNode(m.common()->FrameState(bailout_id, kPushOutput),
334 m.NewNode(m.common()->FrameState(bailout_id, kPushOutput), parameters, 334 parameters, locals, stack, context_dummy);
335 locals, stack, context_dummy, m.UndefinedConstant());
336 Node* call = m.CallJS0(function_node, receiver, state_node); 335 Node* call = m.CallJS0(function_node, receiver, state_node);
337 m.Return(call); 336 m.Return(call);
338 337
339 Stream s = m.Build(kAllExceptNopInstructions); 338 Stream s = m.Build(kAllExceptNopInstructions);
340 339
341 // Skip until kArchCallJSFunction. 340 // Skip until kArchCallJSFunction.
342 size_t index = 0; 341 size_t index = 0;
343 for (; index < s.size() && s[index]->arch_opcode() != kArchCallJSFunction; 342 for (; index < s.size() && s[index]->arch_opcode() != kArchCallJSFunction;
344 index++) { 343 index++) {
345 } 344 }
(...skipping 15 matching lines...) Expand all
361 360
362 // Some arguments for the call node. 361 // Some arguments for the call node.
363 Node* function_node = m.Parameter(0); 362 Node* function_node = m.Parameter(0);
364 Node* receiver = m.Parameter(1); 363 Node* receiver = m.Parameter(1);
365 Node* context = m.Int32Constant(1); // Context is ignored. 364 Node* context = m.Int32Constant(1); // Context is ignored.
366 365
367 // Build frame state for the state before the call. 366 // Build frame state for the state before the call.
368 Node* parameters = m.NewNode(m.common()->StateValues(1), m.Int32Constant(43)); 367 Node* parameters = m.NewNode(m.common()->StateValues(1), m.Int32Constant(43));
369 Node* locals = m.NewNode(m.common()->StateValues(1), m.Int32Constant(44)); 368 Node* locals = m.NewNode(m.common()->StateValues(1), m.Int32Constant(44));
370 Node* stack = m.NewNode(m.common()->StateValues(1), m.Int32Constant(45)); 369 Node* stack = m.NewNode(m.common()->StateValues(1), m.Int32Constant(45));
371
372 Node* context_sentinel = m.Int32Constant(0); 370 Node* context_sentinel = m.Int32Constant(0);
373 Node* frame_state_before = m.NewNode( 371 Node* frame_state_before =
374 m.common()->FrameState(bailout_id_before, kPushOutput), parameters, 372 m.NewNode(m.common()->FrameState(bailout_id_before, kPushOutput),
375 locals, stack, context_sentinel, m.UndefinedConstant()); 373 parameters, locals, stack, context_sentinel);
376 374
377 // Build the call. 375 // Build the call.
378 Node* call = m.CallFunctionStub0(function_node, receiver, context, 376 Node* call = m.CallFunctionStub0(function_node, receiver, context,
379 frame_state_before, CALL_AS_METHOD); 377 frame_state_before, CALL_AS_METHOD);
380 378
381 m.Return(call); 379 m.Return(call);
382 380
383 Stream s = m.Build(kAllExceptNopInstructions); 381 Stream s = m.Build(kAllExceptNopInstructions);
384 382
385 // Skip until kArchCallJSFunction. 383 // Skip until kArchCallJSFunction.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 // Function. 419 // Function.
422 EXPECT_EQ(function_node->id(), s.ToVreg(call_instr->InputAt(6))); 420 EXPECT_EQ(function_node->id(), s.ToVreg(call_instr->InputAt(6)));
423 // Context. 421 // Context.
424 EXPECT_EQ(context->id(), s.ToVreg(call_instr->InputAt(7))); 422 EXPECT_EQ(context->id(), s.ToVreg(call_instr->InputAt(7)));
425 423
426 EXPECT_EQ(kArchRet, s[index++]->arch_opcode()); 424 EXPECT_EQ(kArchRet, s[index++]->arch_opcode());
427 425
428 EXPECT_EQ(index, s.size()); 426 EXPECT_EQ(index, s.size());
429 } 427 }
430 428
431
432 TARGET_TEST_F(InstructionSelectorTest,
433 CallFunctionStubDeoptRecursiveFrameState) {
434 StreamBuilder m(this, kMachAnyTagged, kMachAnyTagged, kMachAnyTagged,
435 kMachAnyTagged);
436
437 BailoutId bailout_id_before(42);
438 BailoutId bailout_id_parent(62);
439
440 // Some arguments for the call node.
441 Node* function_node = m.Parameter(0);
442 Node* receiver = m.Parameter(1);
443 Node* context = m.Int32Constant(66);
444
445 // Build frame state for the state before the call.
446 Node* parameters = m.NewNode(m.common()->StateValues(1), m.Int32Constant(63));
447 Node* locals = m.NewNode(m.common()->StateValues(1), m.Int32Constant(64));
448 Node* stack = m.NewNode(m.common()->StateValues(1), m.Int32Constant(65));
449 Node* frame_state_parent =
450 m.NewNode(m.common()->FrameState(bailout_id_parent, kIgnoreOutput),
451 parameters, locals, stack, context, m.UndefinedConstant());
452
453 Node* context2 = m.Int32Constant(46);
454 Node* parameters2 =
455 m.NewNode(m.common()->StateValues(1), m.Int32Constant(43));
456 Node* locals2 = m.NewNode(m.common()->StateValues(1), m.Int32Constant(44));
457 Node* stack2 = m.NewNode(m.common()->StateValues(1), m.Int32Constant(45));
458 Node* frame_state_before =
459 m.NewNode(m.common()->FrameState(bailout_id_before, kPushOutput),
460 parameters2, locals2, stack2, context2, frame_state_parent);
461
462 // Build the call.
463 Node* call = m.CallFunctionStub0(function_node, receiver, context2,
464 frame_state_before, CALL_AS_METHOD);
465
466 m.Return(call);
467
468 Stream s = m.Build(kAllExceptNopInstructions);
469
470 // Skip until kArchCallJSFunction.
471 size_t index = 0;
472 for (; index < s.size() && s[index]->arch_opcode() != kArchCallCodeObject;
473 index++) {
474 }
475 // Now we should have three instructions: call, return.
476 EXPECT_EQ(index + 2, s.size());
477
478 // Check the call instruction
479 const Instruction* call_instr = s[index++];
480 EXPECT_EQ(kArchCallCodeObject, call_instr->arch_opcode());
481 size_t num_operands =
482 1 + // Code object.
483 1 + // Frame state deopt id
484 4 + // One input for each value in frame state + context.
485 4 + // One input for each value in the parent frame state + context.
486 1 + // Function.
487 1; // Context.
488 EXPECT_EQ(num_operands, call_instr->InputCount());
489 // Code object.
490 EXPECT_TRUE(call_instr->InputAt(0)->IsImmediate());
491
492 // Deoptimization id.
493 int32_t deopt_id_before = s.ToInt32(call_instr->InputAt(1));
494 FrameStateDescriptor* desc_before =
495 s.GetFrameStateDescriptor(deopt_id_before);
496 EXPECT_EQ(bailout_id_before, desc_before->bailout_id());
497 EXPECT_EQ(1, desc_before->parameters_count());
498 EXPECT_EQ(1, desc_before->locals_count());
499 EXPECT_EQ(1, desc_before->stack_count());
500 EXPECT_EQ(63, s.ToInt32(call_instr->InputAt(2)));
501 // Context:
502 EXPECT_EQ(66, s.ToInt32(call_instr->InputAt(3)));
503 EXPECT_EQ(64, s.ToInt32(call_instr->InputAt(4)));
504 EXPECT_EQ(65, s.ToInt32(call_instr->InputAt(5)));
505 // Values from parent environment should follow.
506 EXPECT_EQ(43, s.ToInt32(call_instr->InputAt(6)));
507 EXPECT_EQ(46, s.ToInt32(call_instr->InputAt(7)));
508 EXPECT_EQ(44, s.ToInt32(call_instr->InputAt(8)));
509 EXPECT_EQ(45, s.ToInt32(call_instr->InputAt(9)));
510
511 // Function.
512 EXPECT_EQ(function_node->id(), s.ToVreg(call_instr->InputAt(10)));
513 // Context.
514 EXPECT_EQ(context2->id(), s.ToVreg(call_instr->InputAt(11)));
515 // Continuation.
516
517 EXPECT_EQ(kArchRet, s[index++]->arch_opcode());
518 EXPECT_EQ(index, s.size());
519 }
520
521 } // namespace compiler 429 } // namespace compiler
522 } // namespace internal 430 } // namespace internal
523 } // namespace v8 431 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/instruction-selector-impl.h ('k') | src/compiler/node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698