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

Side by Side Diff: src/assembler.cpp

Issue 700263003: Rearrange emit vs emitIAS. Wait till function is done before dumping text. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 6 years, 1 month 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
1 //===- subzero/src/assembler.cpp - Assembler base class -------------------===// 1 //===- subzero/src/assembler.cpp - Assembler base class -------------------===//
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
11 // 11 //
12 // This file is distributed under the University of Illinois Open Source 12 // This file is distributed under the University of Illinois Open Source
13 // License. See LICENSE.TXT for details. 13 // License. See LICENSE.TXT for details.
14 // 14 //
15 //===----------------------------------------------------------------------===// 15 //===----------------------------------------------------------------------===//
16 // 16 //
17 // This file implements the Assembler class. 17 // This file implements the Assembler class.
18 // 18 //
19 //===----------------------------------------------------------------------===// 19 //===----------------------------------------------------------------------===//
20 20
21 #include "assembler.h" 21 #include "assembler.h"
22 #include "IceGlobalContext.h"
22 #include "IceMemoryRegion.h" 23 #include "IceMemoryRegion.h"
24 #include "IceOperand.h"
23 25
24 namespace Ice { 26 namespace Ice {
25 27
26 static uintptr_t NewContents(Assembler &assembler, intptr_t capacity) { 28 static uintptr_t NewContents(Assembler &assembler, intptr_t capacity) {
27 uintptr_t result = assembler.AllocateBytes(capacity); 29 uintptr_t result = assembler.AllocateBytes(capacity);
28 return result; 30 return result;
29 } 31 }
30 32
31 #ifndef NDEBUG 33 #ifndef NDEBUG
32 AssemblerBuffer::EnsureCapacity::EnsureCapacity(AssemblerBuffer *buffer) { 34 AssemblerBuffer::EnsureCapacity::EnsureCapacity(AssemblerBuffer *buffer) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 128
127 // Update the cursor and recompute the limit. 129 // Update the cursor and recompute the limit.
128 cursor_ += delta; 130 cursor_ += delta;
129 limit_ = ComputeLimit(new_contents, new_capacity); 131 limit_ = ComputeLimit(new_contents, new_capacity);
130 132
131 // Verify internal state. 133 // Verify internal state.
132 assert(Capacity() == new_capacity); 134 assert(Capacity() == new_capacity);
133 assert(Size() == old_size); 135 assert(Size() == old_size);
134 } 136 }
135 137
138 void Assembler::emitIASBytes(GlobalContext *Ctx) const {
139 Ostream &Str = Ctx->getStrEmit();
140 intptr_t EndPosition = buffer_.Size();
141 intptr_t StartPosition = 0;
142 const intptr_t FixupSize = 4;
143 while (StartPosition < EndPosition) {
144 AssemblerFixup *LastFixup = buffer_.GetLatestFixup(StartPosition);
Jim Stichnoth 2014/11/06 00:02:13 The total work done in all the calls to GetLatestF
jvoung (off chromium) 2014/11/06 00:47:13 Ah right, I wasn't looking at how GetLatestFixup()
145 intptr_t LastFixupLoc = LastFixup ? LastFixup->position() : EndPosition;
146 for (intptr_t i = StartPosition; i < LastFixupLoc; ++i) {
147 Str << "\t.byte 0x";
148 Str.write_hex(buffer_.Load<uint8_t>(i));
149 Str << "\n";
150 }
151 if (LastFixup) {
152 Str << "\t.long ";
153 const ConstantRelocatable *Reloc = LastFixup->value();
154 bool IsPCRel = LastFixup->kind() == FK_PcRel_4;
155 if (Reloc->getSuppressMangling())
156 Str << Reloc->getName();
157 else
158 Str << Ctx->mangleName(Reloc->getName());
159 if (Reloc->getOffset()) {
160 Str << " + " << Reloc->getOffset();
161 }
162 if (IsPCRel)
163 Str << " - (. + " << FixupSize << ")";
164 Str << "\n";
165 LastFixupLoc += FixupSize;
166 assert(LastFixupLoc <= EndPosition);
167 }
168 // Continue another round, after the latest fixup.
169 StartPosition = LastFixupLoc;
170 }
171 }
172
136 } // end of namespace Ice 173 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698