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 namespace v8 { | 7 namespace v8 { |
8 namespace internal { | 8 namespace internal { |
9 namespace interpreter { | 9 namespace interpreter { |
10 | 10 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 Strength strength) { | 144 Strength strength) { |
145 if (is_strong(strength)) { | 145 if (is_strong(strength)) { |
146 UNIMPLEMENTED(); | 146 UNIMPLEMENTED(); |
147 } | 147 } |
148 | 148 |
149 Output(BytecodeForBinaryOperation(op), reg.ToOperand()); | 149 Output(BytecodeForBinaryOperation(op), reg.ToOperand()); |
150 return *this; | 150 return *this; |
151 } | 151 } |
152 | 152 |
153 | 153 |
| 154 BytecodeArrayBuilder& BytecodeArrayBuilder::CountOperation(Token::Value op, |
| 155 Strength strength) { |
| 156 if (is_strong(strength)) { |
| 157 UNIMPLEMENTED(); |
| 158 } |
| 159 |
| 160 Output(BytecodeForCountOperation(op)); |
| 161 return *this; |
| 162 } |
| 163 |
| 164 |
154 BytecodeArrayBuilder& BytecodeArrayBuilder::LogicalNot() { | 165 BytecodeArrayBuilder& BytecodeArrayBuilder::LogicalNot() { |
155 Output(Bytecode::kLogicalNot); | 166 Output(Bytecode::kLogicalNot); |
156 return *this; | 167 return *this; |
157 } | 168 } |
158 | 169 |
159 | 170 |
160 BytecodeArrayBuilder& BytecodeArrayBuilder::TypeOf() { | 171 BytecodeArrayBuilder& BytecodeArrayBuilder::TypeOf() { |
161 Output(Bytecode::kTypeOf); | 172 Output(Bytecode::kTypeOf); |
162 return *this; | 173 return *this; |
163 } | 174 } |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 return *this; | 432 return *this; |
422 } | 433 } |
423 | 434 |
424 | 435 |
425 BytecodeArrayBuilder& BytecodeArrayBuilder::CastAccumulatorToName() { | 436 BytecodeArrayBuilder& BytecodeArrayBuilder::CastAccumulatorToName() { |
426 Output(Bytecode::kToName); | 437 Output(Bytecode::kToName); |
427 return *this; | 438 return *this; |
428 } | 439 } |
429 | 440 |
430 | 441 |
| 442 BytecodeArrayBuilder& BytecodeArrayBuilder::CastAccumulatorToNumber() { |
| 443 // TODO(rmcilroy): consider omitting if the preceeding bytecode always returns |
| 444 // a number. |
| 445 Output(Bytecode::kToNumber); |
| 446 return *this; |
| 447 } |
| 448 |
| 449 |
431 BytecodeArrayBuilder& BytecodeArrayBuilder::Bind(BytecodeLabel* label) { | 450 BytecodeArrayBuilder& BytecodeArrayBuilder::Bind(BytecodeLabel* label) { |
432 if (label->is_forward_target()) { | 451 if (label->is_forward_target()) { |
433 // An earlier jump instruction refers to this label. Update it's location. | 452 // An earlier jump instruction refers to this label. Update it's location. |
434 PatchJump(bytecodes()->end(), bytecodes()->begin() + label->offset()); | 453 PatchJump(bytecodes()->end(), bytecodes()->begin() + label->offset()); |
435 // Now treat as if the label will only be back referred to. | 454 // Now treat as if the label will only be back referred to. |
436 } | 455 } |
437 label->bind_to(bytecodes()->size()); | 456 label->bind_to(bytecodes()->size()); |
438 return *this; | 457 return *this; |
439 } | 458 } |
440 | 459 |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 case Token::Value::SHR: | 736 case Token::Value::SHR: |
718 return Bytecode::kShiftRightLogical; | 737 return Bytecode::kShiftRightLogical; |
719 default: | 738 default: |
720 UNREACHABLE(); | 739 UNREACHABLE(); |
721 return static_cast<Bytecode>(-1); | 740 return static_cast<Bytecode>(-1); |
722 } | 741 } |
723 } | 742 } |
724 | 743 |
725 | 744 |
726 // static | 745 // static |
| 746 Bytecode BytecodeArrayBuilder::BytecodeForCountOperation(Token::Value op) { |
| 747 switch (op) { |
| 748 case Token::Value::ADD: |
| 749 return Bytecode::kInc; |
| 750 case Token::Value::SUB: |
| 751 return Bytecode::kDec; |
| 752 default: |
| 753 UNREACHABLE(); |
| 754 return static_cast<Bytecode>(-1); |
| 755 } |
| 756 } |
| 757 |
| 758 |
| 759 // static |
727 Bytecode BytecodeArrayBuilder::BytecodeForCompareOperation(Token::Value op) { | 760 Bytecode BytecodeArrayBuilder::BytecodeForCompareOperation(Token::Value op) { |
728 switch (op) { | 761 switch (op) { |
729 case Token::Value::EQ: | 762 case Token::Value::EQ: |
730 return Bytecode::kTestEqual; | 763 return Bytecode::kTestEqual; |
731 case Token::Value::NE: | 764 case Token::Value::NE: |
732 return Bytecode::kTestNotEqual; | 765 return Bytecode::kTestNotEqual; |
733 case Token::Value::EQ_STRICT: | 766 case Token::Value::EQ_STRICT: |
734 return Bytecode::kTestEqualStrict; | 767 return Bytecode::kTestEqualStrict; |
735 case Token::Value::NE_STRICT: | 768 case Token::Value::NE_STRICT: |
736 return Bytecode::kTestNotEqualStrict; | 769 return Bytecode::kTestNotEqualStrict; |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 | 906 |
874 Register TemporaryRegisterScope::NewRegister() { | 907 Register TemporaryRegisterScope::NewRegister() { |
875 count_++; | 908 count_++; |
876 last_register_index_ = builder_->BorrowTemporaryRegister(); | 909 last_register_index_ = builder_->BorrowTemporaryRegister(); |
877 return Register(last_register_index_); | 910 return Register(last_register_index_); |
878 } | 911 } |
879 | 912 |
880 } // namespace interpreter | 913 } // namespace interpreter |
881 } // namespace internal | 914 } // namespace internal |
882 } // namespace v8 | 915 } // namespace v8 |
OLD | NEW |