Commit 7f25263c authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[csa] Remove unused ReceiverMode for CodeStubArguments

... and other unused methods.

Bug: v8:9708
Change-Id: Ie3658878024fcddcd5503c6462e5ad873eba19b0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2206733
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Auto-Submit: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67859}
parent 9282c907
......@@ -12513,10 +12513,8 @@ TNode<UintPtrT> CodeStubAssembler::LoadJSTypedArrayLength(
}
CodeStubArguments::CodeStubArguments(CodeStubAssembler* assembler,
TNode<IntPtrT> argc, TNode<RawPtrT> fp,
ReceiverMode receiver_mode)
TNode<IntPtrT> argc, TNode<RawPtrT> fp)
: assembler_(assembler),
receiver_mode_(receiver_mode),
argc_(argc),
base_(),
fp_(fp != nullptr ? fp : assembler_->LoadFramePointer()) {
......@@ -12536,7 +12534,6 @@ CodeStubArguments::CodeStubArguments(CodeStubAssembler* assembler,
}
TNode<Object> CodeStubArguments::GetReceiver() const {
DCHECK_EQ(receiver_mode_, ReceiverMode::kHasReceiver);
#ifdef V8_REVERSE_JSARGS
intptr_t offset = -kSystemPointerSize;
#else
......@@ -12546,7 +12543,6 @@ TNode<Object> CodeStubArguments::GetReceiver() const {
}
void CodeStubArguments::SetReceiver(TNode<Object> object) const {
DCHECK_EQ(receiver_mode_, ReceiverMode::kHasReceiver);
#ifdef V8_REVERSE_JSARGS
intptr_t offset = -kSystemPointerSize;
#else
......@@ -12579,26 +12575,6 @@ TNode<Object> CodeStubArguments::AtIndex(int index) const {
return AtIndex(assembler_->IntPtrConstant(index));
}
TNode<Object> CodeStubArguments::GetOptionalArgumentValue(
int index, TNode<Object> default_value) {
CodeStubAssembler::TVariable<Object> result(assembler_);
CodeStubAssembler::Label argument_missing(assembler_),
argument_done(assembler_, &result);
assembler_->GotoIf(assembler_->UintPtrGreaterThanOrEqual(
assembler_->IntPtrConstant(index), argc_),
&argument_missing);
result = AtIndex(index);
assembler_->Goto(&argument_done);
assembler_->BIND(&argument_missing);
result = default_value;
assembler_->Goto(&argument_done);
assembler_->BIND(&argument_done);
return result.value();
}
TNode<Object> CodeStubArguments::GetOptionalArgumentValue(
TNode<IntPtrT> index, TNode<Object> default_value) {
CodeStubAssembler::TVariable<Object> result(assembler_);
......@@ -12646,13 +12622,8 @@ void CodeStubArguments::ForEach(
}
void CodeStubArguments::PopAndReturn(TNode<Object> value) {
TNode<IntPtrT> pop_count;
if (receiver_mode_ == ReceiverMode::kHasReceiver) {
pop_count = assembler_->IntPtrAdd(argc_, assembler_->IntPtrConstant(1));
} else {
pop_count = argc_;
}
TNode<IntPtrT> pop_count =
assembler_->IntPtrAdd(argc_, assembler_->IntPtrConstant(1));
assembler_->PopAndReturn(pop_count, value);
}
......
......@@ -4029,49 +4029,24 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
ParameterMode parameter_mode = INTPTR_PARAMETERS);
};
// template <typename TIndex>
class V8_EXPORT_PRIVATE CodeStubArguments {
public:
using Node = compiler::Node;
enum ReceiverMode { kHasReceiver, kNoReceiver };
// |argc| specifies the number of arguments passed to the builtin excluding
// the receiver. The arguments will include a receiver iff |receiver_mode|
// is kHasReceiver.
// the receiver. The arguments include the receiver.
CodeStubArguments(CodeStubAssembler* assembler, TNode<IntPtrT> argc)
: CodeStubArguments(assembler, argc, TNode<RawPtrT>()) {}
CodeStubArguments(CodeStubAssembler* assembler, TNode<Int32T> argc)
: CodeStubArguments(assembler, assembler->ChangeInt32ToIntPtr(argc)) {}
CodeStubArguments(CodeStubAssembler* assembler, TNode<IntPtrT> argc,
ReceiverMode receiver_mode = ReceiverMode::kHasReceiver)
: CodeStubArguments(assembler, argc, TNode<RawPtrT>(), receiver_mode) {}
CodeStubArguments(CodeStubAssembler* assembler, TNode<Int32T> argc,
ReceiverMode receiver_mode = ReceiverMode::kHasReceiver)
: CodeStubArguments(assembler, assembler->ChangeInt32ToIntPtr(argc),
TNode<RawPtrT>(), receiver_mode) {}
// TODO(v8:9708): Consider removing this variant
CodeStubArguments(CodeStubAssembler* assembler, TNode<Smi> argc,
ReceiverMode receiver_mode = ReceiverMode::kHasReceiver)
: CodeStubArguments(assembler, assembler->ParameterToIntPtr(argc),
TNode<RawPtrT>(), receiver_mode) {}
// |argc| specifies the number of arguments passed to the builtin excluding
// the receiver. The arguments will include a receiver iff |receiver_mode|
// is kHasReceiver.
CodeStubArguments(CodeStubAssembler* assembler, TNode<IntPtrT> argc,
TNode<RawPtrT> fp,
ReceiverMode receiver_mode = ReceiverMode::kHasReceiver);
CodeStubArguments(CodeStubAssembler* assembler, TNode<Smi> argc,
TNode<RawPtrT> fp,
ReceiverMode receiver_mode = ReceiverMode::kHasReceiver)
: CodeStubArguments(assembler, assembler->ParameterToIntPtr(argc), fp,
receiver_mode) {}
TNode<RawPtrT> fp);
// Used by Torque to construct arguments based on a Torque-defined
// struct of values.
CodeStubArguments(CodeStubAssembler* assembler,
TorqueStructArguments torque_arguments)
: assembler_(assembler),
receiver_mode_(ReceiverMode::kHasReceiver),
argc_(torque_arguments.length),
base_(torque_arguments.base),
fp_(torque_arguments.frame) {}
......@@ -4084,68 +4059,41 @@ class V8_EXPORT_PRIVATE CodeStubArguments {
// Computes address of the index'th argument.
TNode<RawPtrT> AtIndexPtr(TNode<IntPtrT> index) const;
TNode<RawPtrT> AtIndexPtr(TNode<Smi> index) const {
return AtIndexPtr(assembler_->ParameterToIntPtr(index));
}
// |index| is zero-based and does not include the receiver
TNode<Object> AtIndex(TNode<IntPtrT> index) const;
// TODO(v8:9708): Consider removing this variant
TNode<Object> AtIndex(TNode<Smi> index) const {
return AtIndex(assembler_->ParameterToIntPtr(index));
}
TNode<Object> AtIndex(int index) const;
TNode<Object> GetOptionalArgumentValue(int index) {
return GetOptionalArgumentValue(index, assembler_->UndefinedConstant());
}
TNode<Object> GetOptionalArgumentValue(int index,
TNode<Object> default_value);
TNode<IntPtrT> GetLength() const { return argc_; }
TorqueStructArguments GetTorqueArguments() const {
return TorqueStructArguments{fp_, base_, argc_};
}
TNode<Object> GetOptionalArgumentValue(TNode<IntPtrT> index,
TNode<Object> default_value);
TNode<Object> GetOptionalArgumentValue(TNode<IntPtrT> index) {
return GetOptionalArgumentValue(index, assembler_->UndefinedConstant());
}
TNode<Object> GetOptionalArgumentValue(TNode<IntPtrT> index,
TNode<Object> default_value);
using ForEachBodyFunction = std::function<void(TNode<Object> arg)>;
TNode<Object> GetOptionalArgumentValue(int index) {
return GetOptionalArgumentValue(assembler_->IntPtrConstant(index));
}
// Iteration doesn't include the receiver. |first| and |last| are zero-based.
template <typename TIndex>
void ForEach(const ForEachBodyFunction& body, TNode<TIndex> first = {},
TNode<TIndex> last = {}) const {
using ForEachBodyFunction = std::function<void(TNode<Object> arg)>;
void ForEach(const ForEachBodyFunction& body, TNode<IntPtrT> first = {},
TNode<IntPtrT> last = {}) const {
CodeStubAssembler::VariableList list(0, assembler_->zone());
ForEach(list, body, first, last);
}
// Iteration doesn't include the receiver. |first| and |last| are zero-based.
void ForEach(const CodeStubAssembler::VariableList& vars,
const ForEachBodyFunction& body, TNode<IntPtrT> first = {},
TNode<IntPtrT> last = {}) const;
void ForEach(const CodeStubAssembler::VariableList& vars,
const ForEachBodyFunction& body, TNode<Smi> first,
TNode<Smi> last = {}) const {
TNode<IntPtrT> first_intptr = assembler_->ParameterToIntPtr(first);
TNode<IntPtrT> last_intptr;
if (last != nullptr) {
last_intptr = assembler_->ParameterToIntPtr(last);
}
return ForEach(vars, body, first_intptr, last_intptr);
}
void PopAndReturn(TNode<Object> value);
private:
CodeStubAssembler* assembler_;
ReceiverMode receiver_mode_;
TNode<IntPtrT> argc_;
TNode<RawPtrT> base_;
TNode<RawPtrT> fp_;
......
......@@ -2155,79 +2155,6 @@ TEST(Arguments) {
CHECK_EQ(*isolate->factory()->undefined_value(), *result);
}
TEST(ArgumentsWithSmiConstantIndices) {
Isolate* isolate(CcTest::InitIsolateOnce());
const int kNumParams = 4;
CodeAssemblerTester asm_tester(isolate, kNumParams);
CodeStubAssembler m(asm_tester.state());
CodeStubArguments arguments(&m, m.SmiConstant(3));
CSA_ASSERT(&m, m.TaggedEqual(arguments.AtIndex(m.SmiConstant(0)),
m.SmiConstant(12)));
CSA_ASSERT(&m, m.TaggedEqual(arguments.AtIndex(m.SmiConstant(1)),
m.SmiConstant(13)));
CSA_ASSERT(&m, m.TaggedEqual(arguments.AtIndex(m.SmiConstant(2)),
m.SmiConstant(14)));
arguments.PopAndReturn(arguments.GetReceiver());
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
Handle<Object> result = ft.Call(isolate->factory()->undefined_value(),
Handle<Smi>(Smi::FromInt(12), isolate),
Handle<Smi>(Smi::FromInt(13), isolate),
Handle<Smi>(Smi::FromInt(14), isolate))
.ToHandleChecked();
CHECK_EQ(*isolate->factory()->undefined_value(), *result);
}
TNode<Smi> NonConstantSmi(CodeStubAssembler* m, int value) {
// Generate a SMI with the given value and feed it through a Phi so it can't
// be inferred to be constant.
Variable var(m, MachineRepresentation::kTagged, m->SmiConstant(value));
Label dummy_done(m);
// Even though the Goto always executes, it will taint the variable and thus
// make it appear non-constant when used later.
m->GotoIf(m->Int32Constant(1), &dummy_done);
var.Bind(m->SmiConstant(value));
m->Goto(&dummy_done);
m->BIND(&dummy_done);
// Ensure that the above hackery actually created a non-constant SMI.
Smi smi_constant;
CHECK(!m->ToSmiConstant(var.value(), &smi_constant));
return m->UncheckedCast<Smi>(var.value());
}
TEST(ArgumentsWithSmiIndices) {
Isolate* isolate(CcTest::InitIsolateOnce());
const int kNumParams = 4;
CodeAssemblerTester asm_tester(isolate, kNumParams);
CodeStubAssembler m(asm_tester.state());
CodeStubArguments arguments(&m, m.SmiConstant(3));
CSA_ASSERT(&m, m.TaggedEqual(arguments.AtIndex(NonConstantSmi(&m, 0)),
m.SmiConstant(12)));
CSA_ASSERT(&m, m.TaggedEqual(arguments.AtIndex(NonConstantSmi(&m, 1)),
m.SmiConstant(13)));
CSA_ASSERT(&m, m.TaggedEqual(arguments.AtIndex(NonConstantSmi(&m, 2)),
m.SmiConstant(14)));
arguments.PopAndReturn(arguments.GetReceiver());
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
Handle<Object> result = ft.Call(isolate->factory()->undefined_value(),
Handle<Smi>(Smi::FromInt(12), isolate),
Handle<Smi>(Smi::FromInt(13), isolate),
Handle<Smi>(Smi::FromInt(14), isolate))
.ToHandleChecked();
CHECK_EQ(*isolate->factory()->undefined_value(), *result);
}
TEST(ArgumentsForEach) {
Isolate* isolate(CcTest::InitIsolateOnce());
......
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