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

Side by Side Diff: courgette/assembly_program.cc

Issue 2771753004: [Courgette] Refactor: Unify Disassembler::Disassemble() and instantiate AssemblyProgram there. (Closed)
Patch Set: Fix signed/unsigned comparison issue in test. Created 3 years, 9 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/assembly_program.h ('k') | courgette/disassembler.h » ('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 #include "courgette/assembly_program.h" 5 #include "courgette/assembly_program.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "courgette/courgette.h" 9 #include "courgette/courgette.h"
10 #include "courgette/encoded_program.h" 10 #include "courgette/encoded_program.h"
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 it->second.Run( 302 it->second.Run(
303 static_cast<const InstructionWithLabel*>(instruction)->label()); 303 static_cast<const InstructionWithLabel*>(instruction)->label());
304 } 304 }
305 } 305 }
306 } 306 }
307 307
308 CheckBool AssemblyProgram::GenerateInstructions( 308 CheckBool AssemblyProgram::GenerateInstructions(
309 const InstructionGenerator& gen) { 309 const InstructionGenerator& gen) {
310 // Pass 1: Count the space needed to store instructions. 310 // Pass 1: Count the space needed to store instructions.
311 InstructionCountReceptor count_receptor; 311 InstructionCountReceptor count_receptor;
312 if (!gen.Run(this, &count_receptor)) 312 if (!gen.Run(&count_receptor))
313 return false; 313 return false;
314 314
315 // Pass 2: Emit all instructions to preallocated buffer (uses Phase 1 count). 315 // Pass 2: Emit all instructions to preallocated buffer (uses Phase 1 count).
316 InstructionStoreReceptor store_receptor(this); 316 InstructionStoreReceptor store_receptor(this);
317 // TODO(huangs): 2016/11: Pass |count_receptor_->size()| to |store_receptor_| 317 // TODO(huangs): 2017/03: Pass |count_receptor->size()| to |store_receptor_|
318 // to reserve space for raw data. 318 // to reserve space for raw data.
319 return gen.Run(this, &store_receptor); 319 return gen.Run(&store_receptor);
320 } 320 }
321 321
322 CheckBool AssemblyProgram::Emit(ScopedInstruction instruction) { 322 CheckBool AssemblyProgram::Emit(ScopedInstruction instruction) {
323 if (!instruction || !instructions_.push_back(instruction.get())) 323 if (!instruction || !instructions_.push_back(instruction.get()))
324 return false; 324 return false;
325 // Ownership successfully passed to instructions_. 325 // Ownership successfully passed to instructions_.
326 ignore_result(instruction.release()); 326 ignore_result(instruction.release());
327 return true; 327 return true;
328 } 328 }
329 329
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 Status Encode(const AssemblyProgram& program, 445 Status Encode(const AssemblyProgram& program,
446 std::unique_ptr<EncodedProgram>* output) { 446 std::unique_ptr<EncodedProgram>* output) {
447 // Explicitly release any memory associated with the output before encoding. 447 // Explicitly release any memory associated with the output before encoding.
448 output->reset(); 448 output->reset();
449 449
450 *output = program.Encode(); 450 *output = program.Encode();
451 return (*output) ? C_OK : C_GENERAL_ERROR; 451 return (*output) ? C_OK : C_GENERAL_ERROR;
452 } 452 }
453 453
454 } // namespace courgette 454 } // namespace courgette
OLDNEW
« no previous file with comments | « courgette/assembly_program.h ('k') | courgette/disassembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698