Introduced copy constructor for List<T, P> and changed constructor of VirtualFrame to use it.
Review URL: http://codereview.chromium.org/113582 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2000 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
e3464bca9d
commit
34865c062b
@ -484,13 +484,8 @@ void BreakTarget::set_direction(Directionality direction) {
|
||||
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_;
|
||||
|
@ -33,6 +33,26 @@
|
||||
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_) {
|
||||
|
@ -48,6 +48,7 @@ class List {
|
||||
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); }
|
||||
@ -125,8 +126,6 @@ class List {
|
||||
// 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;
|
||||
|
@ -39,18 +39,15 @@ namespace v8 { namespace internal {
|
||||
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_));
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user