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/compiler/simplified-operator.h" | 9 #include "src/compiler/simplified-operator.h" |
10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
379 NodeProperties::ChangeOp( | 379 NodeProperties::ChangeOp( |
380 node, javascript()->CallRuntime(Runtime::kThrowCalledNonCallable)); | 380 node, javascript()->CallRuntime(Runtime::kThrowCalledNonCallable)); |
381 return Changed(node); | 381 return Changed(node); |
382 } | 382 } |
383 | 383 |
384 // Check for the ArrayConstructor. | 384 // Check for the ArrayConstructor. |
385 if (*function == function->native_context()->array_function()) { | 385 if (*function == function->native_context()->array_function()) { |
386 // Check if we have an allocation site. | 386 // Check if we have an allocation site. |
387 Handle<AllocationSite> site; | 387 Handle<AllocationSite> site; |
388 if (p.feedback().IsValid()) { | 388 if (p.feedback().IsValid()) { |
389 Handle<Object> feedback( | 389 CallICNexus nexus(p.feedback().vector(), p.feedback().slot()); |
Benedikt Meurer
2016/09/13 17:11:48
Nice!
| |
390 p.feedback().vector()->Get(p.feedback().slot()), isolate()); | 390 Handle<Object> feedback(nexus.GetFeedback(), isolate()); |
391 if (feedback->IsAllocationSite()) { | 391 if (feedback->IsAllocationSite()) { |
392 site = Handle<AllocationSite>::cast(feedback); | 392 site = Handle<AllocationSite>::cast(feedback); |
393 } | 393 } |
394 } | 394 } |
395 | 395 |
396 // Turn the {node} into a {JSCreateArray} call. | 396 // Turn the {node} into a {JSCreateArray} call. |
397 for (int i = arity; i > 0; --i) { | 397 for (int i = arity; i > 0; --i) { |
398 NodeProperties::ReplaceValueInput( | 398 NodeProperties::ReplaceValueInput( |
399 node, NodeProperties::GetValueInput(node, i), i + 1); | 399 node, NodeProperties::GetValueInput(node, i), i + 1); |
400 } | 400 } |
401 NodeProperties::ReplaceValueInput(node, new_target, 1); | 401 NodeProperties::ReplaceValueInput(node, new_target, 1); |
402 NodeProperties::ChangeOp(node, javascript()->CreateArray(arity, site)); | 402 NodeProperties::ChangeOp(node, javascript()->CreateArray(arity, site)); |
403 return Changed(node); | 403 return Changed(node); |
404 } | 404 } |
405 } | 405 } |
406 | 406 |
407 // Don't mess with other {node}s that have a constant {target}. | 407 // Don't mess with other {node}s that have a constant {target}. |
408 // TODO(bmeurer): Also support optimizing bound functions and proxies here. | 408 // TODO(bmeurer): Also support optimizing bound functions and proxies here. |
409 return NoChange(); | 409 return NoChange(); |
410 } | 410 } |
411 | 411 |
412 // Not much we can do if deoptimization support is disabled. | 412 // Not much we can do if deoptimization support is disabled. |
413 if (!(flags() & kDeoptimizationEnabled)) return NoChange(); | 413 if (!(flags() & kDeoptimizationEnabled)) return NoChange(); |
414 | 414 |
415 // TODO(mvstanton): Use ConstructICNexus here, once available. | |
416 Handle<Object> feedback; | |
417 if (!p.feedback().IsValid()) return NoChange(); | 415 if (!p.feedback().IsValid()) return NoChange(); |
418 feedback = handle(p.feedback().vector()->Get(p.feedback().slot()), isolate()); | 416 CallICNexus nexus(p.feedback().vector(), p.feedback().slot()); |
Benedikt Meurer
2016/09/13 17:11:48
Nice!
| |
417 Handle<Object> feedback(nexus.GetFeedback(), isolate()); | |
419 if (feedback->IsAllocationSite()) { | 418 if (feedback->IsAllocationSite()) { |
420 // The feedback is an AllocationSite, which means we have called the | 419 // The feedback is an AllocationSite, which means we have called the |
421 // Array function and collected transition (and pretenuring) feedback | 420 // Array function and collected transition (and pretenuring) feedback |
422 // for the resulting arrays. This has to be kept in sync with the | 421 // for the resulting arrays. This has to be kept in sync with the |
423 // implementation of the CallConstructStub. | 422 // implementation of the CallConstructStub. |
424 Handle<AllocationSite> site = Handle<AllocationSite>::cast(feedback); | 423 Handle<AllocationSite> site = Handle<AllocationSite>::cast(feedback); |
425 | 424 |
426 // Retrieve the Array function from the {node}. | 425 // Retrieve the Array function from the {node}. |
427 Node* array_function; | 426 Node* array_function; |
428 Handle<Context> native_context; | 427 Handle<Context> native_context; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
503 return jsgraph()->javascript(); | 502 return jsgraph()->javascript(); |
504 } | 503 } |
505 | 504 |
506 SimplifiedOperatorBuilder* JSCallReducer::simplified() const { | 505 SimplifiedOperatorBuilder* JSCallReducer::simplified() const { |
507 return jsgraph()->simplified(); | 506 return jsgraph()->simplified(); |
508 } | 507 } |
509 | 508 |
510 } // namespace compiler | 509 } // namespace compiler |
511 } // namespace internal | 510 } // namespace internal |
512 } // namespace v8 | 511 } // namespace v8 |
OLD | NEW |