| 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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 } else { | 316 } else { |
| 317 Node* native_context = effect = graph()->NewNode( | 317 Node* native_context = effect = graph()->NewNode( |
| 318 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | 318 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), |
| 319 context, context, effect); | 319 context, context, effect); |
| 320 array_function = effect = graph()->NewNode( | 320 array_function = effect = graph()->NewNode( |
| 321 javascript()->LoadContext(0, Context::ARRAY_FUNCTION_INDEX, true), | 321 javascript()->LoadContext(0, Context::ARRAY_FUNCTION_INDEX, true), |
| 322 native_context, native_context, effect); | 322 native_context, native_context, effect); |
| 323 } | 323 } |
| 324 | 324 |
| 325 // Check that the {target} is still the {array_function}. | 325 // Check that the {target} is still the {array_function}. |
| 326 Node* check = graph()->NewNode(simplified()->ReferenceEqual(Type::Any()), | 326 Node* check = graph()->NewNode(simplified()->ReferenceEqual(), target, |
| 327 target, array_function); | 327 array_function); |
| 328 effect = graph()->NewNode(simplified()->CheckIf(), check, effect, control); | 328 effect = graph()->NewNode(simplified()->CheckIf(), check, effect, control); |
| 329 | 329 |
| 330 // Turn the {node} into a {JSCreateArray} call. | 330 // Turn the {node} into a {JSCreateArray} call. |
| 331 NodeProperties::ReplaceValueInput(node, array_function, 0); | 331 NodeProperties::ReplaceValueInput(node, array_function, 0); |
| 332 NodeProperties::ReplaceEffectInput(node, effect); | 332 NodeProperties::ReplaceEffectInput(node, effect); |
| 333 return ReduceArrayConstructor(node); | 333 return ReduceArrayConstructor(node); |
| 334 } else if (feedback->IsWeakCell()) { | 334 } else if (feedback->IsWeakCell()) { |
| 335 Handle<WeakCell> cell = Handle<WeakCell>::cast(feedback); | 335 Handle<WeakCell> cell = Handle<WeakCell>::cast(feedback); |
| 336 if (cell->value()->IsJSFunction()) { | 336 if (cell->value()->IsJSFunction()) { |
| 337 Node* target_function = | 337 Node* target_function = |
| 338 jsgraph()->Constant(handle(cell->value(), isolate())); | 338 jsgraph()->Constant(handle(cell->value(), isolate())); |
| 339 | 339 |
| 340 // Check that the {target} is still the {target_function}. | 340 // Check that the {target} is still the {target_function}. |
| 341 Node* check = graph()->NewNode(simplified()->ReferenceEqual(Type::Any()), | 341 Node* check = graph()->NewNode(simplified()->ReferenceEqual(), target, |
| 342 target, target_function); | 342 target_function); |
| 343 effect = | 343 effect = |
| 344 graph()->NewNode(simplified()->CheckIf(), check, effect, control); | 344 graph()->NewNode(simplified()->CheckIf(), check, effect, control); |
| 345 | 345 |
| 346 // Specialize the JSCallFunction node to the {target_function}. | 346 // Specialize the JSCallFunction node to the {target_function}. |
| 347 NodeProperties::ReplaceValueInput(node, target_function, 0); | 347 NodeProperties::ReplaceValueInput(node, target_function, 0); |
| 348 NodeProperties::ReplaceEffectInput(node, effect); | 348 NodeProperties::ReplaceEffectInput(node, effect); |
| 349 | 349 |
| 350 // Try to further reduce the JSCallFunction {node}. | 350 // Try to further reduce the JSCallFunction {node}. |
| 351 Reduction const reduction = ReduceJSCallFunction(node); | 351 Reduction const reduction = ReduceJSCallFunction(node); |
| 352 return reduction.Changed() ? reduction : Changed(node); | 352 return reduction.Changed() ? reduction : Changed(node); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 } else { | 432 } else { |
| 433 Node* native_context = effect = graph()->NewNode( | 433 Node* native_context = effect = graph()->NewNode( |
| 434 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | 434 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), |
| 435 context, context, effect); | 435 context, context, effect); |
| 436 array_function = effect = graph()->NewNode( | 436 array_function = effect = graph()->NewNode( |
| 437 javascript()->LoadContext(0, Context::ARRAY_FUNCTION_INDEX, true), | 437 javascript()->LoadContext(0, Context::ARRAY_FUNCTION_INDEX, true), |
| 438 native_context, native_context, effect); | 438 native_context, native_context, effect); |
| 439 } | 439 } |
| 440 | 440 |
| 441 // Check that the {target} is still the {array_function}. | 441 // Check that the {target} is still the {array_function}. |
| 442 Node* check = graph()->NewNode(simplified()->ReferenceEqual(Type::Any()), | 442 Node* check = graph()->NewNode(simplified()->ReferenceEqual(), target, |
| 443 target, array_function); | 443 array_function); |
| 444 effect = graph()->NewNode(simplified()->CheckIf(), check, effect, control); | 444 effect = graph()->NewNode(simplified()->CheckIf(), check, effect, control); |
| 445 | 445 |
| 446 // Turn the {node} into a {JSCreateArray} call. | 446 // Turn the {node} into a {JSCreateArray} call. |
| 447 NodeProperties::ReplaceEffectInput(node, effect); | 447 NodeProperties::ReplaceEffectInput(node, effect); |
| 448 for (int i = arity; i > 0; --i) { | 448 for (int i = arity; i > 0; --i) { |
| 449 NodeProperties::ReplaceValueInput( | 449 NodeProperties::ReplaceValueInput( |
| 450 node, NodeProperties::GetValueInput(node, i), i + 1); | 450 node, NodeProperties::GetValueInput(node, i), i + 1); |
| 451 } | 451 } |
| 452 NodeProperties::ReplaceValueInput(node, new_target, 1); | 452 NodeProperties::ReplaceValueInput(node, new_target, 1); |
| 453 NodeProperties::ChangeOp(node, javascript()->CreateArray(arity, site)); | 453 NodeProperties::ChangeOp(node, javascript()->CreateArray(arity, site)); |
| 454 return Changed(node); | 454 return Changed(node); |
| 455 } else if (feedback->IsWeakCell()) { | 455 } else if (feedback->IsWeakCell()) { |
| 456 Handle<WeakCell> cell = Handle<WeakCell>::cast(feedback); | 456 Handle<WeakCell> cell = Handle<WeakCell>::cast(feedback); |
| 457 if (cell->value()->IsJSFunction()) { | 457 if (cell->value()->IsJSFunction()) { |
| 458 Node* target_function = | 458 Node* target_function = |
| 459 jsgraph()->Constant(handle(cell->value(), isolate())); | 459 jsgraph()->Constant(handle(cell->value(), isolate())); |
| 460 | 460 |
| 461 // Check that the {target} is still the {target_function}. | 461 // Check that the {target} is still the {target_function}. |
| 462 Node* check = graph()->NewNode(simplified()->ReferenceEqual(Type::Any()), | 462 Node* check = graph()->NewNode(simplified()->ReferenceEqual(), target, |
| 463 target, target_function); | 463 target_function); |
| 464 effect = | 464 effect = |
| 465 graph()->NewNode(simplified()->CheckIf(), check, effect, control); | 465 graph()->NewNode(simplified()->CheckIf(), check, effect, control); |
| 466 | 466 |
| 467 // Specialize the JSCallConstruct node to the {target_function}. | 467 // Specialize the JSCallConstruct node to the {target_function}. |
| 468 NodeProperties::ReplaceValueInput(node, target_function, 0); | 468 NodeProperties::ReplaceValueInput(node, target_function, 0); |
| 469 NodeProperties::ReplaceEffectInput(node, effect); | 469 NodeProperties::ReplaceEffectInput(node, effect); |
| 470 if (target == new_target) { | 470 if (target == new_target) { |
| 471 NodeProperties::ReplaceValueInput(node, target_function, arity + 1); | 471 NodeProperties::ReplaceValueInput(node, target_function, arity + 1); |
| 472 } | 472 } |
| 473 | 473 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 503 return jsgraph()->javascript(); | 503 return jsgraph()->javascript(); |
| 504 } | 504 } |
| 505 | 505 |
| 506 SimplifiedOperatorBuilder* JSCallReducer::simplified() const { | 506 SimplifiedOperatorBuilder* JSCallReducer::simplified() const { |
| 507 return jsgraph()->simplified(); | 507 return jsgraph()->simplified(); |
| 508 } | 508 } |
| 509 | 509 |
| 510 } // namespace compiler | 510 } // namespace compiler |
| 511 } // namespace internal | 511 } // namespace internal |
| 512 } // namespace v8 | 512 } // namespace v8 |
| OLD | NEW |