Chromium Code Reviews| 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 | 658 |
| 659 // corresponding message., An illegal bytecode should never be | 659 RegisterAllocationScope register_scope(this); |
|
rmcilroy
2016/05/13 12:41:27
Nit - put this in its own block.
| |
| 660 // emitted in valid bytecode. | 660 Register reason = register_allocator()->NewRegister(); |
| 661 builder()->Illegal(); // Should never get here. | 661 BailoutReason bailout_reason = BailoutReason::kInvalidJumpTableIndex; |
| 662 builder() | |
| 663 ->LoadLiteral(Smi::FromInt(static_cast<int>(bailout_reason))) | |
| 664 .StoreAccumulatorInRegister(reason) | |
| 665 .CallRuntime(Runtime::kAbort, reason, 1); | |
| 662 } | 666 } |
| 663 | 667 |
| 664 void BytecodeGenerator::VisitIterationHeader(IterationStatement* stmt, | 668 void BytecodeGenerator::VisitIterationHeader(IterationStatement* stmt, |
| 665 LoopBuilder* loop_builder) { | 669 LoopBuilder* loop_builder) { |
| 666 // Recall that stmt->yield_count() is always zero inside ordinary | 670 // Recall that stmt->yield_count() is always zero inside ordinary |
| 667 // (i.e. non-generator) functions. | 671 // (i.e. non-generator) functions. |
| 668 | 672 |
| 669 // Collect all labels for generator resume points within the loop (if any) so | 673 // Collect all labels for generator resume points within the loop (if any) so |
| 670 // that they can be bound to the loop header below. Also create fresh labels | 674 // that they can be bound to the loop header below. Also create fresh labels |
| 671 // for these resume points, to be used inside the loop. | 675 // for these resume points, to be used inside the loop. |
| (...skipping 2598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3270 } | 3274 } |
| 3271 | 3275 |
| 3272 | 3276 |
| 3273 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3277 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
| 3274 return info()->shared_info()->feedback_vector()->GetIndex(slot); | 3278 return info()->shared_info()->feedback_vector()->GetIndex(slot); |
| 3275 } | 3279 } |
| 3276 | 3280 |
| 3277 } // namespace interpreter | 3281 } // namespace interpreter |
| 3278 } // namespace internal | 3282 } // namespace internal |
| 3279 } // namespace v8 | 3283 } // namespace v8 |
| OLD | NEW |