DescriptorArray::CopyFrom should always drop transitions for CALLBACKS.

Review URL: https://chromiumcodereview.appspot.com/9389005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10685 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent da2e84fc
......@@ -1743,7 +1743,9 @@ bool Genesis::InstallNatives() {
Handle<DescriptorArray> array_descriptors(
array_function->initial_map()->instance_descriptors());
int index = array_descriptors->SearchWithCache(heap()->length_symbol());
reresult_descriptors->CopyFrom(0, *array_descriptors, index, witness);
MaybeObject* copy_result =
reresult_descriptors->CopyFrom(0, *array_descriptors, index, witness);
if (copy_result->IsFailure()) return false;
int enum_index = 0;
{
......
......@@ -865,7 +865,7 @@ Handle<DescriptorArray> Factory::CopyAppendCallbackDescriptors(
// Copy the descriptors from the array.
for (int i = 0; i < array->number_of_descriptors(); i++) {
if (!array->IsNullDescriptor(i)) {
result->CopyFrom(descriptor_count++, *array, i, witness);
DescriptorArray::CopyFrom(result, descriptor_count++, array, i, witness);
}
}
......@@ -899,7 +899,7 @@ Handle<DescriptorArray> Factory::CopyAppendCallbackDescriptors(
Handle<DescriptorArray> new_result =
NewDescriptorArray(number_of_descriptors);
for (int i = 0; i < number_of_descriptors; i++) {
new_result->CopyFrom(i, *result, i, witness);
DescriptorArray::CopyFrom(new_result, i, result, i, witness);
}
result = new_result;
}
......
......@@ -2053,16 +2053,6 @@ void DescriptorArray::Set(int descriptor_number,
}
void DescriptorArray::CopyFrom(int index,
DescriptorArray* src,
int src_index,
const WhitenessWitness& witness) {
Descriptor desc;
src->Get(src_index, &desc);
Set(index, &desc, witness);
}
void DescriptorArray::NoIncrementalWriteBarrierSwapDescriptors(
int first, int second) {
NoIncrementalWriteBarrierSwap(this, ToKeyIndex(first), ToKeyIndex(second));
......
......@@ -5735,6 +5735,33 @@ static bool InsertionPointFound(String* key1, String* key2) {
}
void DescriptorArray::CopyFrom(Handle<DescriptorArray> dst,
int dst_index,
Handle<DescriptorArray> src,
int src_index,
const WhitenessWitness& witness) {
CALL_HEAP_FUNCTION_VOID(dst->GetIsolate(),
dst->CopyFrom(dst_index, *src, src_index, witness));
}
MaybeObject* DescriptorArray::CopyFrom(int dst_index,
DescriptorArray* src,
int src_index,
const WhitenessWitness& witness) {
Object* value = src->GetValue(src_index);
PropertyDetails details(src->GetDetails(src_index));
if (details.type() == CALLBACKS && value->IsAccessorPair()) {
MaybeObject* maybe_copy =
AccessorPair::cast(value)->CopyWithoutTransitions();
if (!maybe_copy->To(&value)) return maybe_copy;
}
Descriptor desc(src->GetKey(src_index), value, details);
Set(dst_index, &desc, witness);
return this;
}
MaybeObject* DescriptorArray::CopyInsert(Descriptor* descriptor,
TransitionFlag transition_flag) {
// Transitions are only kept when inserting another transition.
......@@ -5818,7 +5845,9 @@ MaybeObject* DescriptorArray::CopyInsert(Descriptor* descriptor,
} else {
if (!(IsNullDescriptor(from_index) ||
(remove_transitions && IsTransitionOnly(from_index)))) {
new_descriptors->CopyFrom(to_index++, this, from_index, witness);
MaybeObject* copy_result =
new_descriptors->CopyFrom(to_index++, this, from_index, witness);
if (copy_result->IsFailure()) return copy_result;
}
from_index++;
}
......@@ -5858,7 +5887,9 @@ MaybeObject* DescriptorArray::RemoveTransitions() {
int next_descriptor = 0;
for (int i = 0; i < number_of_descriptors(); i++) {
if (IsProperty(i)) {
new_descriptors->CopyFrom(next_descriptor++, this, i, witness);
MaybeObject* copy_result =
new_descriptors->CopyFrom(next_descriptor++, this, i, witness);
if (copy_result->IsFailure()) return copy_result;
}
}
ASSERT(next_descriptor == new_descriptors->number_of_descriptors());
......@@ -5971,6 +6002,18 @@ int DescriptorArray::LinearSearch(String* name, int len) {
}
MaybeObject* AccessorPair::CopyWithoutTransitions() {
Heap* heap = GetHeap();
AccessorPair* copy;
{ MaybeObject* maybe_copy = heap->AllocateAccessorPair();
if (!maybe_copy->To(&copy)) return maybe_copy;
}
copy->set_getter(getter()->IsMap() ? heap->the_hole_value() : getter());
copy->set_setter(setter()->IsMap() ? heap->the_hole_value() : setter());
return copy;
}
MaybeObject* DeoptimizationInputData::Allocate(int deopt_entry_count,
PretenureFlag pretenure) {
ASSERT(deopt_entry_count > 0);
......
......@@ -2434,12 +2434,20 @@ class DescriptorArray: public FixedArray {
Descriptor* desc,
const WhitenessWitness&);
// Transfer complete descriptor from another descriptor array to
// this one.
inline void CopyFrom(int index,
DescriptorArray* src,
// Transfer a complete descriptor from the src descriptor array to the dst
// one, dropping map transitions in CALLBACKS.
static void CopyFrom(Handle<DescriptorArray> dst,
int dst_index,
Handle<DescriptorArray> src,
int src_index,
const WhitenessWitness&);
const WhitenessWitness& witness);
// Transfer a complete descriptor from the src descriptor array to this
// descriptor array, dropping map transitions in CALLBACKS.
MUST_USE_RESULT MaybeObject* CopyFrom(int dst_index,
DescriptorArray* src,
int src_index,
const WhitenessWitness&);
// Copy the descriptor array, insert a new descriptor and optionally
// remove map transitions. If the descriptor is already present, it is
......@@ -7782,6 +7790,8 @@ class AccessorPair: public Struct {
static inline AccessorPair* cast(Object* obj);
MUST_USE_RESULT MaybeObject* CopyWithoutTransitions();
#ifdef OBJECT_PRINT
void AccessorPairPrint(FILE* out = stdout);
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment