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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 } else { | 319 } else { |
320 Node* native_context = effect = graph()->NewNode( | 320 Node* native_context = effect = graph()->NewNode( |
321 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | 321 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), |
322 context, context, effect); | 322 context, context, effect); |
323 array_function = effect = graph()->NewNode( | 323 array_function = effect = graph()->NewNode( |
324 javascript()->LoadContext(0, Context::ARRAY_FUNCTION_INDEX, true), | 324 javascript()->LoadContext(0, Context::ARRAY_FUNCTION_INDEX, true), |
325 native_context, native_context, effect); | 325 native_context, native_context, effect); |
326 } | 326 } |
327 | 327 |
328 // Check that the {target} is still the {array_function}. | 328 // Check that the {target} is still the {array_function}. |
329 Node* check = effect = | 329 Node* check = graph()->NewNode(javascript()->StrictEqual(), target, |
330 graph()->NewNode(javascript()->StrictEqual(), target, array_function, | 330 array_function, context); |
331 context, effect, control); | |
332 control = graph()->NewNode(common()->DeoptimizeUnless(), check, frame_state, | 331 control = graph()->NewNode(common()->DeoptimizeUnless(), check, frame_state, |
333 effect, control); | 332 effect, control); |
334 | 333 |
335 // Turn the {node} into a {JSCreateArray} call. | 334 // Turn the {node} into a {JSCreateArray} call. |
336 NodeProperties::ReplaceValueInput(node, array_function, 0); | 335 NodeProperties::ReplaceValueInput(node, array_function, 0); |
337 NodeProperties::ReplaceEffectInput(node, effect); | 336 NodeProperties::ReplaceEffectInput(node, effect); |
338 NodeProperties::ReplaceControlInput(node, control); | 337 NodeProperties::ReplaceControlInput(node, control); |
339 return ReduceArrayConstructor(node); | 338 return ReduceArrayConstructor(node); |
340 } else if (feedback->IsWeakCell()) { | 339 } else if (feedback->IsWeakCell()) { |
341 Handle<WeakCell> cell = Handle<WeakCell>::cast(feedback); | 340 Handle<WeakCell> cell = Handle<WeakCell>::cast(feedback); |
342 if (cell->value()->IsJSFunction()) { | 341 if (cell->value()->IsJSFunction()) { |
343 Node* target_function = | 342 Node* target_function = |
344 jsgraph()->Constant(handle(cell->value(), isolate())); | 343 jsgraph()->Constant(handle(cell->value(), isolate())); |
345 | 344 |
346 // Check that the {target} is still the {target_function}. | 345 // Check that the {target} is still the {target_function}. |
347 Node* check = effect = | 346 Node* check = graph()->NewNode(javascript()->StrictEqual(), target, |
348 graph()->NewNode(javascript()->StrictEqual(), target, target_function, | 347 target_function, context); |
349 context, effect, control); | |
350 control = graph()->NewNode(common()->DeoptimizeUnless(), check, | 348 control = graph()->NewNode(common()->DeoptimizeUnless(), check, |
351 frame_state, effect, control); | 349 frame_state, effect, control); |
352 | 350 |
353 // Specialize the JSCallFunction node to the {target_function}. | 351 // Specialize the JSCallFunction node to the {target_function}. |
354 NodeProperties::ReplaceValueInput(node, target_function, 0); | 352 NodeProperties::ReplaceValueInput(node, target_function, 0); |
355 NodeProperties::ReplaceEffectInput(node, effect); | |
356 NodeProperties::ReplaceControlInput(node, control); | 353 NodeProperties::ReplaceControlInput(node, control); |
357 | 354 |
358 // Try to further reduce the JSCallFunction {node}. | 355 // Try to further reduce the JSCallFunction {node}. |
359 Reduction const reduction = ReduceJSCallFunction(node); | 356 Reduction const reduction = ReduceJSCallFunction(node); |
360 return reduction.Changed() ? reduction : Changed(node); | 357 return reduction.Changed() ? reduction : Changed(node); |
361 } | 358 } |
362 } | 359 } |
363 return NoChange(); | 360 return NoChange(); |
364 } | 361 } |
365 | 362 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 } else { | 444 } else { |
448 Node* native_context = effect = graph()->NewNode( | 445 Node* native_context = effect = graph()->NewNode( |
449 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | 446 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), |
450 context, context, effect); | 447 context, context, effect); |
451 array_function = effect = graph()->NewNode( | 448 array_function = effect = graph()->NewNode( |
452 javascript()->LoadContext(0, Context::ARRAY_FUNCTION_INDEX, true), | 449 javascript()->LoadContext(0, Context::ARRAY_FUNCTION_INDEX, true), |
453 native_context, native_context, effect); | 450 native_context, native_context, effect); |
454 } | 451 } |
455 | 452 |
456 // Check that the {target} is still the {array_function}. | 453 // Check that the {target} is still the {array_function}. |
457 Node* check = effect = | 454 Node* check = graph()->NewNode(javascript()->StrictEqual(), target, |
458 graph()->NewNode(javascript()->StrictEqual(), target, array_function, | 455 array_function, context); |
459 context, effect, control); | |
460 control = graph()->NewNode(common()->DeoptimizeUnless(), check, frame_state, | 456 control = graph()->NewNode(common()->DeoptimizeUnless(), check, frame_state, |
461 effect, control); | 457 effect, control); |
462 | 458 |
463 // Turn the {node} into a {JSCreateArray} call. | 459 // Turn the {node} into a {JSCreateArray} call. |
464 NodeProperties::ReplaceEffectInput(node, effect); | 460 NodeProperties::ReplaceEffectInput(node, effect); |
465 NodeProperties::ReplaceControlInput(node, control); | 461 NodeProperties::ReplaceControlInput(node, control); |
466 NodeProperties::RemoveFrameStateInput(node, 1); | 462 NodeProperties::RemoveFrameStateInput(node, 1); |
467 for (int i = arity; i > 0; --i) { | 463 for (int i = arity; i > 0; --i) { |
468 NodeProperties::ReplaceValueInput( | 464 NodeProperties::ReplaceValueInput( |
469 node, NodeProperties::GetValueInput(node, i), i + 1); | 465 node, NodeProperties::GetValueInput(node, i), i + 1); |
470 } | 466 } |
471 NodeProperties::ReplaceValueInput(node, new_target, 1); | 467 NodeProperties::ReplaceValueInput(node, new_target, 1); |
472 NodeProperties::ChangeOp(node, javascript()->CreateArray(arity, site)); | 468 NodeProperties::ChangeOp(node, javascript()->CreateArray(arity, site)); |
473 return Changed(node); | 469 return Changed(node); |
474 } else if (feedback->IsWeakCell()) { | 470 } else if (feedback->IsWeakCell()) { |
475 Handle<WeakCell> cell = Handle<WeakCell>::cast(feedback); | 471 Handle<WeakCell> cell = Handle<WeakCell>::cast(feedback); |
476 if (cell->value()->IsJSFunction()) { | 472 if (cell->value()->IsJSFunction()) { |
477 Node* target_function = | 473 Node* target_function = |
478 jsgraph()->Constant(handle(cell->value(), isolate())); | 474 jsgraph()->Constant(handle(cell->value(), isolate())); |
479 | 475 |
480 // Check that the {target} is still the {target_function}. | 476 // Check that the {target} is still the {target_function}. |
481 Node* check = effect = | 477 Node* check = graph()->NewNode(javascript()->StrictEqual(), target, |
482 graph()->NewNode(javascript()->StrictEqual(), target, target_function, | 478 target_function, context); |
483 context, effect, control); | |
484 control = graph()->NewNode(common()->DeoptimizeUnless(), check, | 479 control = graph()->NewNode(common()->DeoptimizeUnless(), check, |
485 frame_state, effect, control); | 480 frame_state, effect, control); |
486 | 481 |
487 // Specialize the JSCallConstruct node to the {target_function}. | 482 // Specialize the JSCallConstruct node to the {target_function}. |
488 NodeProperties::ReplaceValueInput(node, target_function, 0); | 483 NodeProperties::ReplaceValueInput(node, target_function, 0); |
489 NodeProperties::ReplaceEffectInput(node, effect); | 484 NodeProperties::ReplaceEffectInput(node, effect); |
490 NodeProperties::ReplaceControlInput(node, control); | 485 NodeProperties::ReplaceControlInput(node, control); |
491 if (target == new_target) { | 486 if (target == new_target) { |
492 NodeProperties::ReplaceValueInput(node, target_function, arity + 1); | 487 NodeProperties::ReplaceValueInput(node, target_function, arity + 1); |
493 } | 488 } |
(...skipping 26 matching lines...) Expand all Loading... |
520 } | 515 } |
521 | 516 |
522 | 517 |
523 JSOperatorBuilder* JSCallReducer::javascript() const { | 518 JSOperatorBuilder* JSCallReducer::javascript() const { |
524 return jsgraph()->javascript(); | 519 return jsgraph()->javascript(); |
525 } | 520 } |
526 | 521 |
527 } // namespace compiler | 522 } // namespace compiler |
528 } // namespace internal | 523 } // namespace internal |
529 } // namespace v8 | 524 } // namespace v8 |
OLD | NEW |