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

Side by Side Diff: src/IceAssembler.h

Issue 1177843006: Fixes a bug in that caused IceAssembler to use Allocator before it was initialized. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years, 6 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceAssembler.h - Integrated assembler --------*- C++ -*-===// 1 //===- subzero/src/IceAssembler.h - Integrated assembler --------*- C++ -*-===//
2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
3 // for details. All rights reserved. Use of this source code is governed by a 3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file. 4 // BSD-style license that can be found in the LICENSE file.
5 // 5 //
6 // Modified by the Subzero authors. 6 // Modified by the Subzero authors.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // The Subzero Code Generator 10 // The Subzero Code Generator
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 149
150 void extendCapacity(); 150 void extendCapacity();
151 }; 151 };
152 152
153 class Assembler { 153 class Assembler {
154 Assembler(const Assembler &) = delete; 154 Assembler(const Assembler &) = delete;
155 Assembler &operator=(const Assembler &) = delete; 155 Assembler &operator=(const Assembler &) = delete;
156 156
157 public: 157 public:
158 Assembler() 158 Assembler()
159 : Buffer(*this), FunctionName(""), IsInternal(false), 159 : Allocator(), FunctionName(""), IsInternal(false), Preliminary(false),
160 Preliminary(false) {} 160 Buffer(*this) {}
161 virtual ~Assembler() = default; 161 virtual ~Assembler() = default;
162 162
163 // Allocate a chunk of bytes using the per-Assembler allocator. 163 // Allocate a chunk of bytes using the per-Assembler allocator.
164 uintptr_t allocateBytes(size_t bytes) { 164 uintptr_t allocateBytes(size_t bytes) {
165 // For now, alignment is not related to NaCl bundle alignment, since 165 // For now, alignment is not related to NaCl bundle alignment, since
166 // the buffer's GetPosition is relative to the base. So NaCl bundle 166 // the buffer's GetPosition is relative to the base. So NaCl bundle
167 // alignment checks can be relative to that base. Later, the buffer 167 // alignment checks can be relative to that base. Later, the buffer
168 // will be copied out to a ".text" section (or an in memory-buffer 168 // will be copied out to a ".text" section (or an in memory-buffer
169 // that can be mprotect'ed with executable permission), and that 169 // that can be mprotect'ed with executable permission), and that
170 // second buffer should be aligned for NaCl. 170 // second buffer should be aligned for NaCl.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 bool getInternal() const { return IsInternal; } 205 bool getInternal() const { return IsInternal; }
206 void setInternal(bool Internal) { IsInternal = Internal; } 206 void setInternal(bool Internal) { IsInternal = Internal; }
207 const IceString &getFunctionName() { return FunctionName; } 207 const IceString &getFunctionName() { return FunctionName; }
208 void setFunctionName(const IceString &NewName) { FunctionName = NewName; } 208 void setFunctionName(const IceString &NewName) { FunctionName = NewName; }
209 intptr_t getBufferSize() const { return Buffer.size(); } 209 intptr_t getBufferSize() const { return Buffer.size(); }
210 // Roll back to a (smaller) size. 210 // Roll back to a (smaller) size.
211 void setBufferSize(intptr_t NewSize) { Buffer.setSize(NewSize); } 211 void setBufferSize(intptr_t NewSize) { Buffer.setSize(NewSize); }
212 void setPreliminary(bool Value) { Preliminary = Value; } 212 void setPreliminary(bool Value) { Preliminary = Value; }
213 bool getPreliminary() const { return Preliminary; } 213 bool getPreliminary() const { return Preliminary; }
214 214
215 protected:
216 AssemblerBuffer Buffer;
217
218 private: 215 private:
219 ArenaAllocator<32 * 1024> Allocator; 216 ArenaAllocator<32 * 1024> Allocator;
220 // FunctionName and IsInternal are transferred from the original Cfg 217 // FunctionName and IsInternal are transferred from the original Cfg
221 // object, since the Cfg object may be deleted by the time the 218 // object, since the Cfg object may be deleted by the time the
222 // assembler buffer is emitted. 219 // assembler buffer is emitted.
223 IceString FunctionName; 220 IceString FunctionName;
224 bool IsInternal; 221 bool IsInternal;
225 // Preliminary indicates whether a preliminary pass is being made 222 // Preliminary indicates whether a preliminary pass is being made
226 // for calculating bundle padding (Preliminary=true), versus the 223 // for calculating bundle padding (Preliminary=true), versus the
227 // final pass where all changes to label bindings, label links, and 224 // final pass where all changes to label bindings, label links, and
228 // relocation fixups are fully committed (Preliminary=false). 225 // relocation fixups are fully committed (Preliminary=false).
229 bool Preliminary; 226 bool Preliminary;
227
228 protected:
229 // Buffer's constructor uses the Allocator, so it needs to appear after it.
230 // TODO(jpp): dependencies on construction order are a nice way of shooting
231 // yourself in the foot. Fix this.
232 AssemblerBuffer Buffer;
230 }; 233 };
231 234
232 } // end of namespace Ice 235 } // end of namespace Ice
233 236
234 #endif // SUBZERO_SRC_ICEASSEMBLER_H_ 237 #endif // SUBZERO_SRC_ICEASSEMBLER_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698