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/js-call-reducer.h" | 5 #include "src/compiler/js-call-reducer.h" |
6 | 6 |
7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
9 #include "src/objects-inl.h" | 9 #include "src/objects-inl.h" |
10 #include "src/type-feedback-vector-inl.h" | 10 #include "src/type-feedback-vector-inl.h" |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 253 |
254 // Check for the Array constructor. | 254 // Check for the Array constructor. |
255 if (*function == function->native_context()->array_function()) { | 255 if (*function == function->native_context()->array_function()) { |
256 return ReduceArrayConstructor(node); | 256 return ReduceArrayConstructor(node); |
257 } | 257 } |
258 | 258 |
259 // Check for the Number constructor. | 259 // Check for the Number constructor. |
260 if (*function == function->native_context()->number_function()) { | 260 if (*function == function->native_context()->number_function()) { |
261 return ReduceNumberConstructor(node); | 261 return ReduceNumberConstructor(node); |
262 } | 262 } |
| 263 } else if (m.Value()->IsJSBoundFunction()) { |
| 264 Handle<JSBoundFunction> function = |
| 265 Handle<JSBoundFunction>::cast(m.Value()); |
| 266 Handle<JSReceiver> bound_target_function( |
| 267 function->bound_target_function(), isolate()); |
| 268 Handle<Object> bound_this(function->bound_this(), isolate()); |
| 269 Handle<FixedArray> bound_arguments(function->bound_arguments(), |
| 270 isolate()); |
| 271 CallFunctionParameters const& p = CallFunctionParametersOf(node->op()); |
| 272 ConvertReceiverMode const convert_mode = |
| 273 (bound_this->IsNull() || bound_this->IsUndefined()) |
| 274 ? ConvertReceiverMode::kNullOrUndefined |
| 275 : ConvertReceiverMode::kNotNullOrUndefined; |
| 276 size_t arity = p.arity(); |
| 277 DCHECK_LE(2u, arity); |
| 278 // Patch {node} to use [[BoundTargetFunction]] and [[BoundThis]]. |
| 279 NodeProperties::ReplaceValueInput( |
| 280 node, jsgraph()->Constant(bound_target_function), 0); |
| 281 NodeProperties::ReplaceValueInput(node, jsgraph()->Constant(bound_this), |
| 282 1); |
| 283 // Insert the [[BoundArguments]] for {node}. |
| 284 for (int i = 0; i < bound_arguments->length(); ++i) { |
| 285 node->InsertInput( |
| 286 graph()->zone(), i + 2, |
| 287 jsgraph()->Constant(handle(bound_arguments->get(i), isolate()))); |
| 288 arity++; |
| 289 } |
| 290 NodeProperties::ChangeOp( |
| 291 node, javascript()->CallFunction(arity, p.language_mode(), |
| 292 CallCountFeedback(p.feedback()), |
| 293 convert_mode, p.tail_call_mode())); |
| 294 // Try to further reduce the JSCallFunction {node}. |
| 295 Reduction const reduction = ReduceJSCallFunction(node); |
| 296 return reduction.Changed() ? reduction : Changed(node); |
263 } | 297 } |
264 | 298 |
265 // Don't mess with other {node}s that have a constant {target}. | 299 // Don't mess with other {node}s that have a constant {target}. |
266 // TODO(bmeurer): Also support optimizing bound functions and proxies here. | 300 // TODO(bmeurer): Also support proxies here. |
267 return NoChange(); | 301 return NoChange(); |
268 } | 302 } |
269 | 303 |
270 // Not much we can do if deoptimization support is disabled. | 304 // Not much we can do if deoptimization support is disabled. |
271 if (!(flags() & kDeoptimizationEnabled)) return NoChange(); | 305 if (!(flags() & kDeoptimizationEnabled)) return NoChange(); |
272 | 306 |
273 // Extract feedback from the {node} using the CallICNexus. | 307 // Extract feedback from the {node} using the CallICNexus. |
274 if (!p.feedback().IsValid()) return NoChange(); | 308 if (!p.feedback().IsValid()) return NoChange(); |
275 CallICNexus nexus(p.feedback().vector(), p.feedback().slot()); | 309 CallICNexus nexus(p.feedback().vector(), p.feedback().slot()); |
276 Handle<Object> feedback(nexus.GetFeedback(), isolate()); | 310 Handle<Object> feedback(nexus.GetFeedback(), isolate()); |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 } | 548 } |
515 | 549 |
516 | 550 |
517 JSOperatorBuilder* JSCallReducer::javascript() const { | 551 JSOperatorBuilder* JSCallReducer::javascript() const { |
518 return jsgraph()->javascript(); | 552 return jsgraph()->javascript(); |
519 } | 553 } |
520 | 554 |
521 } // namespace compiler | 555 } // namespace compiler |
522 } // namespace internal | 556 } // namespace internal |
523 } // namespace v8 | 557 } // namespace v8 |
OLD | NEW |