Commit 44f46def authored by Mythri A's avatar Mythri A Committed by Commit Bot

[turboprop] Pass required parameters as value inputs to TierUpCheck node

TierUpCheck node tail calls interpreter entry trampoline when additional
processing is needed for tiering up. Calling IET requires target,
new_target, input count and context as parameters. Earlier these were
created as parameter nodes in effect-control-linearizer. This causes
problems with Turboprop since TurboProp doesn't use the second scheduler
and cannot reschedule these nodes to the start block. We should instead
create these parameter nodes in bytecode-graph-builder and pass them
as value inputs to TierUpCheck node.

Bug: v8:9684
Change-Id: Icfe5a33b4e628d5a3ba9a3121b2b0746be6aed5c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2498695Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Mythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70790}
parent d7ece57e
......@@ -1330,6 +1330,8 @@ void InstructionSelector::VisitNode(Node* node) {
case IrOpcode::kFinishRegion:
return MarkAsTagged(node), VisitFinishRegion(node);
case IrOpcode::kParameter: {
// Parameters should always be scheduled to the first block.
DCHECK_EQ(schedule()->block(node)->rpo_number(), 0);
MachineType type =
linkage()->GetParameterType(ParameterIndexOf(node->op()));
MarkAsRepresentation(type.representation(), node);
......
......@@ -1117,7 +1117,23 @@ Node* BytecodeGraphBuilder::BuildLoadNativeContext() {
void BytecodeGraphBuilder::MaybeBuildTierUpCheck() {
if (!CodeKindChecksOptimizationMarker(code_kind())) return;
NewNode(simplified()->TierUpCheck(), feedback_vector_node());
int parameter_count = bytecode_array().parameter_count();
Node* target = GetFunctionClosure();
Node* new_target = graph()->NewNode(
common()->Parameter(
Linkage::GetJSCallNewTargetParamIndex(parameter_count),
"%new.target"),
graph()->start());
Node* argc = graph()->NewNode(
common()->Parameter(Linkage::GetJSCallArgCountParamIndex(parameter_count),
"%argc"),
graph()->start());
DCHECK_EQ(environment()->Context()->opcode(), IrOpcode::kParameter);
Node* context = environment()->Context();
NewNode(simplified()->TierUpCheck(), feedback_vector_node(), target,
new_target, argc, context);
}
void BytecodeGraphBuilder::MaybeBuildIncrementInvocationCount() {
......
......@@ -3713,17 +3713,8 @@ void EffectControlLinearizer::LowerTierUpCheck(Node* node) {
// Currently we delegate these tasks to the InterpreterEntryTrampoline.
// TODO(jgruber,v8:8888): Consider a dedicated builtin instead.
const int parameter_count =
StartNode{graph()->start()}.FormalParameterCount();
TNode<HeapObject> code =
__ HeapConstant(BUILTIN_CODE(isolate(), InterpreterEntryTrampoline));
Node* target = __ Parameter(Linkage::kJSCallClosureParamIndex);
Node* new_target =
__ Parameter(Linkage::GetJSCallNewTargetParamIndex(parameter_count));
Node* argc =
__ Parameter(Linkage::GetJSCallArgCountParamIndex(parameter_count));
Node* context =
__ Parameter(Linkage::GetJSCallContextParamIndex(parameter_count));
JSTrampolineDescriptor descriptor;
CallDescriptor::Flags flags = CallDescriptor::kFixedTargetRegister |
......@@ -3731,8 +3722,8 @@ void EffectControlLinearizer::LowerTierUpCheck(Node* node) {
auto call_descriptor = Linkage::GetStubCallDescriptor(
graph()->zone(), descriptor, descriptor.GetStackParameterCount(), flags,
Operator::kNoProperties);
Node* nodes[] = {code, target, new_target, argc,
context, __ effect(), __ control()};
Node* nodes[] = {code, n.target(), n.new_target(), n.input_count(),
n.context(), __ effect(), __ control()};
#ifdef DEBUG
static constexpr int kCodeContextEffectControl = 4;
......
......@@ -2828,7 +2828,16 @@ class RepresentationSelector {
return VisitUnop<T>(node, UseInfo::AnyTagged(),
MachineRepresentation::kTaggedPointer);
}
case IrOpcode::kTierUpCheck:
case IrOpcode::kTierUpCheck: {
ProcessInput<T>(node, 0, UseInfo::AnyTagged());
ProcessInput<T>(node, 1, UseInfo::AnyTagged());
ProcessInput<T>(node, 2, UseInfo::AnyTagged());
ProcessInput<T>(node, 3, UseInfo::AnyTagged());
ProcessInput<T>(node, 4, UseInfo::AnyTagged());
ProcessRemainingInputs<T>(node, 5);
SetOutput<T>(node, MachineRepresentation::kNone);
return;
}
case IrOpcode::kUpdateInterruptBudget: {
ProcessInput<T>(node, 0, UseInfo::AnyTagged());
ProcessRemainingInputs<T>(node, 1);
......
......@@ -1325,7 +1325,7 @@ const Operator* SimplifiedOperatorBuilder::UpdateInterruptBudget(int delta) {
const Operator* SimplifiedOperatorBuilder::TierUpCheck() {
return zone()->New<Operator>(IrOpcode::kTierUpCheck,
Operator::kNoThrow | Operator::kNoDeopt,
"TierUpCheck", 1, 1, 1, 0, 1, 0);
"TierUpCheck", 5, 1, 1, 0, 1, 0);
}
const Operator* SimplifiedOperatorBuilder::AssertType(Type type) {
......
......@@ -1190,7 +1190,12 @@ class TierUpCheckNode final : public SimplifiedNodeWrapperBase {
CONSTEXPR_DCHECK(node->opcode() == IrOpcode::kTierUpCheck);
}
#define INPUTS(V) V(FeedbackVector, feedback_vector, 0, FeedbackVector)
#define INPUTS(V) \
V(FeedbackVector, feedback_vector, 0, FeedbackVector) \
V(Target, target, 1, JSReceiver) \
V(NewTarget, new_target, 2, Object) \
V(InputCount, input_count, 3, Object) \
V(Context, context, 4, Context)
INPUTS(DEFINE_INPUT_ACCESSORS)
#undef INPUTS
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment