OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/raw-machine-assembler.h" | 5 #include "src/compiler/raw-machine-assembler.h" |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/compiler/node-properties.h" | 8 #include "src/compiler/node-properties.h" |
9 #include "src/compiler/pipeline.h" | 9 #include "src/compiler/pipeline.h" |
10 #include "src/compiler/scheduler.h" | 10 #include "src/compiler/scheduler.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } | 147 } |
148 buffer[index++] = frame_state; | 148 buffer[index++] = frame_state; |
149 return AddNode(common()->Call(desc), input_count, buffer); | 149 return AddNode(common()->Call(desc), input_count, buffer); |
150 } | 150 } |
151 | 151 |
152 | 152 |
153 Node* RawMachineAssembler::CallRuntime1(Runtime::FunctionId function, | 153 Node* RawMachineAssembler::CallRuntime1(Runtime::FunctionId function, |
154 Node* arg1, Node* context) { | 154 Node* arg1, Node* context) { |
155 CallDescriptor* descriptor = Linkage::GetRuntimeCallDescriptor( | 155 CallDescriptor* descriptor = Linkage::GetRuntimeCallDescriptor( |
156 zone(), function, 1, Operator::kNoProperties, CallDescriptor::kNoFlags); | 156 zone(), function, 1, Operator::kNoProperties, CallDescriptor::kNoFlags); |
| 157 int return_count = static_cast<int>(descriptor->ReturnCount()); |
157 | 158 |
158 Node* centry = HeapConstant(CEntryStub(isolate(), 1).GetCode()); | 159 Node* centry = HeapConstant(CEntryStub(isolate(), return_count).GetCode()); |
159 Node* ref = AddNode( | 160 Node* ref = AddNode( |
160 common()->ExternalConstant(ExternalReference(function, isolate()))); | 161 common()->ExternalConstant(ExternalReference(function, isolate()))); |
161 Node* arity = Int32Constant(1); | 162 Node* arity = Int32Constant(1); |
162 | 163 |
163 return AddNode(common()->Call(descriptor), centry, arg1, ref, arity, context); | 164 return AddNode(common()->Call(descriptor), centry, arg1, ref, arity, context); |
164 } | 165 } |
165 | 166 |
166 | 167 |
167 Node* RawMachineAssembler::CallRuntime2(Runtime::FunctionId function, | 168 Node* RawMachineAssembler::CallRuntime2(Runtime::FunctionId function, |
168 Node* arg1, Node* arg2, Node* context) { | 169 Node* arg1, Node* arg2, Node* context) { |
169 CallDescriptor* descriptor = Linkage::GetRuntimeCallDescriptor( | 170 CallDescriptor* descriptor = Linkage::GetRuntimeCallDescriptor( |
170 zone(), function, 2, Operator::kNoProperties, CallDescriptor::kNoFlags); | 171 zone(), function, 2, Operator::kNoProperties, CallDescriptor::kNoFlags); |
| 172 int return_count = static_cast<int>(descriptor->ReturnCount()); |
171 | 173 |
172 Node* centry = HeapConstant(CEntryStub(isolate(), 1).GetCode()); | 174 Node* centry = HeapConstant(CEntryStub(isolate(), return_count).GetCode()); |
173 Node* ref = AddNode( | 175 Node* ref = AddNode( |
174 common()->ExternalConstant(ExternalReference(function, isolate()))); | 176 common()->ExternalConstant(ExternalReference(function, isolate()))); |
175 Node* arity = Int32Constant(2); | 177 Node* arity = Int32Constant(2); |
176 | 178 |
177 return AddNode(common()->Call(descriptor), centry, arg1, arg2, ref, arity, | 179 return AddNode(common()->Call(descriptor), centry, arg1, arg2, ref, arity, |
178 context); | 180 context); |
179 } | 181 } |
180 | 182 |
181 | 183 |
182 Node* RawMachineAssembler::CallRuntime4(Runtime::FunctionId function, | 184 Node* RawMachineAssembler::CallRuntime4(Runtime::FunctionId function, |
183 Node* arg1, Node* arg2, Node* arg3, | 185 Node* arg1, Node* arg2, Node* arg3, |
184 Node* arg4, Node* context) { | 186 Node* arg4, Node* context) { |
185 CallDescriptor* descriptor = Linkage::GetRuntimeCallDescriptor( | 187 CallDescriptor* descriptor = Linkage::GetRuntimeCallDescriptor( |
186 zone(), function, 4, Operator::kNoProperties, CallDescriptor::kNoFlags); | 188 zone(), function, 4, Operator::kNoProperties, CallDescriptor::kNoFlags); |
| 189 int return_count = static_cast<int>(descriptor->ReturnCount()); |
187 | 190 |
188 Node* centry = HeapConstant(CEntryStub(isolate(), 1).GetCode()); | 191 Node* centry = HeapConstant(CEntryStub(isolate(), return_count).GetCode()); |
189 Node* ref = AddNode( | 192 Node* ref = AddNode( |
190 common()->ExternalConstant(ExternalReference(function, isolate()))); | 193 common()->ExternalConstant(ExternalReference(function, isolate()))); |
191 Node* arity = Int32Constant(4); | 194 Node* arity = Int32Constant(4); |
192 | 195 |
193 return AddNode(common()->Call(descriptor), centry, arg1, arg2, arg3, arg4, | 196 return AddNode(common()->Call(descriptor), centry, arg1, arg2, arg3, arg4, |
194 ref, arity, context); | 197 ref, arity, context); |
195 } | 198 } |
196 | 199 |
197 | 200 |
198 Node* RawMachineAssembler::TailCallN(CallDescriptor* desc, Node* function, | 201 Node* RawMachineAssembler::TailCallN(CallDescriptor* desc, Node* function, |
(...skipping 14 matching lines...) Expand all Loading... |
213 return tail_call; | 216 return tail_call; |
214 } | 217 } |
215 | 218 |
216 | 219 |
217 Node* RawMachineAssembler::TailCallRuntime1(Runtime::FunctionId function, | 220 Node* RawMachineAssembler::TailCallRuntime1(Runtime::FunctionId function, |
218 Node* arg1, Node* context) { | 221 Node* arg1, Node* context) { |
219 const int kArity = 1; | 222 const int kArity = 1; |
220 CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor( | 223 CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor( |
221 zone(), function, kArity, Operator::kNoProperties, | 224 zone(), function, kArity, Operator::kNoProperties, |
222 CallDescriptor::kSupportsTailCalls); | 225 CallDescriptor::kSupportsTailCalls); |
| 226 int return_count = static_cast<int>(desc->ReturnCount()); |
223 | 227 |
224 Node* centry = HeapConstant(CEntryStub(isolate(), 1).GetCode()); | 228 Node* centry = HeapConstant(CEntryStub(isolate(), return_count).GetCode()); |
225 Node* ref = AddNode( | 229 Node* ref = AddNode( |
226 common()->ExternalConstant(ExternalReference(function, isolate()))); | 230 common()->ExternalConstant(ExternalReference(function, isolate()))); |
227 Node* arity = Int32Constant(kArity); | 231 Node* arity = Int32Constant(kArity); |
228 | 232 |
229 Node* nodes[] = {centry, arg1, ref, arity, context}; | 233 Node* nodes[] = {centry, arg1, ref, arity, context}; |
230 Node* tail_call = MakeNode(common()->TailCall(desc), arraysize(nodes), nodes); | 234 Node* tail_call = MakeNode(common()->TailCall(desc), arraysize(nodes), nodes); |
231 | 235 |
232 NodeProperties::MergeControlToEnd(graph(), common(), tail_call); | 236 NodeProperties::MergeControlToEnd(graph(), common(), tail_call); |
233 schedule()->AddTailCall(CurrentBlock(), tail_call); | 237 schedule()->AddTailCall(CurrentBlock(), tail_call); |
234 current_block_ = nullptr; | 238 current_block_ = nullptr; |
235 return tail_call; | 239 return tail_call; |
236 } | 240 } |
237 | 241 |
238 | 242 |
239 Node* RawMachineAssembler::TailCallRuntime2(Runtime::FunctionId function, | 243 Node* RawMachineAssembler::TailCallRuntime2(Runtime::FunctionId function, |
240 Node* arg1, Node* arg2, | 244 Node* arg1, Node* arg2, |
241 Node* context) { | 245 Node* context) { |
242 const int kArity = 2; | 246 const int kArity = 2; |
243 CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor( | 247 CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor( |
244 zone(), function, kArity, Operator::kNoProperties, | 248 zone(), function, kArity, Operator::kNoProperties, |
245 CallDescriptor::kSupportsTailCalls); | 249 CallDescriptor::kSupportsTailCalls); |
| 250 int return_count = static_cast<int>(desc->ReturnCount()); |
246 | 251 |
247 Node* centry = HeapConstant(CEntryStub(isolate(), 1).GetCode()); | 252 Node* centry = HeapConstant(CEntryStub(isolate(), return_count).GetCode()); |
248 Node* ref = AddNode( | 253 Node* ref = AddNode( |
249 common()->ExternalConstant(ExternalReference(function, isolate()))); | 254 common()->ExternalConstant(ExternalReference(function, isolate()))); |
250 Node* arity = Int32Constant(kArity); | 255 Node* arity = Int32Constant(kArity); |
251 | 256 |
252 Node* nodes[] = {centry, arg1, arg2, ref, arity, context}; | 257 Node* nodes[] = {centry, arg1, arg2, ref, arity, context}; |
253 Node* tail_call = MakeNode(common()->TailCall(desc), arraysize(nodes), nodes); | 258 Node* tail_call = MakeNode(common()->TailCall(desc), arraysize(nodes), nodes); |
254 | 259 |
255 NodeProperties::MergeControlToEnd(graph(), common(), tail_call); | 260 NodeProperties::MergeControlToEnd(graph(), common(), tail_call); |
256 schedule()->AddTailCall(CurrentBlock(), tail_call); | 261 schedule()->AddTailCall(CurrentBlock(), tail_call); |
257 current_block_ = nullptr; | 262 current_block_ = nullptr; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 | 372 |
368 RawMachineLabel::RawMachineLabel() | 373 RawMachineLabel::RawMachineLabel() |
369 : block_(NULL), used_(false), bound_(false) {} | 374 : block_(NULL), used_(false), bound_(false) {} |
370 | 375 |
371 | 376 |
372 RawMachineLabel::~RawMachineLabel() { DCHECK(bound_ || !used_); } | 377 RawMachineLabel::~RawMachineLabel() { DCHECK(bound_ || !used_); } |
373 | 378 |
374 } // namespace compiler | 379 } // namespace compiler |
375 } // namespace internal | 380 } // namespace internal |
376 } // namespace v8 | 381 } // namespace v8 |
OLD | NEW |