| 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/compiler/bytecode-graph-builder.h" | 5 #include "src/compiler/bytecode-graph-builder.h" |
| 6 | 6 |
| 7 #include "src/compiler/linkage.h" | 7 #include "src/compiler/linkage.h" |
| 8 #include "src/compiler/operator-properties.h" | 8 #include "src/compiler/operator-properties.h" |
| 9 #include "src/interpreter/bytecode-array-iterator.h" | 9 #include "src/interpreter/bytecode-array-iterator.h" |
| 10 | 10 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 jsgraph_(jsgraph), | 106 jsgraph_(jsgraph), |
| 107 input_buffer_size_(0), | 107 input_buffer_size_(0), |
| 108 input_buffer_(nullptr), | 108 input_buffer_(nullptr), |
| 109 exit_controls_(local_zone) { | 109 exit_controls_(local_zone) { |
| 110 bytecode_array_ = handle(info()->shared_info()->bytecode_array()); | 110 bytecode_array_ = handle(info()->shared_info()->bytecode_array()); |
| 111 } | 111 } |
| 112 | 112 |
| 113 | 113 |
| 114 Node* BytecodeGraphBuilder::GetFunctionContext() { | 114 Node* BytecodeGraphBuilder::GetFunctionContext() { |
| 115 if (!function_context_.is_set()) { | 115 if (!function_context_.is_set()) { |
| 116 // Parameter (arity + 1) is special for the outer context of the function | 116 int params = bytecode_array()->parameter_count(); |
| 117 const Operator* op = common()->Parameter( | 117 int index = Linkage::GetJSCallContextParamIndex(params); |
| 118 bytecode_array()->parameter_count() + 1, "%context"); | 118 const Operator* op = common()->Parameter(index, "%context"); |
| 119 Node* node = NewNode(op, graph()->start()); | 119 Node* node = NewNode(op, graph()->start()); |
| 120 function_context_.set(node); | 120 function_context_.set(node); |
| 121 } | 121 } |
| 122 return function_context_.get(); | 122 return function_context_.get(); |
| 123 } | 123 } |
| 124 | 124 |
| 125 | 125 |
| 126 Node* BytecodeGraphBuilder::GetFunctionClosure() { | 126 Node* BytecodeGraphBuilder::GetFunctionClosure() { |
| 127 if (!function_closure_.is_set()) { | 127 if (!function_closure_.is_set()) { |
| 128 const Operator* op = common()->Parameter( | 128 int index = Linkage::kJSCallClosureParamIndex; |
| 129 Linkage::kJSFunctionCallClosureParamIndex, "%closure"); | 129 const Operator* op = common()->Parameter(index, "%closure"); |
| 130 Node* node = NewNode(op, graph()->start()); | 130 Node* node = NewNode(op, graph()->start()); |
| 131 function_closure_.set(node); | 131 function_closure_.set(node); |
| 132 } | 132 } |
| 133 return function_closure_.get(); | 133 return function_closure_.get(); |
| 134 } | 134 } |
| 135 | 135 |
| 136 | 136 |
| 137 Node* BytecodeGraphBuilder::BuildLoadImmutableObjectField(Node* object, | 137 Node* BytecodeGraphBuilder::BuildLoadImmutableObjectField(Node* object, |
| 138 int offset) { | 138 int offset) { |
| 139 return graph()->NewNode(jsgraph()->machine()->Load(kMachAnyTagged), object, | 139 return graph()->NewNode(jsgraph()->machine()->Load(kMachAnyTagged), object, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 | 175 |
| 176 | 176 |
| 177 bool BytecodeGraphBuilder::CreateGraph(bool stack_check) { | 177 bool BytecodeGraphBuilder::CreateGraph(bool stack_check) { |
| 178 // Set up the basic structure of the graph. Outputs for {Start} are | 178 // Set up the basic structure of the graph. Outputs for {Start} are |
| 179 // the formal parameters (including the receiver) plus context and | 179 // the formal parameters (including the receiver) plus context and |
| 180 // closure. | 180 // closure. |
| 181 | 181 |
| 182 // Set up the basic structure of the graph. Outputs for {Start} are the formal | 182 // Set up the basic structure of the graph. Outputs for {Start} are the formal |
| 183 // parameters (including the receiver) plus number of arguments, context and | 183 // parameters (including the receiver) plus new target, number of arguments, |
| 184 // closure. | 184 // context and closure. |
| 185 int actual_parameter_count = bytecode_array()->parameter_count() + 3; | 185 int actual_parameter_count = bytecode_array()->parameter_count() + 4; |
| 186 graph()->SetStart(graph()->NewNode(common()->Start(actual_parameter_count))); | 186 graph()->SetStart(graph()->NewNode(common()->Start(actual_parameter_count))); |
| 187 | 187 |
| 188 Environment env(this, bytecode_array()->register_count(), | 188 Environment env(this, bytecode_array()->register_count(), |
| 189 bytecode_array()->parameter_count(), graph()->start(), | 189 bytecode_array()->parameter_count(), graph()->start(), |
| 190 GetFunctionContext()); | 190 GetFunctionContext()); |
| 191 set_environment(&env); | 191 set_environment(&env); |
| 192 | 192 |
| 193 // Build function context only if there are context allocated variables. | 193 // Build function context only if there are context allocated variables. |
| 194 if (info()->num_heap_slots() > 0) { | 194 if (info()->num_heap_slots() > 0) { |
| 195 UNIMPLEMENTED(); // TODO(oth): Write ast-graph-builder equivalent. | 195 UNIMPLEMENTED(); // TODO(oth): Write ast-graph-builder equivalent. |
| (...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1069 | 1069 |
| 1070 void BytecodeGraphBuilder::UpdateControlDependencyToLeaveFunction(Node* exit) { | 1070 void BytecodeGraphBuilder::UpdateControlDependencyToLeaveFunction(Node* exit) { |
| 1071 if (environment()->IsMarkedAsUnreachable()) return; | 1071 if (environment()->IsMarkedAsUnreachable()) return; |
| 1072 environment()->MarkAsUnreachable(); | 1072 environment()->MarkAsUnreachable(); |
| 1073 exit_controls_.push_back(exit); | 1073 exit_controls_.push_back(exit); |
| 1074 } | 1074 } |
| 1075 | 1075 |
| 1076 } // namespace compiler | 1076 } // namespace compiler |
| 1077 } // namespace internal | 1077 } // namespace internal |
| 1078 } // namespace v8 | 1078 } // namespace v8 |
| OLD | NEW |