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 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 566 | 566 |
| 567 Handle<BytecodeArray> BytecodeGenerator::MakeBytecode(CompilationInfo* info) { | 567 Handle<BytecodeArray> BytecodeGenerator::MakeBytecode(CompilationInfo* info) { |
| 568 set_info(info); | 568 set_info(info); |
| 569 set_scope(info->scope()); | 569 set_scope(info->scope()); |
| 570 | 570 |
| 571 // Initialize bytecode array builder. | 571 // Initialize bytecode array builder. |
| 572 set_builder(new (zone()) BytecodeArrayBuilder( | 572 set_builder(new (zone()) BytecodeArrayBuilder( |
| 573 isolate(), zone(), info->num_parameters_including_this(), | 573 isolate(), zone(), info->num_parameters_including_this(), |
| 574 scope()->MaxNestedContextChainLength(), scope()->num_stack_slots())); | 574 scope()->MaxNestedContextChainLength(), scope()->num_stack_slots())); |
| 575 | 575 |
| 576 builder()->InitializeReturnPosition(info->literal()); | |
| 577 | |
| 576 // Initialize the incoming context. | 578 // Initialize the incoming context. |
| 577 ContextScope incoming_context(this, scope(), false); | 579 ContextScope incoming_context(this, scope(), false); |
| 578 | 580 |
| 579 // Initialize control scope. | 581 // Initialize control scope. |
| 580 ControlScopeForTopLevel control(this); | 582 ControlScopeForTopLevel control(this); |
| 581 | 583 |
| 582 // Build function context only if there are context allocated variables. | 584 // Build function context only if there are context allocated variables. |
| 583 if (scope()->NeedsContext()) { | 585 if (scope()->NeedsContext()) { |
| 584 // Push a new inner context scope for the function. | 586 // Push a new inner context scope for the function. |
| 585 VisitNewLocalFunctionContext(); | 587 VisitNewLocalFunctionContext(); |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 870 execution_control()->Continue(stmt->target()); | 872 execution_control()->Continue(stmt->target()); |
| 871 } | 873 } |
| 872 | 874 |
| 873 | 875 |
| 874 void BytecodeGenerator::VisitBreakStatement(BreakStatement* stmt) { | 876 void BytecodeGenerator::VisitBreakStatement(BreakStatement* stmt) { |
| 875 execution_control()->Break(stmt->target()); | 877 execution_control()->Break(stmt->target()); |
| 876 } | 878 } |
| 877 | 879 |
| 878 | 880 |
| 879 void BytecodeGenerator::VisitReturnStatement(ReturnStatement* stmt) { | 881 void BytecodeGenerator::VisitReturnStatement(ReturnStatement* stmt) { |
| 882 builder()->SetStatementPosition(stmt); | |
|
vogelheim
2016/02/29 17:43:30
Just for my understanding: These switched lines is
Yang
2016/02/29 17:53:12
Yes, correct.
| |
| 880 VisitForAccumulatorValue(stmt->expression()); | 883 VisitForAccumulatorValue(stmt->expression()); |
| 881 builder()->SetStatementPosition(stmt); | |
| 882 execution_control()->ReturnAccumulator(); | 884 execution_control()->ReturnAccumulator(); |
| 883 } | 885 } |
| 884 | 886 |
| 885 | 887 |
| 886 void BytecodeGenerator::VisitWithStatement(WithStatement* stmt) { | 888 void BytecodeGenerator::VisitWithStatement(WithStatement* stmt) { |
| 887 VisitForAccumulatorValue(stmt->expression()); | 889 VisitForAccumulatorValue(stmt->expression()); |
| 888 builder()->CastAccumulatorToJSObject(); | 890 builder()->CastAccumulatorToJSObject(); |
| 889 VisitNewLocalWithContext(); | 891 VisitNewLocalWithContext(); |
| 890 VisitInScope(stmt->statement(), stmt->scope()); | 892 VisitInScope(stmt->statement(), stmt->scope()); |
| 891 } | 893 } |
| (...skipping 2245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3137 } | 3139 } |
| 3138 | 3140 |
| 3139 | 3141 |
| 3140 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3142 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
| 3141 return info()->feedback_vector()->GetIndex(slot); | 3143 return info()->feedback_vector()->GetIndex(slot); |
| 3142 } | 3144 } |
| 3143 | 3145 |
| 3144 } // namespace interpreter | 3146 } // namespace interpreter |
| 3145 } // namespace internal | 3147 } // namespace internal |
| 3146 } // namespace v8 | 3148 } // namespace v8 |
| OLD | NEW |