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/compiler.h" | 8 #include "src/compiler.h" |
9 #include "src/interpreter/bytecode-register-allocator.h" | 9 #include "src/interpreter/bytecode-register-allocator.h" |
10 #include "src/interpreter/control-flow-builders.h" | 10 #include "src/interpreter/control-flow-builders.h" |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 | 623 |
624 // TODO(rmcilroy): Emit tracing call if requested to do so. | 624 // TODO(rmcilroy): Emit tracing call if requested to do so. |
625 if (FLAG_trace) { | 625 if (FLAG_trace) { |
626 UNIMPLEMENTED(); | 626 UNIMPLEMENTED(); |
627 } | 627 } |
628 | 628 |
629 // Visit declarations within the function scope. | 629 // Visit declarations within the function scope. |
630 VisitDeclarations(scope()->declarations()); | 630 VisitDeclarations(scope()->declarations()); |
631 | 631 |
632 // Perform a stack-check before the body. | 632 // Perform a stack-check before the body. |
633 builder()->StackCheck(); | 633 builder()->StackCheck(info()->literal()->start_position()); |
634 | 634 |
635 // Visit statements in the function body. | 635 // Visit statements in the function body. |
636 VisitStatements(info()->literal()->body()); | 636 VisitStatements(info()->literal()->body()); |
637 } | 637 } |
638 | 638 |
639 void BytecodeGenerator::BuildIndexedJump(Register index, size_t start_index, | 639 void BytecodeGenerator::BuildIndexedJump(Register index, size_t start_index, |
640 size_t size, | 640 size_t size, |
641 ZoneVector<BytecodeLabel>& targets) { | 641 ZoneVector<BytecodeLabel>& targets) { |
642 // TODO(neis): Optimize this by using a proper jump table. | 642 // TODO(neis): Optimize this by using a proper jump table. |
643 for (size_t i = start_index; i < start_index + size; i++) { | 643 for (size_t i = start_index; i < start_index + size; i++) { |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 | 1021 |
1022 | 1022 |
1023 void BytecodeGenerator::VisitCaseClause(CaseClause* clause) { | 1023 void BytecodeGenerator::VisitCaseClause(CaseClause* clause) { |
1024 // Handled entirely in VisitSwitchStatement. | 1024 // Handled entirely in VisitSwitchStatement. |
1025 UNREACHABLE(); | 1025 UNREACHABLE(); |
1026 } | 1026 } |
1027 | 1027 |
1028 void BytecodeGenerator::VisitIterationBody(IterationStatement* stmt, | 1028 void BytecodeGenerator::VisitIterationBody(IterationStatement* stmt, |
1029 LoopBuilder* loop_builder) { | 1029 LoopBuilder* loop_builder) { |
1030 ControlScopeForIteration execution_control(this, stmt, loop_builder); | 1030 ControlScopeForIteration execution_control(this, stmt, loop_builder); |
1031 builder()->StackCheck(); | 1031 builder()->StackCheck(stmt->position()); |
1032 Visit(stmt->body()); | 1032 Visit(stmt->body()); |
1033 } | 1033 } |
1034 | 1034 |
1035 void BytecodeGenerator::VisitDoWhileStatement(DoWhileStatement* stmt) { | 1035 void BytecodeGenerator::VisitDoWhileStatement(DoWhileStatement* stmt) { |
1036 LoopBuilder loop_builder(builder()); | 1036 LoopBuilder loop_builder(builder()); |
1037 VisitIterationHeader(stmt, &loop_builder); | 1037 VisitIterationHeader(stmt, &loop_builder); |
1038 if (stmt->cond()->ToBooleanIsFalse()) { | 1038 if (stmt->cond()->ToBooleanIsFalse()) { |
1039 VisitIterationBody(stmt, &loop_builder); | 1039 VisitIterationBody(stmt, &loop_builder); |
1040 loop_builder.Condition(); | 1040 loop_builder.Condition(); |
1041 } else if (stmt->cond()->ToBooleanIsTrue()) { | 1041 } else if (stmt->cond()->ToBooleanIsTrue()) { |
(...skipping 2221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3263 } | 3263 } |
3264 | 3264 |
3265 | 3265 |
3266 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3266 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
3267 return info()->shared_info()->feedback_vector()->GetIndex(slot); | 3267 return info()->shared_info()->feedback_vector()->GetIndex(slot); |
3268 } | 3268 } |
3269 | 3269 |
3270 } // namespace interpreter | 3270 } // namespace interpreter |
3271 } // namespace internal | 3271 } // namespace internal |
3272 } // namespace v8 | 3272 } // namespace v8 |
OLD | NEW |