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

Unified Diff: src/compiler/common-operator.cc

Issue 1391333003: Adding support for multiple returns in compiled functions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: formatting Created 5 years, 2 months 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
Index: src/compiler/common-operator.cc
diff --git a/src/compiler/common-operator.cc b/src/compiler/common-operator.cc
index bacaae980f918eddf24abbca60e2f16657a6a499..ca22bcbcf037d92ebdd1bef38b85c86c300eebcf 100644
--- a/src/compiler/common-operator.cc
+++ b/src/compiler/common-operator.cc
@@ -123,12 +123,17 @@ std::ostream& operator<<(std::ostream& os, ParameterInfo const& i) {
V(IfDefault, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \
V(Throw, Operator::kKontrol, 1, 1, 1, 0, 0, 1) \
V(Deoptimize, Operator::kNoThrow, 1, 1, 1, 0, 0, 1) \
- V(Return, Operator::kNoThrow, 1, 1, 1, 0, 0, 1) \
V(Terminate, Operator::kKontrol, 0, 1, 1, 0, 0, 1) \
V(OsrNormalEntry, Operator::kFoldable, 0, 1, 1, 0, 1, 1) \
V(OsrLoopEntry, Operator::kFoldable, 0, 1, 1, 0, 1, 1)
+#define CACHED_RETURN_LIST(V) \
+ V(1) \
+ V(2) \
+ V(3)
+
+
#define CACHED_END_LIST(V) \
V(1) \
V(2) \
@@ -249,6 +254,19 @@ struct CommonOperatorGlobalCache final {
CACHED_END_LIST(CACHED_END)
#undef CACHED_END
+ template <size_t kInputCount>
+ struct ReturnOperator final : public Operator {
+ ReturnOperator()
+ : Operator( // --
+ IrOpcode::kReturn, Operator::kNoThrow, // opcode
+ "Return", // name
+ kInputCount, 1, 1, 0, 0, 1) {} // counts
+ };
+#define CACHED_RETURN(input_count) \
+ ReturnOperator<input_count> kReturn##input_count##Operator;
+ CACHED_RETURN_LIST(CACHED_RETURN)
+#undef CACHED_RETURN
+
template <BranchHint kBranchHint>
struct BranchOperator final : public Operator1<BranchHint> {
BranchOperator()
@@ -397,6 +415,24 @@ const Operator* CommonOperatorBuilder::End(size_t control_input_count) {
}
+const Operator* CommonOperatorBuilder::Return(int value_input_count) {
+ switch (value_input_count) {
+#define CACHED_RETURN(input_count) \
+ case input_count: \
+ return &cache_.kReturn##input_count##Operator;
+ CACHED_RETURN_LIST(CACHED_RETURN)
+#undef CACHED_RETURN
+ default:
+ break;
+ }
+ // Uncached.
+ return new (zone()) Operator( //--
+ IrOpcode::kReturn, Operator::kNoThrow, // opcode
+ "Return", // name
+ value_input_count, 1, 1, 0, 0, 1); // counts
+}
+
+
const Operator* CommonOperatorBuilder::Branch(BranchHint hint) {
switch (hint) {
case BranchHint::kNone:

Powered by Google App Engine
This is Rietveld 408576698