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

Side by Side Diff: src/interpreter/bytecode-peephole-table.h

Issue 2118183002: [interpeter] Move to table based peephole optimizer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase and back out patch set 21. 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef V8_INTERPRETER_BYTECODE_PEEPHOLE_TABLE_H_
6 #define V8_INTERPRETER_BYTECODE_PEEPHOLE_TABLE_H_
7
8 #include "src/interpreter/bytecodes.h"
9
10 namespace v8 {
11 namespace internal {
12 namespace interpreter {
13
14 #define PEEPHOLE_NON_JUMP_ACTION_LIST(V) \
15 V(DefaultAction) \
16 V(UpdateLastAction) \
17 V(ElideCurrentAction) \
18 V(ElideCurrentIfOperand0MatchesAction) \
19 V(ElideCurrentIfLoadingNameConstantAction) \
20 V(ElideLastAction) \
21 V(ChangeBytecodeAction) \
22 V(TransformLdaStarToLdrLdarAction) \
23 V(TransformLdaSmiBinaryOpToBinaryOpWithSmiAction) \
24 V(TransformLdaZeroBinaryOpToBinaryOpWithZeroAction)
25
26 #define PEEPHOLE_JUMP_ACTION_LIST(V) \
27 V(DefaultJumpAction) \
28 V(UpdateLastJumpAction) \
29 V(ChangeJumpBytecodeAction) \
30 V(ElideLastBeforeJumpAction)
31
32 #define PEEPHOLE_ACTION_LIST(V) \
33 PEEPHOLE_NON_JUMP_ACTION_LIST(V) \
34 PEEPHOLE_JUMP_ACTION_LIST(V)
35
36 // Actions to take when a pair of bytes is encountered. A handler
37 // exists for each action.
38 enum class PeepholeAction : uint8_t {
39 #define DECLARE_PEEPHOLE_ACTION(Action) k##Action,
40 PEEPHOLE_ACTION_LIST(DECLARE_PEEPHOLE_ACTION)
41 #undef DECLARE_PEEPHOLE_ACTION
42 };
43
44 // Tuple of action to take when pair of bytecodes is encountered and
45 // optional data to invoke handler with.
46 struct PeepholeActionAndData final {
47 // Action to take when tuple of bytecodes encountered.
48 PeepholeAction action;
49
50 // Replacement bytecode (if valid).
51 Bytecode bytecode;
52 };
53
54 // Lookup table for matching pairs of bytecodes to peephole optimization
55 // actions. The contents of the table are generated by mkpeephole.cc.
56 struct PeepholeActionTable final {
57 public:
58 static const PeepholeActionAndData* Lookup(Bytecode last, Bytecode current);
59
60 private:
61 static const size_t kNumberOfBytecodes =
62 static_cast<size_t>(Bytecode::kLast) + 1;
63
64 static const PeepholeActionAndData row_data_[][kNumberOfBytecodes];
65 static const PeepholeActionAndData* const row_[kNumberOfBytecodes];
66 };
67
68 } // namespace interpreter
69 } // namespace internal
70 } // namespace v8
71
72 #endif // V8_INTERPRETER_BYTECODE_PEEPHOLE_TABLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698