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

Unified Diff: runtime/vm/debuginfo.h

Issue 9139080: Rename the VM internal class ByteArray to ByteVector. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: new strategy Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/debuginfo_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/debuginfo.h
diff --git a/runtime/vm/debuginfo.h b/runtime/vm/debuginfo.h
index 2b4bc8658ad635b911d49a9369a29f17381804ae..b3de437c655a8d57d119cd705d2ab4b78efe64bd 100644
--- a/runtime/vm/debuginfo.h
+++ b/runtime/vm/debuginfo.h
@@ -11,56 +11,6 @@
namespace dart {
-// A basic ByteArray which is growable and uses malloc/free.
-class ByteArray {
- public:
- ByteArray() : size_(0), capacity_(0), data_(NULL) { }
- ~ByteArray() {
- free(data_);
- size_ = 0;
- capacity_ = 0;
- data_ = NULL;
- }
-
- uint8_t at(int index) const {
- ASSERT(0 <= index);
- ASSERT(index < size_);
- ASSERT(size_ <= capacity_);
- return data_[index];
- }
-
- uint8_t* data() const { return data_; }
- void set_data(uint8_t* value) { data_ = value; }
- int size() const { return size_; }
-
- // Append an element.
- void Add(const uint8_t value) {
- Resize(size() + 1);
- data_[size() - 1] = value;
- }
-
- private:
- void Resize(int new_size) {
- if (new_size > capacity_) {
- int new_capacity = Utils::RoundUpToPowerOfTwo(new_size);
- uint8_t* new_data =
- reinterpret_cast<uint8_t*>(realloc(data_, new_capacity));
- ASSERT(new_data != NULL);
- data_ = new_data;
- capacity_ = new_capacity;
- }
- size_ = new_size;
- }
-
- int size_;
- int capacity_;
- uint8_t* data_;
-
- // Disallow assignment
- DISALLOW_COPY_AND_ASSIGN(ByteArray);
-};
-
-
// DebugInfo is used to generate minimal debug information containing code,
// symbols, and line numbers for generated code in the dart VM. This information
// can be used in two ways:
@@ -68,6 +18,55 @@ class ByteArray {
// - for generating information to be read by pprof to analyze Dart programs.
class DebugInfo {
public:
+ // A basic ByteBuffer which is growable and uses malloc/free.
+ class ByteBuffer {
+ public:
+ ByteBuffer() : size_(0), capacity_(0), data_(NULL) { }
+ ~ByteBuffer() {
+ free(data_);
+ size_ = 0;
+ capacity_ = 0;
+ data_ = NULL;
+ }
+
+ uint8_t at(int index) const {
+ ASSERT(0 <= index);
+ ASSERT(index < size_);
+ ASSERT(size_ <= capacity_);
+ return data_[index];
+ }
+
+ uint8_t* data() const { return data_; }
+ void set_data(uint8_t* value) { data_ = value; }
+ int size() const { return size_; }
+
+ // Append an element.
+ void Add(const uint8_t value) {
+ Resize(size() + 1);
+ data_[size() - 1] = value;
+ }
+
+ private:
+ void Resize(int new_size) {
+ if (new_size > capacity_) {
+ int new_capacity = Utils::RoundUpToPowerOfTwo(new_size);
+ uint8_t* new_data =
+ reinterpret_cast<uint8_t*>(realloc(data_, new_capacity));
+ ASSERT(new_data != NULL);
+ data_ = new_data;
+ capacity_ = new_capacity;
+ }
+ size_ = new_size;
+ }
+
+ int size_;
+ int capacity_;
+ uint8_t* data_;
+
+ // Disallow assignment
+ DISALLOW_COPY_AND_ASSIGN(ByteBuffer);
+ };
+
~DebugInfo();
// Add the code starting at pc.
@@ -78,7 +77,7 @@ class DebugInfo {
void AddCodeRegion(const char* name, uword pc, intptr_t size);
// Write out all the debug information info the memory region.
- bool WriteToMemory(ByteArray* region);
+ bool WriteToMemory(ByteBuffer* region);
// Create a new debug information generator.
static DebugInfo* NewGenerator();
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/debuginfo_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698