| 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 "src/interpreter/bytecode-array-builder.h" | 5 #include "src/interpreter/bytecode-array-builder.h" |
| 6 | 6 |
| 7 #include "src/globals.h" | 7 #include "src/globals.h" |
| 8 #include "src/interpreter/bytecode-array-writer.h" | 8 #include "src/interpreter/bytecode-array-writer.h" |
| 9 #include "src/interpreter/bytecode-dead-code-optimizer.h" | 9 #include "src/interpreter/bytecode-dead-code-optimizer.h" |
| 10 #include "src/interpreter/bytecode-label.h" | 10 #include "src/interpreter/bytecode-label.h" |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 return *this; | 445 return *this; |
| 446 } | 446 } |
| 447 | 447 |
| 448 BytecodeArrayBuilder& BytecodeArrayBuilder::Bind(const BytecodeLabel& target, | 448 BytecodeArrayBuilder& BytecodeArrayBuilder::Bind(const BytecodeLabel& target, |
| 449 BytecodeLabel* label) { | 449 BytecodeLabel* label) { |
| 450 pipeline_->BindLabel(target, label); | 450 pipeline_->BindLabel(target, label); |
| 451 LeaveBasicBlock(); | 451 LeaveBasicBlock(); |
| 452 return *this; | 452 return *this; |
| 453 } | 453 } |
| 454 | 454 |
| 455 BytecodeArrayBuilder& BytecodeArrayBuilder::OutputJump(Bytecode jump_bytecode, | 455 BytecodeArrayBuilder& BytecodeArrayBuilder::OutputJump(BytecodeNode* node, |
| 456 BytecodeLabel* label) { | 456 BytecodeLabel* label) { |
| 457 BytecodeNode node(jump_bytecode, 0); | 457 AttachSourceInfo(node); |
| 458 AttachSourceInfo(&node); | 458 pipeline_->WriteJump(node, label); |
| 459 pipeline_->WriteJump(&node, label); | |
| 460 LeaveBasicBlock(); | 459 LeaveBasicBlock(); |
| 461 return *this; | 460 return *this; |
| 462 } | 461 } |
| 463 | 462 |
| 464 BytecodeArrayBuilder& BytecodeArrayBuilder::Jump(BytecodeLabel* label) { | 463 BytecodeArrayBuilder& BytecodeArrayBuilder::Jump(BytecodeLabel* label) { |
| 465 return OutputJump(Bytecode::kJump, label); | 464 BytecodeNode node(Bytecode::kJump, 0); |
| 465 return OutputJump(&node, label); |
| 466 } | 466 } |
| 467 | 467 |
| 468 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfTrue(BytecodeLabel* label) { | 468 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfTrue(BytecodeLabel* label) { |
| 469 // The peephole optimizer attempts to simplify JumpIfToBooleanTrue | 469 // The peephole optimizer attempts to simplify JumpIfToBooleanTrue |
| 470 // to JumpIfTrue. | 470 // to JumpIfTrue. |
| 471 return OutputJump(Bytecode::kJumpIfToBooleanTrue, label); | 471 BytecodeNode node(Bytecode::kJumpIfToBooleanTrue, 0); |
| 472 return OutputJump(&node, label); |
| 472 } | 473 } |
| 473 | 474 |
| 474 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfFalse(BytecodeLabel* label) { | 475 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfFalse(BytecodeLabel* label) { |
| 475 // The peephole optimizer attempts to simplify JumpIfToBooleanFalse | 476 // The peephole optimizer attempts to simplify JumpIfToBooleanFalse |
| 476 // to JumpIfFalse. | 477 // to JumpIfFalse. |
| 477 return OutputJump(Bytecode::kJumpIfToBooleanFalse, label); | 478 BytecodeNode node(Bytecode::kJumpIfToBooleanFalse, 0); |
| 479 return OutputJump(&node, label); |
| 478 } | 480 } |
| 479 | 481 |
| 480 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfNull(BytecodeLabel* label) { | 482 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfNull(BytecodeLabel* label) { |
| 481 return OutputJump(Bytecode::kJumpIfNull, label); | 483 BytecodeNode node(Bytecode::kJumpIfNull, 0); |
| 484 return OutputJump(&node, label); |
| 482 } | 485 } |
| 483 | 486 |
| 484 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfUndefined( | 487 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfUndefined( |
| 485 BytecodeLabel* label) { | 488 BytecodeLabel* label) { |
| 486 return OutputJump(Bytecode::kJumpIfUndefined, label); | 489 BytecodeNode node(Bytecode::kJumpIfUndefined, 0); |
| 490 return OutputJump(&node, label); |
| 487 } | 491 } |
| 488 | 492 |
| 489 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfNotHole( | 493 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfNotHole( |
| 490 BytecodeLabel* label) { | 494 BytecodeLabel* label) { |
| 491 return OutputJump(Bytecode::kJumpIfNotHole, label); | 495 BytecodeNode node(Bytecode::kJumpIfNotHole, 0); |
| 496 return OutputJump(&node, label); |
| 497 } |
| 498 |
| 499 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpLoop(BytecodeLabel* label, |
| 500 int loop_depth) { |
| 501 BytecodeNode node(Bytecode::kJumpLoop, 0, UnsignedOperand(loop_depth)); |
| 502 return OutputJump(&node, label); |
| 492 } | 503 } |
| 493 | 504 |
| 494 BytecodeArrayBuilder& BytecodeArrayBuilder::StackCheck(int position) { | 505 BytecodeArrayBuilder& BytecodeArrayBuilder::StackCheck(int position) { |
| 495 if (position != kNoSourcePosition) { | 506 if (position != kNoSourcePosition) { |
| 496 // We need to attach a non-breakable source position to a stack | 507 // We need to attach a non-breakable source position to a stack |
| 497 // check, so we simply add it as expression position. There can be | 508 // check, so we simply add it as expression position. There can be |
| 498 // a prior statement position from constructs like: | 509 // a prior statement position from constructs like: |
| 499 // | 510 // |
| 500 // do var x; while (false); | 511 // do var x; while (false); |
| 501 // | 512 // |
| 502 // A Nop could be inserted for empty statements, but since no code | 513 // A Nop could be inserted for empty statements, but since no code |
| 503 // is associated with these positions, instead we force the stack | 514 // is associated with these positions, instead we force the stack |
| 504 // check's expression position which eliminates the empty | 515 // check's expression position which eliminates the empty |
| 505 // statement's position. | 516 // statement's position. |
| 506 latest_source_info_.ForceExpressionPosition(position); | 517 latest_source_info_.ForceExpressionPosition(position); |
| 507 } | 518 } |
| 508 Output(Bytecode::kStackCheck); | 519 Output(Bytecode::kStackCheck); |
| 509 return *this; | 520 return *this; |
| 510 } | 521 } |
| 511 | 522 |
| 512 BytecodeArrayBuilder& BytecodeArrayBuilder::OsrPoll(int loop_depth) { | |
| 513 Output(Bytecode::kOsrPoll, UnsignedOperand(loop_depth)); | |
| 514 return *this; | |
| 515 } | |
| 516 | |
| 517 BytecodeArrayBuilder& BytecodeArrayBuilder::Throw() { | 523 BytecodeArrayBuilder& BytecodeArrayBuilder::Throw() { |
| 518 Output(Bytecode::kThrow); | 524 Output(Bytecode::kThrow); |
| 519 return *this; | 525 return *this; |
| 520 } | 526 } |
| 521 | 527 |
| 522 BytecodeArrayBuilder& BytecodeArrayBuilder::ReThrow() { | 528 BytecodeArrayBuilder& BytecodeArrayBuilder::ReThrow() { |
| 523 Output(Bytecode::kReThrow); | 529 Output(Bytecode::kReThrow); |
| 524 return *this; | 530 return *this; |
| 525 } | 531 } |
| 526 | 532 |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 return Bytecode::kTailCall; | 1002 return Bytecode::kTailCall; |
| 997 default: | 1003 default: |
| 998 UNREACHABLE(); | 1004 UNREACHABLE(); |
| 999 } | 1005 } |
| 1000 return Bytecode::kIllegal; | 1006 return Bytecode::kIllegal; |
| 1001 } | 1007 } |
| 1002 | 1008 |
| 1003 } // namespace interpreter | 1009 } // namespace interpreter |
| 1004 } // namespace internal | 1010 } // namespace internal |
| 1005 } // namespace v8 | 1011 } // namespace v8 |
| OLD | NEW |