OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef SANDBOX_LINUX_SECCOMP_BPF_CODEGEN_H__ | 5 #ifndef SANDBOX_LINUX_SECCOMP_BPF_CODEGEN_H__ |
6 #define SANDBOX_LINUX_SECCOMP_BPF_CODEGEN_H__ | 6 #define SANDBOX_LINUX_SECCOMP_BPF_CODEGEN_H__ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // logical beginning) of |program_|. | 99 // logical beginning) of |program_|. |
100 Node Append(uint16_t code, uint32_t k, size_t jt, size_t jf); | 100 Node Append(uint16_t code, uint32_t k, size_t jt, size_t jf); |
101 | 101 |
102 // Offset returns how many instructions exist in |program_| after |target|. | 102 // Offset returns how many instructions exist in |program_| after |target|. |
103 size_t Offset(Node target) const; | 103 size_t Offset(Node target) const; |
104 | 104 |
105 // NOTE: program_ is the compiled program in *reverse*, so that | 105 // NOTE: program_ is the compiled program in *reverse*, so that |
106 // indices remain stable as we add instructions. | 106 // indices remain stable as we add instructions. |
107 Program program_; | 107 Program program_; |
108 | 108 |
| 109 // equivalent_ stores the most recent semantically-equivalent node for each |
| 110 // instruction in program_. A node is defined as semantically-equivalent to N |
| 111 // if it has the same instruction code and constant as N and its successor |
| 112 // nodes (if any) are semantically-equivalent to N's successor nodes, or |
| 113 // if it's an unconditional jump to a node semantically-equivalent to N. |
| 114 std::vector<Node> equivalent_; |
| 115 |
109 std::map<MemoKey, Node, MemoKeyLess> memos_; | 116 std::map<MemoKey, Node, MemoKeyLess> memos_; |
110 | 117 |
111 DISALLOW_COPY_AND_ASSIGN(CodeGen); | 118 DISALLOW_COPY_AND_ASSIGN(CodeGen); |
112 }; | 119 }; |
113 | 120 |
114 } // namespace sandbox | 121 } // namespace sandbox |
115 | 122 |
116 #endif // SANDBOX_LINUX_SECCOMP_BPF_CODEGEN_H__ | 123 #endif // SANDBOX_LINUX_SECCOMP_BPF_CODEGEN_H__ |
OLD | NEW |