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/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 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 961 } | 961 } |
| 962 | 962 |
| 963 void BytecodeGenerator::VisitIterationBody(IterationStatement* stmt, | 963 void BytecodeGenerator::VisitIterationBody(IterationStatement* stmt, |
| 964 LoopBuilder* loop_builder) { | 964 LoopBuilder* loop_builder) { |
| 965 ControlScopeForIteration execution_control(this, stmt, loop_builder); | 965 ControlScopeForIteration execution_control(this, stmt, loop_builder); |
| 966 builder()->StackCheck(); | 966 builder()->StackCheck(); |
| 967 Visit(stmt->body()); | 967 Visit(stmt->body()); |
| 968 } | 968 } |
| 969 | 969 |
| 970 void BytecodeGenerator::VisitDoWhileStatement(DoWhileStatement* stmt) { | 970 void BytecodeGenerator::VisitDoWhileStatement(DoWhileStatement* stmt) { |
| 971 builder()->SetStatementPosition(stmt); | |
|
Yang
2016/03/15 09:32:12
In FCG, we set a statement position, but no debug
| |
| 972 LoopBuilder loop_builder(builder()); | 971 LoopBuilder loop_builder(builder()); |
| 973 loop_builder.LoopHeader(); | 972 loop_builder.LoopHeader(); |
| 974 if (stmt->cond()->ToBooleanIsFalse()) { | 973 if (stmt->cond()->ToBooleanIsFalse()) { |
| 975 VisitIterationBody(stmt, &loop_builder); | 974 VisitIterationBody(stmt, &loop_builder); |
| 976 loop_builder.Condition(); | 975 loop_builder.Condition(); |
| 977 } else if (stmt->cond()->ToBooleanIsTrue()) { | 976 } else if (stmt->cond()->ToBooleanIsTrue()) { |
| 978 loop_builder.Condition(); | 977 loop_builder.Condition(); |
| 979 VisitIterationBody(stmt, &loop_builder); | 978 VisitIterationBody(stmt, &loop_builder); |
| 980 loop_builder.JumpToHeader(); | 979 loop_builder.JumpToHeader(); |
| 981 } else { | 980 } else { |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 1003 loop_builder.BreakIfFalse(); | 1002 loop_builder.BreakIfFalse(); |
| 1004 } | 1003 } |
| 1005 VisitIterationBody(stmt, &loop_builder); | 1004 VisitIterationBody(stmt, &loop_builder); |
| 1006 loop_builder.JumpToHeader(); | 1005 loop_builder.JumpToHeader(); |
| 1007 loop_builder.EndLoop(); | 1006 loop_builder.EndLoop(); |
| 1008 } | 1007 } |
| 1009 | 1008 |
| 1010 | 1009 |
| 1011 void BytecodeGenerator::VisitForStatement(ForStatement* stmt) { | 1010 void BytecodeGenerator::VisitForStatement(ForStatement* stmt) { |
| 1012 if (stmt->init() != nullptr) { | 1011 if (stmt->init() != nullptr) { |
| 1013 builder()->SetStatementPosition(stmt->init()); | |
| 1014 Visit(stmt->init()); | 1012 Visit(stmt->init()); |
| 1015 } | 1013 } |
| 1016 if (stmt->cond() && stmt->cond()->ToBooleanIsFalse()) { | 1014 if (stmt->cond() && stmt->cond()->ToBooleanIsFalse()) { |
| 1017 // If the condition is known to be false there is no need to generate | 1015 // If the condition is known to be false there is no need to generate |
| 1018 // body, next or condition blocks. Init block should be generated. | 1016 // body, next or condition blocks. Init block should be generated. |
| 1019 return; | 1017 return; |
| 1020 } | 1018 } |
| 1021 | 1019 |
| 1022 LoopBuilder loop_builder(builder()); | 1020 LoopBuilder loop_builder(builder()); |
| 1023 loop_builder.LoopHeader(); | 1021 loop_builder.LoopHeader(); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1139 USE(cache_array); | 1137 USE(cache_array); |
| 1140 builder()->ForInPrepare(cache_type); | 1138 builder()->ForInPrepare(cache_type); |
| 1141 | 1139 |
| 1142 // Set up loop counter | 1140 // Set up loop counter |
| 1143 Register index = register_allocator()->NewRegister(); | 1141 Register index = register_allocator()->NewRegister(); |
| 1144 builder()->LoadLiteral(Smi::FromInt(0)); | 1142 builder()->LoadLiteral(Smi::FromInt(0)); |
| 1145 builder()->StoreAccumulatorInRegister(index); | 1143 builder()->StoreAccumulatorInRegister(index); |
| 1146 | 1144 |
| 1147 // The loop | 1145 // The loop |
| 1148 loop_builder.LoopHeader(); | 1146 loop_builder.LoopHeader(); |
| 1147 builder()->SetExpressionAsStatementPosition(stmt->each()); | |
| 1149 loop_builder.Condition(); | 1148 loop_builder.Condition(); |
| 1150 builder()->ForInDone(index, cache_length); | 1149 builder()->ForInDone(index, cache_length); |
| 1151 loop_builder.BreakIfTrue(); | 1150 loop_builder.BreakIfTrue(); |
| 1152 DCHECK(Register::AreContiguous(cache_type, cache_array)); | 1151 DCHECK(Register::AreContiguous(cache_type, cache_array)); |
| 1153 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot(); | 1152 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot(); |
| 1154 builder()->ForInNext(receiver, index, cache_type, feedback_index(slot)); | 1153 builder()->ForInNext(receiver, index, cache_type, feedback_index(slot)); |
| 1155 loop_builder.ContinueIfUndefined(); | 1154 loop_builder.ContinueIfUndefined(); |
| 1156 builder()->SetExpressionAsStatementPosition(stmt->each()); | |
| 1157 VisitForInAssignment(stmt->each(), stmt->EachFeedbackSlot()); | 1155 VisitForInAssignment(stmt->each(), stmt->EachFeedbackSlot()); |
| 1158 VisitIterationBody(stmt, &loop_builder); | 1156 VisitIterationBody(stmt, &loop_builder); |
| 1159 loop_builder.Next(); | 1157 loop_builder.Next(); |
| 1160 builder()->ForInStep(index); | 1158 builder()->ForInStep(index); |
| 1161 builder()->StoreAccumulatorInRegister(index); | 1159 builder()->StoreAccumulatorInRegister(index); |
| 1162 loop_builder.JumpToHeader(); | 1160 loop_builder.JumpToHeader(); |
| 1163 loop_builder.EndLoop(); | 1161 loop_builder.EndLoop(); |
| 1164 builder()->Bind(&subject_null_label); | 1162 builder()->Bind(&subject_null_label); |
| 1165 builder()->Bind(&subject_undefined_label); | 1163 builder()->Bind(&subject_undefined_label); |
| 1166 } | 1164 } |
| (...skipping 1990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3157 } | 3155 } |
| 3158 | 3156 |
| 3159 | 3157 |
| 3160 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3158 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
| 3161 return info()->feedback_vector()->GetIndex(slot); | 3159 return info()->feedback_vector()->GetIndex(slot); |
| 3162 } | 3160 } |
| 3163 | 3161 |
| 3164 } // namespace interpreter | 3162 } // namespace interpreter |
| 3165 } // namespace internal | 3163 } // namespace internal |
| 3166 } // namespace v8 | 3164 } // namespace v8 |
| OLD | NEW |