Commit ef5ee8e1 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[turbofan] Remove language mode from JSCall operator.

This removes the language mode parameter from all JSCall operators. The
information is no longer used anywhere and is not threaded through the
interpreter bytecode. We should only thread it through the bytecode if
it has a semantic impact on the compilation.

R=bmeurer@chromium.org

Review URL: https://codereview.chromium.org/1709493002

Cr-Commit-Position: refs/heads/master@{#34073}
parent 76c054b1
......@@ -2483,9 +2483,8 @@ void AstGraphBuilder::VisitCall(Call* expr) {
// Create node to perform the function call.
VectorSlotPair feedback = CreateVectorSlotPair(expr->CallFeedbackICSlot());
const Operator* call =
javascript()->CallFunction(args->length() + 2, language_mode(), feedback,
receiver_hint, expr->tail_call_mode());
const Operator* call = javascript()->CallFunction(
args->length() + 2, feedback, receiver_hint, expr->tail_call_mode());
FrameStateBeforeAndAfter states(this, expr->CallId());
Node* value = ProcessArguments(call, args->length() + 2);
environment()->Push(value->InputAt(0)); // The callee passed to the call.
......@@ -2563,8 +2562,7 @@ void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) {
VisitForValues(args);
// Create node to perform the JS runtime call.
const Operator* call =
javascript()->CallFunction(args->length() + 2, language_mode());
const Operator* call = javascript()->CallFunction(args->length() + 2);
FrameStateBeforeAndAfter states(this, expr->CallId());
Node* value = ProcessArguments(call, args->length() + 2);
states.AddToNode(value, expr->id(), ast_context()->GetStateCombine());
......
......@@ -1007,8 +1007,8 @@ void BytecodeGraphBuilder::BuildCall() {
CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(3));
// TODO(ishell): provide correct tail_call_mode value to CallFunction.
const Operator* call = javascript()->CallFunction(
arg_count + 1, language_mode(), feedback, receiver_hint);
const Operator* call =
javascript()->CallFunction(arg_count + 1, feedback, receiver_hint);
Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1);
environment()->BindAccumulator(value, &states);
}
......@@ -1025,8 +1025,7 @@ void BytecodeGraphBuilder::BuildCallJSRuntime() {
size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2);
// Create node to perform the JS runtime call.
const Operator* call =
javascript()->CallFunction(arg_count + 1, language_mode());
const Operator* call = javascript()->CallFunction(arg_count + 1);
Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 1);
environment()->BindAccumulator(value, &states);
}
......
......@@ -167,8 +167,7 @@ Reduction JSCallReducer::ReduceFunctionPrototypeApply(Node* node) {
}
// Change {node} to the new {JSCallFunction} operator.
NodeProperties::ChangeOp(
node, javascript()->CallFunction(arity, p.language_mode(),
CallCountFeedback(p.feedback()),
node, javascript()->CallFunction(arity, CallCountFeedback(p.feedback()),
convert_mode, p.tail_call_mode()));
// Change context of {node} to the Function.prototype.apply context,
// to ensure any exception is thrown in the correct context.
......@@ -208,8 +207,7 @@ Reduction JSCallReducer::ReduceFunctionPrototypeCall(Node* node) {
--arity;
}
NodeProperties::ChangeOp(
node, javascript()->CallFunction(arity, p.language_mode(),
CallCountFeedback(p.feedback()),
node, javascript()->CallFunction(arity, CallCountFeedback(p.feedback()),
convert_mode, p.tail_call_mode()));
// Try to further reduce the JSCallFunction {node}.
Reduction const reduction = ReduceJSCallFunction(node);
......@@ -291,10 +289,9 @@ Reduction JSCallReducer::ReduceJSCallFunction(Node* node) {
jsgraph()->Constant(handle(bound_arguments->get(i), isolate())));
arity++;
}
NodeProperties::ChangeOp(
node, javascript()->CallFunction(arity, p.language_mode(),
CallCountFeedback(p.feedback()),
convert_mode, p.tail_call_mode()));
NodeProperties::ChangeOp(node, javascript()->CallFunction(
arity, CallCountFeedback(p.feedback()),
convert_mode, p.tail_call_mode()));
// Try to further reduce the JSCallFunction {node}.
Reduction const reduction = ReduceJSCallFunction(node);
return reduction.Changed() ? reduction : Changed(node);
......
......@@ -499,20 +499,20 @@ Reduction JSIntrinsicLowering::ReduceToString(Node* node) {
Reduction JSIntrinsicLowering::ReduceCall(Node* node) {
size_t const arity = CallRuntimeParametersOf(node->op()).arity();
NodeProperties::ChangeOp(
node, javascript()->CallFunction(arity, STRICT, VectorSlotPair(),
ConvertReceiverMode::kAny,
TailCallMode::kDisallow));
NodeProperties::ChangeOp(node,
javascript()->CallFunction(arity, VectorSlotPair(),
ConvertReceiverMode::kAny,
TailCallMode::kDisallow));
return Changed(node);
}
Reduction JSIntrinsicLowering::ReduceTailCall(Node* node) {
size_t const arity = CallRuntimeParametersOf(node->op()).arity();
NodeProperties::ChangeOp(
node, javascript()->CallFunction(arity, STRICT, VectorSlotPair(),
ConvertReceiverMode::kAny,
TailCallMode::kAllow));
NodeProperties::ChangeOp(node,
javascript()->CallFunction(arity, VectorSlotPair(),
ConvertReceiverMode::kAny,
TailCallMode::kAllow));
return Changed(node);
}
......
......@@ -81,8 +81,7 @@ CallConstructParameters const& CallConstructParametersOf(Operator const* op) {
std::ostream& operator<<(std::ostream& os, CallFunctionParameters const& p) {
os << p.arity() << ", " << p.language_mode() << ", " << p.convert_mode()
<< ", " << p.tail_call_mode();
os << p.arity() << ", " << p.convert_mode() << ", " << p.tail_call_mode();
return os;
}
......@@ -544,12 +543,11 @@ const Operator* JSOperatorBuilder::ToBoolean(ToBooleanHints hints) {
hints); // parameter
}
const Operator* JSOperatorBuilder::CallFunction(
size_t arity, LanguageMode language_mode, VectorSlotPair const& feedback,
size_t arity, VectorSlotPair const& feedback,
ConvertReceiverMode convert_mode, TailCallMode tail_call_mode) {
CallFunctionParameters parameters(arity, language_mode, feedback,
tail_call_mode, convert_mode);
CallFunctionParameters parameters(arity, feedback, tail_call_mode,
convert_mode);
return new (zone()) Operator1<CallFunctionParameters>( // --
IrOpcode::kJSCallFunction, Operator::kNoProperties, // opcode
"JSCallFunction", // name
......
......@@ -80,20 +80,15 @@ CallConstructParameters const& CallConstructParametersOf(Operator const*);
// used as a parameter by JSCallFunction operators.
class CallFunctionParameters final {
public:
CallFunctionParameters(size_t arity, LanguageMode language_mode,
VectorSlotPair const& feedback,
CallFunctionParameters(size_t arity, VectorSlotPair const& feedback,
TailCallMode tail_call_mode,
ConvertReceiverMode convert_mode)
: bit_field_(ArityField::encode(arity) |
ConvertReceiverModeField::encode(convert_mode) |
LanguageModeField::encode(language_mode) |
TailCallModeField::encode(tail_call_mode)),
feedback_(feedback) {}
size_t arity() const { return ArityField::decode(bit_field_); }
LanguageMode language_mode() const {
return LanguageModeField::decode(bit_field_);
}
ConvertReceiverMode convert_mode() const {
return ConvertReceiverModeField::decode(bit_field_);
}
......@@ -115,9 +110,8 @@ class CallFunctionParameters final {
return base::hash_combine(p.bit_field_, p.feedback_);
}
typedef BitField<size_t, 0, 27> ArityField;
typedef BitField<ConvertReceiverMode, 27, 2> ConvertReceiverModeField;
typedef BitField<LanguageMode, 29, 2> LanguageModeField;
typedef BitField<size_t, 0, 29> ArityField;
typedef BitField<ConvertReceiverMode, 29, 2> ConvertReceiverModeField;
typedef BitField<TailCallMode, 31, 1> TailCallModeField;
const uint32_t bit_field_;
......@@ -427,8 +421,7 @@ class JSOperatorBuilder final : public ZoneObject {
int literal_flags, int literal_index);
const Operator* CallFunction(
size_t arity, LanguageMode language_mode,
VectorSlotPair const& feedback = VectorSlotPair(),
size_t arity, VectorSlotPair const& feedback = VectorSlotPair(),
ConvertReceiverMode convert_mode = ConvertReceiverMode::kAny,
TailCallMode tail_call_mode = TailCallMode::kDisallow);
const Operator* CallRuntime(Runtime::FunctionId id);
......
......@@ -1496,9 +1496,8 @@ Reduction JSTypedLowering::ReduceJSCallFunction(Node* node) {
// Maybe we did at least learn something about the {receiver}.
if (p.convert_mode() != convert_mode) {
NodeProperties::ChangeOp(
node,
javascript()->CallFunction(p.arity(), p.language_mode(), p.feedback(),
convert_mode, p.tail_call_mode()));
node, javascript()->CallFunction(p.arity(), p.feedback(), convert_mode,
p.tail_call_mode()));
return Changed(node);
}
......
......@@ -64,10 +64,6 @@ Type* const kIntegral32Types[] = {Type::UnsignedSmall(), Type::Negative32(),
Type::Integral32()};
const LanguageMode kLanguageModes[] = {SLOPPY, STRICT, STRONG};
// TODO(mstarzinger): Find a common place and unify with test-js-typed-lowering.
Type* const kNumberTypes[] = {
Type::UnsignedSmall(), Type::Negative32(), Type::Unsigned31(),
Type::SignedSmall(), Type::Signed32(), Type::Unsigned32(),
......@@ -88,15 +84,13 @@ TEST_F(JSBuiltinReducerTest, MathMax0) {
Node* control = graph()->start();
Node* context = UndefinedConstant();
Node* frame_state = graph()->start();
TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
Node* call = graph()->NewNode(javascript()->CallFunction(2, language_mode),
function, UndefinedConstant(), context,
frame_state, frame_state, effect, control);
Reduction r = Reduce(call);
Node* call = graph()->NewNode(javascript()->CallFunction(2), function,
UndefinedConstant(), context, frame_state,
frame_state, effect, control);
Reduction r = Reduce(call);
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsNumberConstant(-V8_INFINITY));
}
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsNumberConstant(-V8_INFINITY));
}
......@@ -107,18 +101,15 @@ TEST_F(JSBuiltinReducerTest, MathMax1) {
Node* control = graph()->start();
Node* context = UndefinedConstant();
Node* frame_state = graph()->start();
TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
TRACED_FOREACH(Type*, t0, kNumberTypes) {
Node* p0 = Parameter(t0, 0);
Node* call =
graph()->NewNode(javascript()->CallFunction(3, language_mode),
function, UndefinedConstant(), p0, context,
frame_state, frame_state, effect, control);
Reduction r = Reduce(call);
TRACED_FOREACH(Type*, t0, kNumberTypes) {
Node* p0 = Parameter(t0, 0);
Node* call = graph()->NewNode(javascript()->CallFunction(3), function,
UndefinedConstant(), p0, context, frame_state,
frame_state, effect, control);
Reduction r = Reduce(call);
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), p0);
}
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), p0);
}
}
......@@ -130,22 +121,18 @@ TEST_F(JSBuiltinReducerTest, MathMax2) {
Node* control = graph()->start();
Node* context = UndefinedConstant();
Node* frame_state = graph()->start();
TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
TRACED_FOREACH(Type*, t0, kIntegral32Types) {
TRACED_FOREACH(Type*, t1, kIntegral32Types) {
Node* p0 = Parameter(t0, 0);
Node* p1 = Parameter(t1, 1);
Node* call =
graph()->NewNode(javascript()->CallFunction(4, language_mode),
function, UndefinedConstant(), p0, p1, context,
frame_state, frame_state, effect, control);
Reduction r = Reduce(call);
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(),
IsSelect(MachineRepresentation::kNone,
IsNumberLessThan(p1, p0), p0, p1));
}
TRACED_FOREACH(Type*, t0, kIntegral32Types) {
TRACED_FOREACH(Type*, t1, kIntegral32Types) {
Node* p0 = Parameter(t0, 0);
Node* p1 = Parameter(t1, 1);
Node* call = graph()->NewNode(javascript()->CallFunction(4), function,
UndefinedConstant(), p0, p1, context,
frame_state, frame_state, effect, control);
Reduction r = Reduce(call);
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsSelect(MachineRepresentation::kNone,
IsNumberLessThan(p1, p0), p0, p1));
}
}
}
......@@ -162,20 +149,17 @@ TEST_F(JSBuiltinReducerTest, MathImul) {
Node* control = graph()->start();
Node* context = UndefinedConstant();
Node* frame_state = graph()->start();
TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
TRACED_FOREACH(Type*, t0, kIntegral32Types) {
TRACED_FOREACH(Type*, t1, kIntegral32Types) {
Node* p0 = Parameter(t0, 0);
Node* p1 = Parameter(t1, 1);
Node* call =
graph()->NewNode(javascript()->CallFunction(4, language_mode),
function, UndefinedConstant(), p0, p1, context,
frame_state, frame_state, effect, control);
Reduction r = Reduce(call);
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsInt32Mul(p0, p1));
}
TRACED_FOREACH(Type*, t0, kIntegral32Types) {
TRACED_FOREACH(Type*, t1, kIntegral32Types) {
Node* p0 = Parameter(t0, 0);
Node* p1 = Parameter(t1, 1);
Node* call = graph()->NewNode(javascript()->CallFunction(4), function,
UndefinedConstant(), p0, p1, context,
frame_state, frame_state, effect, control);
Reduction r = Reduce(call);
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsInt32Mul(p0, p1));
}
}
}
......@@ -192,18 +176,15 @@ TEST_F(JSBuiltinReducerTest, MathFround) {
Node* control = graph()->start();
Node* context = UndefinedConstant();
Node* frame_state = graph()->start();
TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
TRACED_FOREACH(Type*, t0, kNumberTypes) {
Node* p0 = Parameter(t0, 0);
Node* call =
graph()->NewNode(javascript()->CallFunction(3, language_mode),
function, UndefinedConstant(), p0, context,
frame_state, frame_state, effect, control);
Reduction r = Reduce(call);
TRACED_FOREACH(Type*, t0, kNumberTypes) {
Node* p0 = Parameter(t0, 0);
Node* call = graph()->NewNode(javascript()->CallFunction(3), function,
UndefinedConstant(), p0, context, frame_state,
frame_state, effect, control);
Reduction r = Reduce(call);
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsTruncateFloat64ToFloat32(p0));
}
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsTruncateFloat64ToFloat32(p0));
}
}
......
......@@ -83,9 +83,9 @@ TEST_F(JSContextRelaxationTest,
ShallowFrameStateChain(outer_context, CALL_MAINTAINS_NATIVE_CONTEXT);
Node* const effect = graph()->start();
Node* const control = graph()->start();
Node* node = graph()->NewNode(
javascript()->CallFunction(2, STRICT, VectorSlotPair()), input0, input1,
context, frame_state, frame_state, effect, control);
Node* node = graph()->NewNode(javascript()->CallFunction(2, VectorSlotPair()),
input0, input1, context, frame_state,
frame_state, effect, control);
Reduction const r = Reduce(node);
EXPECT_TRUE(r.Changed());
EXPECT_EQ(outer_context, NodeProperties::GetContextInput(node));
......@@ -101,9 +101,9 @@ TEST_F(JSContextRelaxationTest,
ShallowFrameStateChain(outer_context, CALL_CHANGES_NATIVE_CONTEXT);
Node* const effect = graph()->start();
Node* const control = graph()->start();
Node* node = graph()->NewNode(
javascript()->CallFunction(2, STRICT, VectorSlotPair()), input0, input1,
context, frame_state, frame_state, effect, control);
Node* node = graph()->NewNode(javascript()->CallFunction(2, VectorSlotPair()),
input0, input1, context, frame_state,
frame_state, effect, control);
Reduction const r = Reduce(node);
EXPECT_FALSE(r.Changed());
EXPECT_EQ(context, NodeProperties::GetContextInput(node));
......@@ -119,9 +119,9 @@ TEST_F(JSContextRelaxationTest,
DeepFrameStateChain(outer_context, CALL_MAINTAINS_NATIVE_CONTEXT);
Node* const effect = graph()->start();
Node* const control = graph()->start();
Node* node = graph()->NewNode(
javascript()->CallFunction(2, STRICT, VectorSlotPair()), input0, input1,
context, frame_state, frame_state, effect, control);
Node* node = graph()->NewNode(javascript()->CallFunction(2, VectorSlotPair()),
input0, input1, context, frame_state,
frame_state, effect, control);
Reduction const r = Reduce(node);
EXPECT_TRUE(r.Changed());
EXPECT_EQ(outer_context, NodeProperties::GetContextInput(node));
......@@ -137,9 +137,9 @@ TEST_F(JSContextRelaxationTest,
DeepFrameStateChain(outer_context, CALL_CHANGES_NATIVE_CONTEXT);
Node* const effect = graph()->start();
Node* const control = graph()->start();
Node* node = graph()->NewNode(
javascript()->CallFunction(2, STRICT, VectorSlotPair()), input0, input1,
context, frame_state, frame_state, effect, control);
Node* node = graph()->NewNode(javascript()->CallFunction(2, VectorSlotPair()),
input0, input1, context, frame_state,
frame_state, effect, control);
Reduction const r = Reduce(node);
EXPECT_FALSE(r.Changed());
EXPECT_EQ(context, NodeProperties::GetContextInput(node));
......@@ -158,9 +158,9 @@ TEST_F(JSContextRelaxationTest,
op, graph()->start(), graph()->start(), outer_context, effect, control);
Node* const frame_state_2 =
ShallowFrameStateChain(nested_context, CALL_MAINTAINS_NATIVE_CONTEXT);
Node* node = graph()->NewNode(
javascript()->CallFunction(2, STRICT, VectorSlotPair()), input0, input1,
context, frame_state_2, frame_state_2, effect, control);
Node* node = graph()->NewNode(javascript()->CallFunction(2, VectorSlotPair()),
input0, input1, context, frame_state_2,
frame_state_2, effect, control);
Reduction const r = Reduce(node);
EXPECT_TRUE(r.Changed());
EXPECT_EQ(outer_context, NodeProperties::GetContextInput(node));
......@@ -180,9 +180,9 @@ TEST_F(JSContextRelaxationTest,
op, graph()->start(), graph()->start(), outer_context, effect, control);
Node* const frame_state_2 =
ShallowFrameStateChain(nested_context, CALL_MAINTAINS_NATIVE_CONTEXT);
Node* node = graph()->NewNode(
javascript()->CallFunction(2, STRICT, VectorSlotPair()), input0, input1,
context, frame_state_2, frame_state_2, effect, control);
Node* node = graph()->NewNode(javascript()->CallFunction(2, VectorSlotPair()),
input0, input1, context, frame_state_2,
frame_state_2, effect, control);
Reduction const r = Reduce(node);
EXPECT_TRUE(r.Changed());
EXPECT_EQ(outer_context, NodeProperties::GetContextInput(node));
......@@ -203,9 +203,9 @@ TEST_F(JSContextRelaxationTest,
graph()->NewNode(op, graph()->start(), outer_context, effect, control);
Node* const frame_state_2 =
ShallowFrameStateChain(nested_context, CALL_MAINTAINS_NATIVE_CONTEXT);
Node* node = graph()->NewNode(
javascript()->CallFunction(2, STRICT, VectorSlotPair()), input0, input1,
context, frame_state_2, frame_state_2, effect, control);
Node* node = graph()->NewNode(javascript()->CallFunction(2, VectorSlotPair()),
input0, input1, context, frame_state_2,
frame_state_2, effect, control);
Reduction const r = Reduce(node);
EXPECT_TRUE(r.Changed());
EXPECT_EQ(outer_context, NodeProperties::GetContextInput(node));
......@@ -228,9 +228,9 @@ TEST_F(JSContextRelaxationTest,
frame_state_1, effect, control);
Node* const frame_state_2 =
ShallowFrameStateChain(nested_context, CALL_MAINTAINS_NATIVE_CONTEXT);
Node* node = graph()->NewNode(
javascript()->CallFunction(2, STRICT, VectorSlotPair()), input0, input1,
context, frame_state_2, frame_state_2, effect, control);
Node* node = graph()->NewNode(javascript()->CallFunction(2, VectorSlotPair()),
input0, input1, context, frame_state_2,
frame_state_2, effect, control);
Reduction const r = Reduce(node);
EXPECT_TRUE(r.Changed());
EXPECT_EQ(nested_context, NodeProperties::GetContextInput(node));
......@@ -250,9 +250,9 @@ TEST_F(JSContextRelaxationTest,
op, graph()->start(), graph()->start(), outer_context, effect, control);
Node* const frame_state_2 =
ShallowFrameStateChain(nested_context, CALL_MAINTAINS_NATIVE_CONTEXT);
Node* node = graph()->NewNode(
javascript()->CallFunction(2, STRICT, VectorSlotPair()), input0, input1,
context, frame_state_2, frame_state_2, effect, control);
Node* node = graph()->NewNode(javascript()->CallFunction(2, VectorSlotPair()),
input0, input1, context, frame_state_2,
frame_state_2, effect, control);
Reduction const r = Reduce(node);
EXPECT_TRUE(r.Changed());
EXPECT_EQ(nested_context, NodeProperties::GetContextInput(node));
......@@ -272,9 +272,9 @@ TEST_F(JSContextRelaxationTest,
graph()->NewNode(op, graph()->start(), outer_context, effect, control);
Node* const frame_state_2 =
ShallowFrameStateChain(nested_context, CALL_MAINTAINS_NATIVE_CONTEXT);
Node* node = graph()->NewNode(
javascript()->CallFunction(2, STRICT, VectorSlotPair()), input0, input1,
context, frame_state_2, frame_state_2, effect, control);
Node* node = graph()->NewNode(javascript()->CallFunction(2, VectorSlotPair()),
input0, input1, context, frame_state_2,
frame_state_2, effect, control);
Reduction const r = Reduce(node);
EXPECT_FALSE(r.Changed());
EXPECT_EQ(context, NodeProperties::GetContextInput(node));
......
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