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/compiler/frame-states.h" | 5 #include "src/compiler/frame-states.h" |
| 6 | 6 |
| 7 #include "src/base/functional.h" | 7 #include "src/base/functional.h" |
| 8 #include "src/callable.h" | |
| 9 #include "src/compiler/graph.h" | |
| 10 #include "src/compiler/js-graph.h" | |
| 11 #include "src/compiler/node.h" | |
| 8 #include "src/handles-inl.h" | 12 #include "src/handles-inl.h" |
| 9 #include "src/objects-inl.h" | 13 #include "src/objects-inl.h" |
| 10 | 14 |
| 11 namespace v8 { | 15 namespace v8 { |
| 12 namespace internal { | 16 namespace internal { |
| 13 namespace compiler { | 17 namespace compiler { |
| 14 | 18 |
| 15 size_t hash_value(OutputFrameStateCombine const& sc) { | 19 size_t hash_value(OutputFrameStateCombine const& sc) { |
| 16 return base::hash_combine(sc.kind_, sc.parameter_); | 20 return base::hash_combine(sc.kind_, sc.parameter_); |
| 17 } | 21 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 break; | 62 break; |
| 59 case FrameStateType::kArgumentsAdaptor: | 63 case FrameStateType::kArgumentsAdaptor: |
| 60 os << "ARGUMENTS_ADAPTOR"; | 64 os << "ARGUMENTS_ADAPTOR"; |
| 61 break; | 65 break; |
| 62 case FrameStateType::kTailCallerFunction: | 66 case FrameStateType::kTailCallerFunction: |
| 63 os << "TAIL_CALLER_FRAME"; | 67 os << "TAIL_CALLER_FRAME"; |
| 64 break; | 68 break; |
| 65 case FrameStateType::kConstructStub: | 69 case FrameStateType::kConstructStub: |
| 66 os << "CONSTRUCT_STUB"; | 70 os << "CONSTRUCT_STUB"; |
| 67 break; | 71 break; |
| 72 case FrameStateType::kBuiltinContinuation: | |
| 73 os << "BUILTIN_CONTINUATION_FRAME"; | |
| 74 break; | |
| 68 case FrameStateType::kGetterStub: | 75 case FrameStateType::kGetterStub: |
| 69 os << "GETTER_STUB"; | 76 os << "GETTER_STUB"; |
| 70 break; | 77 break; |
| 71 case FrameStateType::kSetterStub: | 78 case FrameStateType::kSetterStub: |
| 72 os << "SETTER_STUB"; | 79 os << "SETTER_STUB"; |
| 73 break; | 80 break; |
| 74 } | 81 } |
| 75 return os; | 82 return os; |
| 76 } | 83 } |
| 77 | 84 |
| 78 | 85 |
| 79 std::ostream& operator<<(std::ostream& os, FrameStateInfo const& info) { | 86 std::ostream& operator<<(std::ostream& os, FrameStateInfo const& info) { |
| 80 os << info.type() << ", " << info.bailout_id() << ", " | 87 os << info.type() << ", " << info.bailout_id() << ", " |
| 81 << info.state_combine(); | 88 << info.state_combine(); |
| 82 Handle<SharedFunctionInfo> shared_info; | 89 Handle<SharedFunctionInfo> shared_info; |
| 83 if (info.shared_info().ToHandle(&shared_info)) { | 90 if (info.shared_info().ToHandle(&shared_info)) { |
| 84 os << ", " << Brief(*shared_info); | 91 os << ", " << Brief(*shared_info); |
| 85 } | 92 } |
| 86 return os; | 93 return os; |
| 87 } | 94 } |
| 88 | 95 |
| 96 namespace { | |
| 97 Node* CreateBuiltinContinuationFrameStateCommon( | |
| 98 JSGraph* js_graph, Builtins::Name name, Node** parameters, | |
| 99 int parameter_count, Node* outer_frame_state, | |
| 100 Handle<SharedFunctionInfo> shared) { | |
| 101 Isolate* isolate = js_graph->isolate(); | |
| 102 Graph* graph = js_graph->graph(); | |
| 103 CommonOperatorBuilder* common = js_graph->common(); | |
| 104 | |
| 105 BailoutId bailout_id = Builtins::GetContinuationBailoutId(name); | |
| 106 Callable callable = Builtins::CallableFor(isolate, name); | |
| 107 | |
| 108 const Operator* op_param = | |
| 109 common->StateValues(parameter_count, SparseInputMask::Dense()); | |
| 110 Node* params_node = graph->NewNode(op_param, parameter_count, parameters); | |
| 111 | |
| 112 const FrameStateFunctionInfo* state_info = | |
| 113 common->CreateFrameStateFunctionInfo(FrameStateType::kBuiltinContinuation, | |
| 114 parameter_count, 0, shared); | |
| 115 const Operator* op = common->FrameState( | |
| 116 bailout_id, OutputFrameStateCombine::Ignore(), state_info); | |
| 117 const Operator* op0 = common->StateValues(0, SparseInputMask::Dense()); | |
| 118 Node* node0 = graph->NewNode(op0); | |
| 119 | |
| 120 Node* frame_state = graph->NewNode( | |
| 121 op, params_node, node0, node0, js_graph->UndefinedConstant(), | |
|
Jarin
2017/05/24 06:41:22
node0 --> js_graph->EmptyStateValues()
danno
2017/06/06 12:04:52
Done.
| |
| 122 js_graph->UndefinedConstant(), outer_frame_state); | |
| 123 | |
| 124 return frame_state; | |
| 125 } | |
| 126 | |
| 127 } // namespace | |
| 128 | |
| 129 Node* CreateStubBuiltinContinuationFrameState(JSGraph* js_graph, | |
| 130 Builtins::Name name, | |
| 131 Node* context, Node** parameters, | |
| 132 int parameter_count, | |
| 133 Node* outer_frame_state, | |
| 134 ContinuationFrameStateMode mode) { | |
| 135 Isolate* isolate = js_graph->isolate(); | |
| 136 Callable callable = Builtins::CallableFor(isolate, name); | |
| 137 CallInterfaceDescriptor descriptor = callable.descriptor(); | |
| 138 | |
| 139 std::vector<Node*> actual_parameters; | |
| 140 if (descriptor.GetRegisterParameterCount() == 0) { | |
| 141 actual_parameters.push_back(context); | |
| 142 } | |
| 143 for (int i = 0; i < parameter_count; ++i) { | |
| 144 actual_parameters.push_back(parameters[i]); | |
| 145 if (i == descriptor.GetRegisterParameterCount() - 1) { | |
| 146 actual_parameters.push_back(context); | |
| 147 } | |
| 148 } | |
| 149 | |
| 150 return CreateBuiltinContinuationFrameStateCommon( | |
| 151 js_graph, name, &actual_parameters[0], | |
| 152 static_cast<int>(actual_parameters.size()), outer_frame_state, | |
| 153 Handle<SharedFunctionInfo>()); | |
| 154 } | |
| 155 | |
| 156 Node* CreateJavaScriptBuiltinContinuationFrameState( | |
| 157 JSGraph* js_graph, Handle<SharedFunctionInfo> shared, Builtins::Name name, | |
| 158 Node* target, Node* context, Node** stack_parameters, | |
| 159 int stack_parameter_count, Node* outer_frame_state, | |
| 160 ContinuationFrameStateMode mode) { | |
| 161 Isolate* isolate = js_graph->isolate(); | |
| 162 Callable callable = Builtins::CallableFor(isolate, name); | |
| 163 | |
| 164 // Lazy deopt points where the frame state is assocated with a call get an | |
| 165 // additional parameter for the return result from the call that's added by | |
| 166 // the deoptimizer and not explicitly specified in the frame state. Check that | |
| 167 // there is not a mismatch between the number of frame state parameters and | |
| 168 // the stack parameters required by the builtin taking this into account. | |
| 169 DCHECK_EQ( | |
| 170 Builtins::GetStackParameterCount(isolate, name) + 1, // add receiver | |
| 171 stack_parameter_count + | |
| 172 (mode == ContinuationFrameStateMode::EAGER ? 0 : 1)); | |
| 173 | |
| 174 Node* argc = | |
| 175 js_graph->Constant(stack_parameter_count - | |
| 176 (mode == ContinuationFrameStateMode::EAGER ? 1 : 0)); | |
| 177 std::vector<Node*> actual_parameters( | |
| 178 {target, js_graph->UndefinedConstant(), argc, context}); | |
| 179 | |
| 180 for (int i = 0; i < stack_parameter_count; ++i) { | |
| 181 actual_parameters.push_back(stack_parameters[i]); | |
| 182 } | |
| 183 | |
| 184 return CreateBuiltinContinuationFrameStateCommon( | |
| 185 js_graph, name, &actual_parameters[0], | |
| 186 static_cast<int>(actual_parameters.size()), outer_frame_state, shared); | |
| 187 } | |
| 188 | |
| 89 } // namespace compiler | 189 } // namespace compiler |
| 90 } // namespace internal | 190 } // namespace internal |
| 91 } // namespace v8 | 191 } // namespace v8 |
| OLD | NEW |