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

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

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 | « no previous file | src/code-stub-assembler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stub-assembler.h
diff --git a/src/code-stub-assembler.h b/src/code-stub-assembler.h
index 7821d35a419c5a758cc63d30ef4eab6f9e9b4e0b..36e7801bdd188c082a16e0a29e594835e56a8741 100644
--- a/src/code-stub-assembler.h
+++ b/src/code-stub-assembler.h
@@ -1108,6 +1108,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
compiler::Node* IsDetachedBuffer(compiler::Node* buffer);
private:
+ friend class CodeStubArguments;
+
enum ElementSupport { kOnlyProperties, kSupportElements };
void DescriptorLookupLinear(compiler::Node* unique_name,
@@ -1208,6 +1210,53 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
static const int kElementLoopUnrollThreshold = 8;
};
+class CodeStubArguments {
+ public:
+ // |argc| specifies the number of arguments passed to the builtin excluding
+ // the receiver.
+ CodeStubArguments(CodeStubAssembler* assembler, compiler::Node* argc,
+ CodeStubAssembler::ParameterMode mode =
+ CodeStubAssembler::INTPTR_PARAMETERS);
+
+ compiler::Node* GetReceiver();
+
+ // |index| is zero-based and does not include the receiver
+ compiler::Node* AtIndex(compiler::Node* index,
+ CodeStubAssembler::ParameterMode mode =
+ CodeStubAssembler::INTPTR_PARAMETERS);
+
+ compiler::Node* AtIndex(int index);
+
+ typedef std::function<void(CodeStubAssembler* assembler, compiler::Node* arg)>
+ ForEachBodyFunction;
+
+ // Iteration doesn't include the receiver. |first| and |last| are zero-based.
+ void ForEach(ForEachBodyFunction body, compiler::Node* first = nullptr,
+ compiler::Node* last = nullptr,
+ CodeStubAssembler::ParameterMode mode =
+ CodeStubAssembler::INTPTR_PARAMETERS) {
+ 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,
+ ForEachBodyFunction body, compiler::Node* first = nullptr,
+ compiler::Node* last = nullptr,
+ CodeStubAssembler::ParameterMode mode =
+ CodeStubAssembler::INTPTR_PARAMETERS);
+
+ void PopAndReturn(compiler::Node* value);
+
+ private:
+ compiler::Node* GetArguments();
+
+ CodeStubAssembler* assembler_;
+ compiler::Node* argc_;
+ compiler::Node* arguments_;
+ compiler::Node* fp_;
+};
+
#define CSA_ASSERT(x) Assert((x), #x, __FILE__, __LINE__)
#ifdef ENABLE_SLOW_DCHECKS
#define CSA_SLOW_ASSERT(x) \
« no previous file with comments | « no previous file | src/code-stub-assembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698