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

Issue 2462993003: [Courgette] Refactor: Add and use Instruction*Receptor classes; call ParseFile() in 2 passes. (Closed)

Created:
4 years, 1 month ago by huangs
Modified:
4 years, 1 month ago
CC:
chromium-reviews, wfh+watch_chromium.org, huangs+watch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

[Courgette] Refactor: Add and use Instruction*Receptor classes; call ParseFile() in 2 passes. We wish to reduce AssemblyProgram's memory usage on instruction storage. This requires changing Disassembler*::Disassemble() to call ParseFile() in 2 passes: (1) count bytes needed (so we can preallocate) (2) store bytes. This CL implements the 2-pass system, focusing on callers. Details: - Add AssemblyProgram::GenerateInstructions() as main entrance point from Disassembler*. It takes InstructionGenerator, which is just Disassembler*::ParseFile() wrapped in a Closure. - Change Disassembler*::ParseFile() and downstream functions to const, to assert absence of Disassembler state change for the passes. - Exception: For ELF, we need to stort abs32_locations_ and re32_locations_ to obtain different traversal orders. This doesn't add/remove elements. So we make these containers mutable. - Emit*() functions are moved from AssemblyProgram to new interface InstructionReceptor. Updating all Emit*() calls to accommodate. - Add InstructionReceptor interface with 2 implementations: - InstructionCountReceptor for pass 1 (no-op in this CL). - InstructionStoreReceptor for pass 2 (calls AssemblyProgram::Emit*() in this CL). - Rename Emit*Instruction() to Emit*(). TEST=Correctness without behavioral change; Courgette-gen and Courgette-apply are not slowed down, and do not use more memory. BUG=660980 Committed: https://crrev.com/7b221a5ec1175ffba9955aede222b9bdd4056183 Cr-Commit-Position: refs/heads/master@{#431053}

Patch Set 1 #

Patch Set 2 : Make AssemblyProgram::CreateInstruction*Receptor() return CheckBool. #

Total comments: 34

Patch Set 3 : Fix style and comments; lint; remove size param from InstructionStoreReceptor ctor. #

Total comments: 4

Patch Set 4 : Hide 2-pass from caller. #

Total comments: 4

Patch Set 5 : Fix comments. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+373 lines, -182 lines) Patch
M courgette/adjustment_method_unittest.cc View 1 2 3 6 chunks +49 lines, -35 lines 0 comments Download
M courgette/assembly_program.h View 1 2 3 4 4 chunks +95 lines, -39 lines 0 comments Download
M courgette/assembly_program.cc View 1 2 3 7 chunks +108 lines, -12 lines 0 comments Download
M courgette/disassembler_elf_32.h View 1 2 8 chunks +19 lines, -12 lines 0 comments Download
M courgette/disassembler_elf_32.cc View 1 2 3 12 chunks +27 lines, -24 lines 0 comments Download
M courgette/disassembler_elf_32_arm.h View 1 2 4 chunks +6 lines, -4 lines 0 comments Download
M courgette/disassembler_elf_32_arm.cc View 1 2 5 chunks +9 lines, -10 lines 0 comments Download
M courgette/disassembler_elf_32_x86.h View 1 2 4 chunks +6 lines, -4 lines 0 comments Download
M courgette/disassembler_elf_32_x86.cc View 3 chunks +6 lines, -6 lines 0 comments Download
M courgette/disassembler_win32.h View 1 2 3 chunks +13 lines, -8 lines 0 comments Download
M courgette/disassembler_win32.cc View 1 2 3 12 chunks +26 lines, -21 lines 0 comments Download
M courgette/disassembler_win32_x64.h View 2 chunks +3 lines, -2 lines 0 comments Download
M courgette/disassembler_win32_x64.cc View 1 chunk +2 lines, -2 lines 0 comments Download
M courgette/disassembler_win32_x86.h View 2 chunks +2 lines, -1 line 0 comments Download
M courgette/disassembler_win32_x86.cc View 1 chunk +2 lines, -2 lines 0 comments Download

Messages

Total messages: 32 (16 generated)
huangs
Phase 1, CL 2, per design doc I sent out earlier today. PTAL. Thanks!
4 years, 1 month ago (2016-10-31 22:53:46 UTC) #5
huangs
PTAL. Thanks!
4 years, 1 month ago (2016-11-03 13:35:01 UTC) #12
grt (UTC plus 2)
it's hard for me to comment on much of this since it doesn't seem to ...
4 years, 1 month ago (2016-11-04 09:38:54 UTC) #13
huangs
Updated, PTAL. https://codereview.chromium.org/2462993003/diff/20001/courgette/assembly_program.cc File courgette/assembly_program.cc (right): https://codereview.chromium.org/2462993003/diff/20001/courgette/assembly_program.cc#newcode122 courgette/assembly_program.cc:122: // TODO(huangs): Populate these with size_ += ...
4 years, 1 month ago (2016-11-04 18:20:40 UTC) #14
huangs
Preview of the next CL is here: https://codereview.chromium.org/2476863004 Right now it also contains this CL; ...
4 years, 1 month ago (2016-11-04 22:25:26 UTC) #15
grt (UTC plus 2)
https://codereview.chromium.org/2462993003/diff/20001/courgette/assembly_program.cc File courgette/assembly_program.cc (right): https://codereview.chromium.org/2462993003/diff/20001/courgette/assembly_program.cc#newcode173 courgette/assembly_program.cc:173: CHECK(program_ != nullptr); On 2016/11/04 18:20:39, huangs wrote: > ...
4 years, 1 month ago (2016-11-07 09:36:18 UTC) #16
huangs
Updated, PTAL. https://codereview.chromium.org/2462993003/diff/20001/courgette/assembly_program.cc File courgette/assembly_program.cc (right): https://codereview.chromium.org/2462993003/diff/20001/courgette/assembly_program.cc#newcode173 courgette/assembly_program.cc:173: CHECK(program_ != nullptr); On 2016/11/07 09:36:17, grt ...
4 years, 1 month ago (2016-11-07 19:46:52 UTC) #18
grt (UTC plus 2)
lgtm. please wait for wfh's review before committing. as i said, i'm no expert in ...
4 years, 1 month ago (2016-11-08 11:27:34 UTC) #19
huangs
Thanks! Ping wfh@ for review, PTAL. https://codereview.chromium.org/2462993003/diff/60001/courgette/assembly_program.h File courgette/assembly_program.h (right): https://codereview.chromium.org/2462993003/diff/60001/courgette/assembly_program.h#newcode26 courgette/assembly_program.h:26: class AssemblyProgram; On ...
4 years, 1 month ago (2016-11-08 16:45:16 UTC) #21
Will Harris
lgtm
4 years, 1 month ago (2016-11-08 17:09:47 UTC) #22
huangs
Ping chrisha@, PTAL.
4 years, 1 month ago (2016-11-09 20:51:08 UTC) #23
chrisha
lgtm!
4 years, 1 month ago (2016-11-09 21:27:04 UTC) #24
huangs
Thanks. Committing!
4 years, 1 month ago (2016-11-09 21:28:22 UTC) #25
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2462993003/80001
4 years, 1 month ago (2016-11-09 21:29:19 UTC) #28
commit-bot: I haz the power
Committed patchset #5 (id:80001)
4 years, 1 month ago (2016-11-09 22:28:53 UTC) #30
commit-bot: I haz the power
4 years, 1 month ago (2016-11-09 22:42:19 UTC) #32
Message was sent while issue was closed.
Patchset 5 (id:??) landed as
https://crrev.com/7b221a5ec1175ffba9955aede222b9bdd4056183
Cr-Commit-Position: refs/heads/master@{#431053}

Powered by Google App Engine
This is Rietveld 408576698