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

Unified Diff: src/code-stub-assembler.cc

Issue 2469273003: [stubs] Add a utility class to generate code to access builtin arguments (Closed)
Patch Set: Review feedback Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/code-stub-assembler.h ('k') | src/compiler/frame-elider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stub-assembler.cc
diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc
index 170ad235e316f3f21141e296282c5252e47e402a..7ef2016809fb8db0516b882eff1eed8899b2c273 100644
--- a/src/code-stub-assembler.cc
+++ b/src/code-stub-assembler.cc
@@ -8756,5 +8756,76 @@ compiler::Node* CodeStubAssembler::IsDetachedBuffer(compiler::Node* buffer) {
Int32Constant(0));
}
+CodeStubArguments::CodeStubArguments(CodeStubAssembler* assembler,
+ compiler::Node* argc,
+ CodeStubAssembler::ParameterMode mode)
+ : assembler_(assembler),
+ argc_(argc),
+ arguments_(nullptr),
+ fp_(assembler->LoadFramePointer()) {
+ compiler::Node* offset = assembler->ElementOffsetFromIndex(
+ argc_, FAST_ELEMENTS, mode,
+ (StandardFrameConstants::kFixedSlotCountAboveFp - 1) * kPointerSize);
+ arguments_ = assembler_->IntPtrAddFoldConstants(fp_, offset);
+ if (mode == CodeStubAssembler::INTEGER_PARAMETERS) {
+ argc_ = assembler->ChangeInt32ToIntPtr(argc_);
+ } else if (mode == CodeStubAssembler::SMI_PARAMETERS) {
+ argc_ = assembler->SmiUntag(argc_);
+ }
+}
+
+compiler::Node* CodeStubArguments::GetReceiver() {
+ return assembler_->Load(MachineType::AnyTagged(), arguments_,
+ assembler_->IntPtrConstant(kPointerSize));
+}
+
+compiler::Node* CodeStubArguments::AtIndex(
+ compiler::Node* index, CodeStubAssembler::ParameterMode mode) {
+ typedef compiler::Node Node;
+ Node* negated_index = assembler_->IntPtrSubFoldConstants(
+ assembler_->IntPtrOrSmiConstant(0, mode), index);
+ Node* offset =
+ assembler_->ElementOffsetFromIndex(negated_index, FAST_ELEMENTS, mode, 0);
+ return assembler_->Load(MachineType::AnyTagged(), arguments_, offset);
+}
+
+compiler::Node* CodeStubArguments::AtIndex(int index) {
+ return AtIndex(assembler_->IntPtrConstant(index));
+}
+
+void CodeStubArguments::ForEach(const CodeStubAssembler::VariableList& vars,
+ CodeStubArguments::ForEachBodyFunction body,
+ compiler::Node* first, compiler::Node* last,
+ CodeStubAssembler::ParameterMode mode) {
+ assembler_->Comment("CodeStubArguments::ForEach");
+ DCHECK_IMPLIES(first == nullptr || last == nullptr,
+ mode == CodeStubAssembler::INTPTR_PARAMETERS);
+ if (first == nullptr) {
+ first = assembler_->IntPtrOrSmiConstant(0, mode);
+ }
+ if (last == nullptr) {
+ last = argc_;
+ }
+ compiler::Node* start = assembler_->IntPtrSubFoldConstants(
+ arguments_,
+ assembler_->ElementOffsetFromIndex(first, FAST_ELEMENTS, mode));
+ compiler::Node* end = assembler_->IntPtrSubFoldConstants(
+ arguments_,
+ assembler_->ElementOffsetFromIndex(last, FAST_ELEMENTS, mode));
+ assembler_->BuildFastLoop(
+ vars, MachineType::PointerRepresentation(), start, end,
+ [body](CodeStubAssembler* assembler, compiler::Node* current) {
+ Node* arg = assembler->Load(MachineType::AnyTagged(), current);
+ body(assembler, arg);
+ },
+ -kPointerSize, CodeStubAssembler::IndexAdvanceMode::kPost);
+}
+
+void CodeStubArguments::PopAndReturn(compiler::Node* value) {
+ assembler_->PopAndReturn(
+ assembler_->IntPtrAddFoldConstants(argc_, assembler_->IntPtrConstant(1)),
+ value);
+}
+
} // namespace internal
} // namespace v8
« no previous file with comments | « src/code-stub-assembler.h ('k') | src/compiler/frame-elider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698