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

Side by Side Diff: courgette/assembly_program.h

Issue 1629703002: [Courgette] Refactor: Manage AssemblyProgram and EncodedProgram with scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix courgette_fuzzer in libfuzzer. Created 4 years, 10 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
« no previous file with comments | « courgette/adjustment_method_unittest.cc ('k') | courgette/assembly_program.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 COURGETTE_ASSEMBLY_PROGRAM_H_ 5 #ifndef COURGETTE_ASSEMBLY_PROGRAM_H_
6 #define COURGETTE_ASSEMBLY_PROGRAM_H_ 6 #define COURGETTE_ASSEMBLY_PROGRAM_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <map> 11 #include <map>
12 #include <set> 12 #include <set>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "courgette/disassembler.h" 17 #include "courgette/courgette.h"
18 #include "courgette/image_utils.h" 18 #include "courgette/image_utils.h"
19 #include "courgette/label_manager.h" 19 #include "courgette/label_manager.h"
20 #include "courgette/memory_allocator.h" 20 #include "courgette/memory_allocator.h"
21 21
22 namespace courgette { 22 namespace courgette {
23 23
24 class EncodedProgram; 24 class EncodedProgram;
25 25
26 // Opcodes of simple assembly language 26 // Opcodes of simple assembly language
27 enum OP { 27 enum OP {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // Looks up a label or creates a new one. Might return NULL. 125 // Looks up a label or creates a new one. Might return NULL.
126 Label* FindOrMakeAbs32Label(RVA rva); 126 Label* FindOrMakeAbs32Label(RVA rva);
127 127
128 // Looks up a label or creates a new one. Might return NULL. 128 // Looks up a label or creates a new one. Might return NULL.
129 Label* FindOrMakeRel32Label(RVA rva); 129 Label* FindOrMakeRel32Label(RVA rva);
130 130
131 void DefaultAssignIndexes(); 131 void DefaultAssignIndexes();
132 void UnassignIndexes(); 132 void UnassignIndexes();
133 void AssignRemainingIndexes(); 133 void AssignRemainingIndexes();
134 134
135 EncodedProgram* Encode() const; 135 scoped_ptr<EncodedProgram> Encode() const;
136 136
137 // Accessor for instruction list. 137 // Accessor for instruction list.
138 const InstructionVector& instructions() const { 138 const InstructionVector& instructions() const {
139 return instructions_; 139 return instructions_;
140 } 140 }
141 141
142 // Returns the label if the instruction contains an absolute 32-bit address, 142 // Returns the label if the instruction contains an absolute 32-bit address,
143 // otherwise returns NULL. 143 // otherwise returns NULL.
144 Label* InstructionAbs32Label(const Instruction* instruction) const; 144 Label* InstructionAbs32Label(const Instruction* instruction) const;
145 145
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 184
185 // These are lookup maps to find the label associated with a given address. 185 // These are lookup maps to find the label associated with a given address.
186 // We have separate label spaces for addresses referenced by rel32 labels and 186 // We have separate label spaces for addresses referenced by rel32 labels and
187 // abs32 labels. This is somewhat arbitrary. 187 // abs32 labels. This is somewhat arbitrary.
188 RVAToLabel rel32_labels_; 188 RVAToLabel rel32_labels_;
189 RVAToLabel abs32_labels_; 189 RVAToLabel abs32_labels_;
190 190
191 DISALLOW_COPY_AND_ASSIGN(AssemblyProgram); 191 DISALLOW_COPY_AND_ASSIGN(AssemblyProgram);
192 }; 192 };
193 193
194 // Converts |program| into encoded form, returning it as |*output|.
195 // Returns C_OK if succeeded, otherwise returns an error status and sets
196 // |*output| to null.
197 Status Encode(const AssemblyProgram& program,
198 scoped_ptr<EncodedProgram>* output);
199
194 } // namespace courgette 200 } // namespace courgette
201
195 #endif // COURGETTE_ASSEMBLY_PROGRAM_H_ 202 #endif // COURGETTE_ASSEMBLY_PROGRAM_H_
OLDNEW
« no previous file with comments | « courgette/adjustment_method_unittest.cc ('k') | courgette/assembly_program.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698