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

Side by Side Diff: courgette/assembly_program.cc

Issue 149597: Code changes to get the code to compile under GCC.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « courgette/adjustment_method_2.cc ('k') | courgette/courgette.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Name: svn:eol-style
+ LF
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include "courgette/assembly_program.h" 5 #include "courgette/assembly_program.h"
6 6
7 #include <memory.h> 7 #include <memory.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 if (label == NULL) NOTREACHED(); 78 if (label == NULL) NOTREACHED();
79 } 79 }
80 Label* label() const { return label_; } 80 Label* label() const { return label_; }
81 private: 81 private:
82 Label* label_; 82 Label* label_;
83 }; 83 };
84 84
85 } // namespace 85 } // namespace
86 86
87 AssemblyProgram::AssemblyProgram() 87 AssemblyProgram::AssemblyProgram()
88 : image_base_(0), 88 : byte_instruction_cache_(NULL),
89 byte_instruction_cache_(NULL) { 89 image_base_(0) {
90 } 90 }
91 91
92 static void DeleteContainedLabels(const RVAToLabel& labels) { 92 static void DeleteContainedLabels(const RVAToLabel& labels) {
93 for (RVAToLabel::const_iterator p = labels.begin(); p != labels.end(); ++p) 93 for (RVAToLabel::const_iterator p = labels.begin(); p != labels.end(); ++p)
94 delete p->second; 94 delete p->second;
95 } 95 }
96 96
97 AssemblyProgram::~AssemblyProgram() { 97 AssemblyProgram::~AssemblyProgram() {
98 for (size_t i = 0; i < instructions_.size(); ++i) { 98 for (size_t i = 0; i < instructions_.size(); ++i) {
99 Instruction* instruction = instructions_[i]; 99 Instruction* instruction = instructions_[i];
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 // An address table compresses best when each index is associated with an 202 // An address table compresses best when each index is associated with an
203 // address that is slight larger than the previous index. 203 // address that is slight larger than the previous index.
204 204
205 // First see which indexes have not been used. The 'available' vector could 205 // First see which indexes have not been used. The 'available' vector could
206 // grow even bigger, but the number of addresses is a better starting size 206 // grow even bigger, but the number of addresses is a better starting size
207 // than empty. 207 // than empty.
208 std::vector<bool> available(labels->size(), true); 208 std::vector<bool> available(labels->size(), true);
209 int used = 0; 209 int used = 0;
210 210
211 for (RVAToLabel::iterator p = labels->begin(); p != labels->end(); ++p) { 211 for (RVAToLabel::iterator p = labels->begin(); p != labels->end(); ++p) {
212 size_t index = p->second->index_; 212 int index = p->second->index_;
213 if (index != Label::kNoIndex) { 213 if (index != Label::kNoIndex) {
214 while (index >= available.size()) 214 while (static_cast<size_t>(index) >= available.size())
215 available.push_back(true); 215 available.push_back(true);
216 available.at(index) = false; 216 available.at(index) = false;
217 ++used; 217 ++used;
218 } 218 }
219 } 219 }
220 220
221 LOG(INFO) << used << " of " << labels->size() << " labels pre-assigned"; 221 LOG(INFO) << used << " of " << labels->size() << " labels pre-assigned";
222 222
223 // Are there any unused labels that happen to be adjacent following a used 223 // Are there any unused labels that happen to be adjacent following a used
224 // label? 224 // label?
(...skipping 12 matching lines...) Expand all
237 ++fill_forward_count; 237 ++fill_forward_count;
238 } 238 }
239 } 239 }
240 prev = current; 240 prev = current;
241 } 241 }
242 242
243 // Are there any unused labels that happen to be adjacent preceeding a used 243 // Are there any unused labels that happen to be adjacent preceeding a used
244 // label? 244 // label?
245 // 245 //
246 int fill_backward_count = 0; 246 int fill_backward_count = 0;
247 int backward_refs = 0;
248 prev = 0; 247 prev = 0;
249 for (RVAToLabel::reverse_iterator p = labels->rbegin(); 248 for (RVAToLabel::reverse_iterator p = labels->rbegin();
250 p != labels->rend(); 249 p != labels->rend();
251 ++p) { 250 ++p) {
252 Label* current = p->second; 251 Label* current = p->second;
253 if (current->index_ == Label::kNoIndex) { 252 if (current->index_ == Label::kNoIndex) {
254 int prev_index; 253 int prev_index;
255 if (prev) 254 if (prev)
256 prev_index = prev->index_; 255 prev_index = prev->index_;
257 else 256 else
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 EncodedProgram *encoded = program->Encode(); 362 EncodedProgram *encoded = program->Encode();
364 if (encoded) { 363 if (encoded) {
365 *output = encoded; 364 *output = encoded;
366 return C_OK; 365 return C_OK;
367 } else { 366 } else {
368 return C_GENERAL_ERROR; 367 return C_GENERAL_ERROR;
369 } 368 }
370 } 369 }
371 370
372 } // namespace courgette 371 } // namespace courgette
OLDNEW
« no previous file with comments | « courgette/adjustment_method_2.cc ('k') | courgette/courgette.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698