void BreakTarget::CopyTo(BreakTarget* destination) {
ASSERT(destination != NULL);
destination->direction_ = direction_;
- destination->reaching_frames_.Clear();
- destination->merge_labels_.Clear();
- ASSERT(reaching_frames_.length() == merge_labels_.length());
- for (int i = 0; i < reaching_frames_.length(); i++) {
- destination->reaching_frames_.Add(reaching_frames_[i]);
- destination->merge_labels_.Add(merge_labels_[i]);
- }
+ destination->reaching_frames_ = reaching_frames_;
+ destination->merge_labels_ = merge_labels_;
destination->entry_frame_ = entry_frame_;
destination->entry_label_ = entry_label_;
destination->expected_height_ = expected_height_;
namespace v8 { namespace internal {
+template<typename T, class P>
+List<T, P>::List(const List<T, P>& other) {
+ ASSERT(other.capacity() >= 0);
+ capacity_ = other.capacity();
+ length_ = other.length();
+ if (capacity_ > 0) {
+ data_ = NewData(capacity_);
+ int copy_size = length_ * sizeof(T);
+ const int kMinMemCpySize = 64;
+ if (copy_size < kMinMemCpySize) {
+ for (int i = 0; i < length_; i++) data_[i] = other.data_[i];
+ } else {
+ memcpy(data_, other.data_, copy_size);
+ }
+ } else {
+ data_ = NULL;
+ }
+}
+
+
template<typename T, class P>
void List<T, P>::Add(const T& element) {
if (length_ < capacity_) {
public:
INLINE(explicit List(int capacity)) { Initialize(capacity); }
+ INLINE(explicit List(const List<T, P>& other));
INLINE(~List()) { DeleteData(data_); }
INLINE(void* operator new(size_t size)) { return P::New(size); }
// Inlined implementation of ResizeAdd, shared by inlined and
// non-inlined versions of ResizeAdd.
void ResizeAddInternal(const T& element);
-
- DISALLOW_COPY_AND_ASSIGN(List);
};
class FrameElement;
VirtualFrame::VirtualFrame(VirtualFrame* original)
: cgen_(original->cgen_),
masm_(original->masm_),
- elements_(original->elements_.capacity()),
+ elements_(original->elements_),
parameter_count_(original->parameter_count_),
local_count_(original->local_count_),
stack_pointer_(original->stack_pointer_),
frame_pointer_(original->frame_pointer_) {
- // Copy all the elements from the original.
- for (int i = 0; i < original->elements_.length(); i++) {
- elements_.Add(original->elements_[i]);
- }
- for (int i = 0; i < kNumRegisters; i++) {
- register_locations_[i] = original->register_locations_[i];
- }
+ // Copy register locations from original.
+ memcpy(®ister_locations_,
+ original->register_locations_,
+ sizeof(register_locations_));
}