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-generator.h" | 5 #include "src/interpreter/bytecode-generator.h" |
6 | 6 |
7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/interpreter/bytecode-register-allocator.h" | 10 #include "src/interpreter/bytecode-register-allocator.h" |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 size_t size, | 648 size_t size, |
649 ZoneVector<BytecodeLabel>& targets) { | 649 ZoneVector<BytecodeLabel>& targets) { |
650 // TODO(neis): Optimize this by using a proper jump table. | 650 // TODO(neis): Optimize this by using a proper jump table. |
651 for (size_t i = start_index; i < start_index + size; i++) { | 651 for (size_t i = start_index; i < start_index + size; i++) { |
652 DCHECK(0 <= i && i < targets.size()); | 652 DCHECK(0 <= i && i < targets.size()); |
653 builder() | 653 builder() |
654 ->LoadLiteral(Smi::FromInt(static_cast<int>(i))) | 654 ->LoadLiteral(Smi::FromInt(static_cast<int>(i))) |
655 .CompareOperation(Token::Value::EQ_STRICT, index) | 655 .CompareOperation(Token::Value::EQ_STRICT, index) |
656 .JumpIfTrue(&(targets[i])); | 656 .JumpIfTrue(&(targets[i])); |
657 } | 657 } |
| 658 // TODO(oth): This should be an abort via the runtime with a |
| 659 // corresponding message., An illegal bytecode should never be |
| 660 // emitted in valid bytecode. |
658 builder()->Illegal(); // Should never get here. | 661 builder()->Illegal(); // Should never get here. |
659 } | 662 } |
660 | 663 |
661 void BytecodeGenerator::VisitIterationHeader(IterationStatement* stmt, | 664 void BytecodeGenerator::VisitIterationHeader(IterationStatement* stmt, |
662 LoopBuilder* loop_builder) { | 665 LoopBuilder* loop_builder) { |
663 // Recall that stmt->yield_count() is always zero inside ordinary | 666 // Recall that stmt->yield_count() is always zero inside ordinary |
664 // (i.e. non-generator) functions. | 667 // (i.e. non-generator) functions. |
665 | 668 |
666 // Collect all labels for generator resume points within the loop (if any) so | 669 // Collect all labels for generator resume points within the loop (if any) so |
667 // that they can be bound to the loop header below. Also create fresh labels | 670 // that they can be bound to the loop header below. Also create fresh labels |
(...skipping 2599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3267 } | 3270 } |
3268 | 3271 |
3269 | 3272 |
3270 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3273 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
3271 return info()->shared_info()->feedback_vector()->GetIndex(slot); | 3274 return info()->shared_info()->feedback_vector()->GetIndex(slot); |
3272 } | 3275 } |
3273 | 3276 |
3274 } // namespace interpreter | 3277 } // namespace interpreter |
3275 } // namespace internal | 3278 } // namespace internal |
3276 } // namespace v8 | 3279 } // namespace v8 |
OLD | NEW |