diff options
author | huangs <huangs@chromium.org> | 2016-01-19 14:09:03 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-19 22:11:12 +0000 |
commit | bb4b8a90a34d7a36b9a83cb663e9f29f12d16a3e (patch) | |
tree | 67781fd3df79bd04ed728c2555bcce6a574d609f /courgette/image_utils.h | |
parent | 7f6dad4f0bdb435323452ba420d34b2e7ee536cc (diff) | |
download | chromium_src-bb4b8a90a34d7a36b9a83cb663e9f29f12d16a3e.zip chromium_src-bb4b8a90a34d7a36b9a83cb663e9f29f12d16a3e.tar.gz chromium_src-bb4b8a90a34d7a36b9a83cb663e9f29f12d16a3e.tar.bz2 |
[Courgette] Simplify EncodedProgram Label addition code; removed "1.01 x" memory fix.
This CL simplifies how Labels get flattened to a list of RVAs. In the past
EncodedProgram used DefineAbs32Label() / DefineRel32Label(), which let callers
add one Label at a time. Complexity arose from:
- Function pointer usage to avoid duplicate code for abs32 and rel32.
- Need for EncodedProgram to dynamically adjust size of RVA list. This led to
inefficient array resizing, which was fixed by the "1.01 x" memory growth.
Change: We now pass the collection of abs32 and rel32 Labels to EncodedProgram.
This simplifies the interface, and allows EncodedProgram to find the max indexes
and preallocated buffers. The trade-off is increased test code complexity, since
we'd need to create Label collection.
Other changes:
- Update namespace{} for EncodedProgram and its tests.
- Add more Label constructors (for testing).
- Add LabelManager::GetIndexBound(), for LabelVector and RVAToLabel.
- Add kUnassignedRVA in image_utils.h, with checks for its absence in images.
Review URL: https://codereview.chromium.org/1571913003
Cr-Commit-Position: refs/heads/master@{#370200}
Diffstat (limited to 'courgette/image_utils.h')
-rw-r--r-- | courgette/image_utils.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/courgette/image_utils.h b/courgette/image_utils.h index 9a077fd..f958cc1 100644 --- a/courgette/image_utils.h +++ b/courgette/image_utils.h @@ -15,6 +15,7 @@ namespace courgette { typedef uint32_t RVA; +const RVA kUnassignedRVA = 0xFFFFFFFFU; // A Label is a symbolic reference to an address. Unlike a conventional // assembly language, we always know the address. The address will later be @@ -25,13 +26,16 @@ class Label { public: enum : int { kNoIndex = -1 }; explicit Label(RVA rva) : rva_(rva) {} + Label(RVA rva, int index) : rva_(rva), index_(index) {} + Label(RVA rva, int index, int32_t count) + : rva_(rva), index_(index), count_(count) {} bool operator==(const Label& other) const { return rva_ == other.rva_ && index_ == other.index_ && count_ == other.count_; } - RVA rva_ = 0; // Address referred to by the label. + RVA rva_ = kUnassignedRVA; // Address referred to by the label. int index_ = kNoIndex; // Index of address in address table. int32_t count_ = 0; }; |