Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(417)

Side by Side Diff: src/compiler/js-typed-lowering.cc

Issue 2025573003: [turbofan] Remove eager frame state from call nodes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_turbofan-checkpoint-1
Patch Set: Rebased. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/js-inlining.cc ('k') | src/compiler/linkage.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/code-factory.h" 5 #include "src/code-factory.h"
6 #include "src/compilation-dependencies.h" 6 #include "src/compilation-dependencies.h"
7 #include "src/compiler/access-builder.h" 7 #include "src/compiler/access-builder.h"
8 #include "src/compiler/js-graph.h" 8 #include "src/compiler/js-graph.h"
9 #include "src/compiler/js-typed-lowering.h" 9 #include "src/compiler/js-typed-lowering.h"
10 #include "src/compiler/linkage.h" 10 #include "src/compiler/linkage.h"
(...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 Type* target_type = NodeProperties::GetType(target); 1381 Type* target_type = NodeProperties::GetType(target);
1382 Node* new_target = NodeProperties::GetValueInput(node, arity + 1); 1382 Node* new_target = NodeProperties::GetValueInput(node, arity + 1);
1383 1383
1384 // Check if {target} is a known JSFunction. 1384 // Check if {target} is a known JSFunction.
1385 if (target_type->IsConstant() && 1385 if (target_type->IsConstant() &&
1386 target_type->AsConstant()->Value()->IsJSFunction()) { 1386 target_type->AsConstant()->Value()->IsJSFunction()) {
1387 Handle<JSFunction> function = 1387 Handle<JSFunction> function =
1388 Handle<JSFunction>::cast(target_type->AsConstant()->Value()); 1388 Handle<JSFunction>::cast(target_type->AsConstant()->Value());
1389 Handle<SharedFunctionInfo> shared(function->shared(), isolate()); 1389 Handle<SharedFunctionInfo> shared(function->shared(), isolate());
1390 1390
1391 // Remove the eager bailout frame state.
1392 NodeProperties::RemoveFrameStateInput(node, 1);
1393
1394 // Patch {node} to an indirect call via the {function}s construct stub. 1391 // Patch {node} to an indirect call via the {function}s construct stub.
1395 Callable callable(handle(shared->construct_stub(), isolate()), 1392 Callable callable(handle(shared->construct_stub(), isolate()),
1396 ConstructStubDescriptor(isolate())); 1393 ConstructStubDescriptor(isolate()));
1397 node->RemoveInput(arity + 1); 1394 node->RemoveInput(arity + 1);
1398 node->InsertInput(graph()->zone(), 0, 1395 node->InsertInput(graph()->zone(), 0,
1399 jsgraph()->HeapConstant(callable.code())); 1396 jsgraph()->HeapConstant(callable.code()));
1400 node->InsertInput(graph()->zone(), 2, new_target); 1397 node->InsertInput(graph()->zone(), 2, new_target);
1401 node->InsertInput(graph()->zone(), 3, jsgraph()->Int32Constant(arity)); 1398 node->InsertInput(graph()->zone(), 3, jsgraph()->Int32Constant(arity));
1402 node->InsertInput(graph()->zone(), 4, jsgraph()->UndefinedConstant()); 1399 node->InsertInput(graph()->zone(), 4, jsgraph()->UndefinedConstant());
1403 node->InsertInput(graph()->zone(), 5, jsgraph()->UndefinedConstant()); 1400 node->InsertInput(graph()->zone(), 5, jsgraph()->UndefinedConstant());
1404 NodeProperties::ChangeOp( 1401 NodeProperties::ChangeOp(
1405 node, common()->Call(Linkage::GetStubCallDescriptor( 1402 node, common()->Call(Linkage::GetStubCallDescriptor(
1406 isolate(), graph()->zone(), callable.descriptor(), 1 + arity, 1403 isolate(), graph()->zone(), callable.descriptor(), 1 + arity,
1407 CallDescriptor::kNeedsFrameState))); 1404 CallDescriptor::kNeedsFrameState)));
1408 return Changed(node); 1405 return Changed(node);
1409 } 1406 }
1410 1407
1411 // Check if {target} is a JSFunction. 1408 // Check if {target} is a JSFunction.
1412 if (target_type->Is(Type::Function())) { 1409 if (target_type->Is(Type::Function())) {
1413 // Remove the eager bailout frame state.
1414 NodeProperties::RemoveFrameStateInput(node, 1);
1415
1416 // Patch {node} to an indirect call via the ConstructFunction builtin. 1410 // Patch {node} to an indirect call via the ConstructFunction builtin.
1417 Callable callable = CodeFactory::ConstructFunction(isolate()); 1411 Callable callable = CodeFactory::ConstructFunction(isolate());
1418 node->RemoveInput(arity + 1); 1412 node->RemoveInput(arity + 1);
1419 node->InsertInput(graph()->zone(), 0, 1413 node->InsertInput(graph()->zone(), 0,
1420 jsgraph()->HeapConstant(callable.code())); 1414 jsgraph()->HeapConstant(callable.code()));
1421 node->InsertInput(graph()->zone(), 2, new_target); 1415 node->InsertInput(graph()->zone(), 2, new_target);
1422 node->InsertInput(graph()->zone(), 3, jsgraph()->Int32Constant(arity)); 1416 node->InsertInput(graph()->zone(), 3, jsgraph()->Int32Constant(arity));
1423 node->InsertInput(graph()->zone(), 4, jsgraph()->UndefinedConstant()); 1417 node->InsertInput(graph()->zone(), 4, jsgraph()->UndefinedConstant());
1424 NodeProperties::ChangeOp( 1418 NodeProperties::ChangeOp(
1425 node, common()->Call(Linkage::GetStubCallDescriptor( 1419 node, common()->Call(Linkage::GetStubCallDescriptor(
1426 isolate(), graph()->zone(), callable.descriptor(), 1 + arity, 1420 isolate(), graph()->zone(), callable.descriptor(), 1 + arity,
1427 CallDescriptor::kNeedsFrameState))); 1421 CallDescriptor::kNeedsFrameState)));
1428 return Changed(node); 1422 return Changed(node);
1429 } 1423 }
1430 1424
1431 return NoChange(); 1425 return NoChange();
1432 } 1426 }
1433 1427
1434 1428
1435 Reduction JSTypedLowering::ReduceJSCallFunction(Node* node) { 1429 Reduction JSTypedLowering::ReduceJSCallFunction(Node* node) {
1436 DCHECK_EQ(IrOpcode::kJSCallFunction, node->opcode()); 1430 DCHECK_EQ(IrOpcode::kJSCallFunction, node->opcode());
1437 CallFunctionParameters const& p = CallFunctionParametersOf(node->op()); 1431 CallFunctionParameters const& p = CallFunctionParametersOf(node->op());
1438 int const arity = static_cast<int>(p.arity() - 2); 1432 int const arity = static_cast<int>(p.arity() - 2);
1439 ConvertReceiverMode convert_mode = p.convert_mode(); 1433 ConvertReceiverMode convert_mode = p.convert_mode();
1440 Node* target = NodeProperties::GetValueInput(node, 0); 1434 Node* target = NodeProperties::GetValueInput(node, 0);
1441 Type* target_type = NodeProperties::GetType(target); 1435 Type* target_type = NodeProperties::GetType(target);
1442 Node* receiver = NodeProperties::GetValueInput(node, 1); 1436 Node* receiver = NodeProperties::GetValueInput(node, 1);
1443 Type* receiver_type = NodeProperties::GetType(receiver); 1437 Type* receiver_type = NodeProperties::GetType(receiver);
1444 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1);
1445 Node* effect = NodeProperties::GetEffectInput(node); 1438 Node* effect = NodeProperties::GetEffectInput(node);
1446 Node* control = NodeProperties::GetControlInput(node); 1439 Node* control = NodeProperties::GetControlInput(node);
1440 Node* frame_state = NodeProperties::FindFrameStateBefore(node);
1447 1441
1448 // Try to infer receiver {convert_mode} from {receiver} type. 1442 // Try to infer receiver {convert_mode} from {receiver} type.
1449 if (receiver_type->Is(Type::NullOrUndefined())) { 1443 if (receiver_type->Is(Type::NullOrUndefined())) {
1450 convert_mode = ConvertReceiverMode::kNullOrUndefined; 1444 convert_mode = ConvertReceiverMode::kNullOrUndefined;
1451 } else if (!receiver_type->Maybe(Type::NullOrUndefined())) { 1445 } else if (!receiver_type->Maybe(Type::NullOrUndefined())) {
1452 convert_mode = ConvertReceiverMode::kNotNullOrUndefined; 1446 convert_mode = ConvertReceiverMode::kNotNullOrUndefined;
1453 } 1447 }
1454 1448
1455 // Check if {target} is a known JSFunction. 1449 // Check if {target} is a known JSFunction.
1456 if (target_type->IsConstant() && 1450 if (target_type->IsConstant() &&
(...skipping 17 matching lines...) Expand all
1474 !receiver_type->Is(Type::Receiver())) { 1468 !receiver_type->Is(Type::Receiver())) {
1475 receiver = effect = 1469 receiver = effect =
1476 graph()->NewNode(javascript()->ConvertReceiver(convert_mode), 1470 graph()->NewNode(javascript()->ConvertReceiver(convert_mode),
1477 receiver, context, frame_state, effect, control); 1471 receiver, context, frame_state, effect, control);
1478 NodeProperties::ReplaceValueInput(node, receiver, 1); 1472 NodeProperties::ReplaceValueInput(node, receiver, 1);
1479 } 1473 }
1480 1474
1481 // Update the effect dependency for the {node}. 1475 // Update the effect dependency for the {node}.
1482 NodeProperties::ReplaceEffectInput(node, effect); 1476 NodeProperties::ReplaceEffectInput(node, effect);
1483 1477
1484 // Remove the eager bailout frame state.
1485 NodeProperties::RemoveFrameStateInput(node, 1);
1486
1487 // Compute flags for the call. 1478 // Compute flags for the call.
1488 CallDescriptor::Flags flags = CallDescriptor::kNeedsFrameState; 1479 CallDescriptor::Flags flags = CallDescriptor::kNeedsFrameState;
1489 if (p.tail_call_mode() == TailCallMode::kAllow) { 1480 if (p.tail_call_mode() == TailCallMode::kAllow) {
1490 flags |= CallDescriptor::kSupportsTailCalls; 1481 flags |= CallDescriptor::kSupportsTailCalls;
1491 } 1482 }
1492 1483
1493 Node* new_target = jsgraph()->UndefinedConstant(); 1484 Node* new_target = jsgraph()->UndefinedConstant();
1494 Node* argument_count = jsgraph()->Int32Constant(arity); 1485 Node* argument_count = jsgraph()->Int32Constant(arity);
1495 if (shared->internal_formal_parameter_count() == arity || 1486 if (shared->internal_formal_parameter_count() == arity ||
1496 shared->internal_formal_parameter_count() == 1487 shared->internal_formal_parameter_count() ==
(...skipping 17 matching lines...) Expand all
1514 NodeProperties::ChangeOp( 1505 NodeProperties::ChangeOp(
1515 node, common()->Call(Linkage::GetStubCallDescriptor( 1506 node, common()->Call(Linkage::GetStubCallDescriptor(
1516 isolate(), graph()->zone(), callable.descriptor(), 1507 isolate(), graph()->zone(), callable.descriptor(),
1517 1 + arity, flags))); 1508 1 + arity, flags)));
1518 } 1509 }
1519 return Changed(node); 1510 return Changed(node);
1520 } 1511 }
1521 1512
1522 // Check if {target} is a JSFunction. 1513 // Check if {target} is a JSFunction.
1523 if (target_type->Is(Type::Function())) { 1514 if (target_type->Is(Type::Function())) {
1524 // Remove the eager bailout frame state.
1525 NodeProperties::RemoveFrameStateInput(node, 1);
1526
1527 // Compute flags for the call. 1515 // Compute flags for the call.
1528 CallDescriptor::Flags flags = CallDescriptor::kNeedsFrameState; 1516 CallDescriptor::Flags flags = CallDescriptor::kNeedsFrameState;
1529 if (p.tail_call_mode() == TailCallMode::kAllow) { 1517 if (p.tail_call_mode() == TailCallMode::kAllow) {
1530 flags |= CallDescriptor::kSupportsTailCalls; 1518 flags |= CallDescriptor::kSupportsTailCalls;
1531 } 1519 }
1532 1520
1533 // Patch {node} to an indirect call via the CallFunction builtin. 1521 // Patch {node} to an indirect call via the CallFunction builtin.
1534 Callable callable = CodeFactory::CallFunction(isolate(), convert_mode); 1522 Callable callable = CodeFactory::CallFunction(isolate(), convert_mode);
1535 node->InsertInput(graph()->zone(), 0, 1523 node->InsertInput(graph()->zone(), 0,
1536 jsgraph()->HeapConstant(callable.code())); 1524 jsgraph()->HeapConstant(callable.code()));
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1899 } 1887 }
1900 1888
1901 1889
1902 CompilationDependencies* JSTypedLowering::dependencies() const { 1890 CompilationDependencies* JSTypedLowering::dependencies() const {
1903 return dependencies_; 1891 return dependencies_;
1904 } 1892 }
1905 1893
1906 } // namespace compiler 1894 } // namespace compiler
1907 } // namespace internal 1895 } // namespace internal
1908 } // namespace v8 1896 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-inlining.cc ('k') | src/compiler/linkage.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698