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

Unified Diff: src/interpreter/bytecode-peephole-table.h

Issue 2164583002: Reland "[interpeter] Move to table based peephole optimizer." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Nit. Created 4 years, 5 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
« no previous file with comments | « src/interpreter/bytecode-peephole-optimizer.cc ('k') | src/interpreter/bytecodes.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/bytecode-peephole-table.h
diff --git a/src/interpreter/bytecode-peephole-table.h b/src/interpreter/bytecode-peephole-table.h
new file mode 100644
index 0000000000000000000000000000000000000000..7c0059e8cc3d9d387cf507fe22967432acb90826
--- /dev/null
+++ b/src/interpreter/bytecode-peephole-table.h
@@ -0,0 +1,73 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_INTERPRETER_BYTECODE_PEEPHOLE_TABLE_H_
+#define V8_INTERPRETER_BYTECODE_PEEPHOLE_TABLE_H_
+
+#include "src/interpreter/bytecodes.h"
+
+namespace v8 {
+namespace internal {
+namespace interpreter {
+
+#define PEEPHOLE_NON_JUMP_ACTION_LIST(V) \
+ V(DefaultAction) \
+ V(UpdateLastAction) \
+ V(UpdateLastIfSourceInfoPresentAction) \
+ V(ElideCurrentAction) \
+ V(ElideCurrentIfOperand0MatchesAction) \
+ V(ElideCurrentIfLoadingNameConstantAction) \
+ V(ElideLastAction) \
+ V(ChangeBytecodeAction) \
+ V(TransformLdaStarToLdrLdarAction) \
+ V(TransformLdaSmiBinaryOpToBinaryOpWithSmiAction) \
+ V(TransformLdaZeroBinaryOpToBinaryOpWithZeroAction)
+
+#define PEEPHOLE_JUMP_ACTION_LIST(V) \
+ V(DefaultJumpAction) \
+ V(UpdateLastJumpAction) \
+ V(ChangeJumpBytecodeAction) \
+ V(ElideLastBeforeJumpAction)
+
+#define PEEPHOLE_ACTION_LIST(V) \
+ PEEPHOLE_NON_JUMP_ACTION_LIST(V) \
+ PEEPHOLE_JUMP_ACTION_LIST(V)
+
+// Actions to take when a pair of bytes is encountered. A handler
+// exists for each action.
+enum class PeepholeAction : uint8_t {
+#define DECLARE_PEEPHOLE_ACTION(Action) k##Action,
+ PEEPHOLE_ACTION_LIST(DECLARE_PEEPHOLE_ACTION)
+#undef DECLARE_PEEPHOLE_ACTION
+};
+
+// Tuple of action to take when pair of bytecodes is encountered and
+// optional data to invoke handler with.
+struct PeepholeActionAndData final {
+ // Action to take when tuple of bytecodes encountered.
+ PeepholeAction action;
+
+ // Replacement bytecode (if valid).
+ Bytecode bytecode;
+};
+
+// Lookup table for matching pairs of bytecodes to peephole optimization
+// actions. The contents of the table are generated by mkpeephole.cc.
+struct PeepholeActionTable final {
+ public:
+ static const PeepholeActionAndData* Lookup(Bytecode last, Bytecode current);
+
+ private:
+ static const size_t kNumberOfBytecodes =
+ static_cast<size_t>(Bytecode::kLast) + 1;
+
+ static const PeepholeActionAndData row_data_[][kNumberOfBytecodes];
+ static const PeepholeActionAndData* const row_[kNumberOfBytecodes];
+};
+
+} // namespace interpreter
+} // namespace internal
+} // namespace v8
+
+#endif // V8_INTERPRETER_BYTECODE_PEEPHOLE_TABLE_H_
« no previous file with comments | « src/interpreter/bytecode-peephole-optimizer.cc ('k') | src/interpreter/bytecodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698