| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 // elements to the vector, and return it. | 575 // elements to the vector, and return it. |
| 576 // The caller is responsible for freeing the memory of the returned | 576 // The caller is responsible for freeing the memory of the returned |
| 577 // vector (e.g., using Vector::Dispose). | 577 // vector (e.g., using Vector::Dispose). |
| 578 Vector<T> ToVector() { | 578 Vector<T> ToVector() { |
| 579 Vector<T> new_store = Vector<T>::New(size_); | 579 Vector<T> new_store = Vector<T>::New(size_); |
| 580 WriteTo(new_store); | 580 WriteTo(new_store); |
| 581 return new_store; | 581 return new_store; |
| 582 } | 582 } |
| 583 | 583 |
| 584 // Resets the collector to be empty. | 584 // Resets the collector to be empty. |
| 585 virtual void Reset() { | 585 virtual void Reset(); |
| 586 for (int i = chunks_.length() - 1; i >= 0; i--) { | |
| 587 chunks_.at(i).Dispose(); | |
| 588 } | |
| 589 chunks_.Rewind(0); | |
| 590 index_ = 0; | |
| 591 size_ = 0; | |
| 592 } | |
| 593 | 586 |
| 594 // Total number of elements added to collector so far. | 587 // Total number of elements added to collector so far. |
| 595 inline int size() { return size_; } | 588 inline int size() { return size_; } |
| 596 | 589 |
| 597 protected: | 590 protected: |
| 598 static const int kMinCapacity = 16; | 591 static const int kMinCapacity = 16; |
| 599 List<Vector<T> > chunks_; | 592 List<Vector<T> > chunks_; |
| 600 Vector<T> current_chunk_; // Block of memory currently being written into. | 593 Vector<T> current_chunk_; // Block of memory currently being written into. |
| 601 int index_; // Current index in current chunk. | 594 int index_; // Current index in current chunk. |
| 602 int size_; // Total number of elements in collector. | 595 int size_; // Total number of elements in collector. |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 INLINE(Dest BitCast(const Source& source)); | 786 INLINE(Dest BitCast(const Source& source)); |
| 794 | 787 |
| 795 template <class Dest, class Source> | 788 template <class Dest, class Source> |
| 796 inline Dest BitCast(const Source& source) { | 789 inline Dest BitCast(const Source& source) { |
| 797 return BitCastHelper<Dest, Source>::cast(source); | 790 return BitCastHelper<Dest, Source>::cast(source); |
| 798 } | 791 } |
| 799 | 792 |
| 800 } } // namespace v8::internal | 793 } } // namespace v8::internal |
| 801 | 794 |
| 802 #endif // V8_UTILS_H_ | 795 #endif // V8_UTILS_H_ |
| OLD | NEW |