From: bmeurer@chromium.org Date: Mon, 17 Feb 2014 13:22:34 +0000 (+0000) Subject: Handlify DescriptorArray::Merge(). X-Git-Tag: upstream/4.7.83~10683 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c1729e5283fca8a985563798cf7ac1d3bbaa71fb;p=platform%2Fupstream%2Fv8.git Handlify DescriptorArray::Merge(). R=svenpanne@chromium.org Review URL: https://codereview.chromium.org/169363002 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19410 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/objects.cc b/src/objects.cc index 84fcee7..607d5cf 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -7992,97 +7992,88 @@ void DescriptorArray::CopyFrom(int dst_index, } -Handle DescriptorArray::Merge(Handle desc, - int verbatim, - int valid, - int new_size, - int modify_index, - StoreMode store_mode, - Handle other) { - CALL_HEAP_FUNCTION(desc->GetIsolate(), - desc->Merge(verbatim, valid, new_size, modify_index, - store_mode, *other), - DescriptorArray); -} - - // Generalize the |other| descriptor array by merging it into the (at least -// partly) updated |this| descriptor array. +// partly) updated |desc| descriptor array. // The method merges two descriptor array in three parts. Both descriptor arrays // are identical up to |verbatim|. They also overlap in keys up to |valid|. // Between |verbatim| and |valid|, the resulting descriptor type as well as the -// representation are generalized from both |this| and |other|. Beyond |valid|, +// representation are generalized from both |desc| and |other|. Beyond |valid|, // the descriptors are copied verbatim from |other| up to |new_size|. // In case of incompatible types, the type and representation of |other| is // used. -MaybeObject* DescriptorArray::Merge(int verbatim, - int valid, - int new_size, - int modify_index, - StoreMode store_mode, - DescriptorArray* other) { +Handle DescriptorArray::Merge(Handle desc, + int verbatim, + int valid, + int new_size, + int modify_index, + StoreMode store_mode, + Handle other) { ASSERT(verbatim <= valid); ASSERT(valid <= new_size); - DescriptorArray* result; // Allocate a new descriptor array large enough to hold the required // descriptors, with minimally the exact same size as this descriptor array. - MaybeObject* maybe_descriptors = DescriptorArray::Allocate( - GetIsolate(), new_size, - Max(new_size, other->number_of_descriptors()) - new_size); - if (!maybe_descriptors->To(&result)) return maybe_descriptors; - ASSERT(result->length() > length() || + Isolate* isolate = desc->GetIsolate(); + Handle result = isolate->factory()->NewDescriptorArray( + new_size, Max(new_size, other->number_of_descriptors()) - new_size); + ASSERT(result->length() > desc->length() || result->NumberOfSlackDescriptors() > 0 || result->number_of_descriptors() == other->number_of_descriptors()); ASSERT(result->number_of_descriptors() == new_size); - DescriptorArray::WhitenessWitness witness(result); - int descriptor; // 0 -> |verbatim| int current_offset = 0; for (descriptor = 0; descriptor < verbatim; descriptor++) { - if (GetDetails(descriptor).type() == FIELD) current_offset++; - result->CopyFrom(descriptor, other, descriptor, witness); + if (desc->GetDetails(descriptor).type() == FIELD) current_offset++; + Descriptor d(other->GetKey(descriptor), + other->GetValue(descriptor), + other->GetDetails(descriptor)); + result->Set(descriptor, &d); } // |verbatim| -> |valid| for (; descriptor < valid; descriptor++) { - Name* key = GetKey(descriptor); - PropertyDetails details = GetDetails(descriptor); + PropertyDetails details = desc->GetDetails(descriptor); PropertyDetails other_details = other->GetDetails(descriptor); if (details.type() == FIELD || other_details.type() == FIELD || (store_mode == FORCE_FIELD && descriptor == modify_index) || (details.type() == CONSTANT && other_details.type() == CONSTANT && - GetValue(descriptor) != other->GetValue(descriptor))) { + desc->GetValue(descriptor) != other->GetValue(descriptor))) { Representation representation = details.representation().generalize(other_details.representation()); - FieldDescriptor d(key, + FieldDescriptor d(desc->GetKey(descriptor), current_offset++, other_details.attributes(), representation); - result->Set(descriptor, &d, witness); + result->Set(descriptor, &d); } else { - result->CopyFrom(descriptor, other, descriptor, witness); + Descriptor d(other->GetKey(descriptor), + other->GetValue(descriptor), + other->GetDetails(descriptor)); + result->Set(descriptor, &d); } } // |valid| -> |new_size| for (; descriptor < new_size; descriptor++) { PropertyDetails details = other->GetDetails(descriptor); + if (details.type() == FIELD || (store_mode == FORCE_FIELD && descriptor == modify_index)) { - Name* key = other->GetKey(descriptor); - FieldDescriptor d(key, + FieldDescriptor d(other->GetKey(descriptor), current_offset++, details.attributes(), details.representation()); - result->Set(descriptor, &d, witness); + result->Set(descriptor, &d); } else { - result->CopyFrom(descriptor, other, descriptor, witness); + Descriptor d(other->GetKey(descriptor), + other->GetValue(descriptor), + other->GetDetails(descriptor)); + result->Set(descriptor, &d); } } diff --git a/src/objects.h b/src/objects.h index 2400be3..c5cd193 100644 --- a/src/objects.h +++ b/src/objects.h @@ -3389,13 +3389,8 @@ class DescriptorArray: public FixedArray { int new_size, int modify_index, StoreMode store_mode, - Handle other); - MUST_USE_RESULT MaybeObject* Merge(int verbatim, - int valid, - int new_size, - int modify_index, - StoreMode store_mode, - DescriptorArray* other); + Handle other) + V8_WARN_UNUSED_RESULT; bool IsMoreGeneralThan(int verbatim, int valid,