diff options
author | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-06 17:42:45 +0000 |
---|---|---|
committer | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-06 17:42:45 +0000 |
commit | 43a9e24a52fa867db98fc2195b8db85b4729e7a1 (patch) | |
tree | cad7a14c415542083ac3d1ecc2df1fd86f789557 /courgette/encoded_program.h | |
parent | 6768ac0b06ae36ec7b2d27adfb9b64fc17f57cee (diff) | |
download | chromium_src-43a9e24a52fa867db98fc2195b8db85b4729e7a1.zip chromium_src-43a9e24a52fa867db98fc2195b8db85b4729e7a1.tar.gz chromium_src-43a9e24a52fa867db98fc2195b8db85b4729e7a1.tar.bz2 |
Switch out use of std::string and std::vector for large allocations for a buffer class that doesn't throw exceptions.
The new buffer class is pretty simple and relies on the MemoryAllocator class that I previously to back large
allocations with mapped files when memory is scarce. That reduced the number of crashes quite a bit but we
still crash on machines that are simply out of diskspace as well. So, the right thing to do is to expect and
handle failures which is what this cl is all about. What we should see once this has landed is that crash
dumps due to courgette running out of disk space should disappear from crash/ and instead we should see the
number of users that run into this particular problem in dashboards.
TEST=Courgette out-of-memory/out-of-diskspace errors should disappear from crash/
BUG=74777
Review URL: http://codereview.chromium.org/6677141
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80648 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'courgette/encoded_program.h')
-rw-r--r-- | courgette/encoded_program.h | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/courgette/encoded_program.h b/courgette/encoded_program.h index 6d2f440..5acfeb6 100644 --- a/courgette/encoded_program.h +++ b/courgette/encoded_program.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -32,19 +32,21 @@ class EncodedProgram { void set_image_base(uint64 base) { image_base_ = base; } // (2) Address tables and indexes defined first. - CheckBool DefineRel32Label(int index, RVA address); - CheckBool DefineAbs32Label(int index, RVA address); + CheckBool DefineRel32Label(int index, RVA address) WARN_UNUSED_RESULT; + CheckBool DefineAbs32Label(int index, RVA address) WARN_UNUSED_RESULT; void EndLabels(); // (3) Add instructions in the order needed to generate bytes of file. - CheckBool AddOrigin(RVA rva); - CheckBool AddCopy(uint32 count, const void* bytes); - CheckBool AddRel32(int label_index); - CheckBool AddAbs32(int label_index); - CheckBool AddMakeRelocs(); + // NOTE: If any of these methods ever fail, the EncodedProgram instance + // has failed and should be discarded. + CheckBool AddOrigin(RVA rva) WARN_UNUSED_RESULT; + CheckBool AddCopy(uint32 count, const void* bytes) WARN_UNUSED_RESULT; + CheckBool AddRel32(int label_index) WARN_UNUSED_RESULT; + CheckBool AddAbs32(int label_index) WARN_UNUSED_RESULT; + CheckBool AddMakeRelocs() WARN_UNUSED_RESULT; // (3) Serialize binary assembly language tables to a set of streams. - CheckBool WriteTo(SinkStreamSet* streams); + CheckBool WriteTo(SinkStreamSet* streams) WARN_UNUSED_RESULT; // Using an EncodedProgram to generate a byte stream: // @@ -52,7 +54,7 @@ class EncodedProgram { bool ReadFrom(SourceStreamSet* streams); // (5) Assembles the 'binary assembly language' into final file. - CheckBool AssembleTo(SinkStream* buffer); + CheckBool AssembleTo(SinkStream* buffer) WARN_UNUSED_RESULT; private: // Binary assembly language operations. @@ -68,14 +70,14 @@ class EncodedProgram { OP_LAST }; - typedef std::vector<RVA, MemoryAllocator<RVA> > RvaVector; - typedef std::vector<uint32, MemoryAllocator<uint32> > UInt32Vector; - typedef std::vector<uint8, MemoryAllocator<uint8> > UInt8Vector; - typedef std::vector<OP, MemoryAllocator<OP> > OPVector; + typedef NoThrowBuffer<RVA> RvaVector; + typedef NoThrowBuffer<uint32> UInt32Vector; + typedef NoThrowBuffer<uint8> UInt8Vector; + typedef NoThrowBuffer<OP> OPVector; void DebuggingSummary(); - CheckBool GenerateBaseRelocations(SinkStream *buffer); - CheckBool DefineLabelCommon(RvaVector*, int, RVA); + CheckBool GenerateBaseRelocations(SinkStream *buffer) WARN_UNUSED_RESULT; + CheckBool DefineLabelCommon(RvaVector*, int, RVA) WARN_UNUSED_RESULT; void FinishLabelsCommon(RvaVector* addresses); // Binary assembly language tables. |