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