From: svenpanne@chromium.org Date: Tue, 17 Apr 2012 07:16:19 +0000 (+0000) Subject: Tiny DescriptorArray cleanup. X-Git-Tag: upstream/4.7.83~16879 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=999fb73bc60d1cde6f337df0d0392167556ad7ec;p=platform%2Fupstream%2Fv8.git Tiny DescriptorArray cleanup. Removed 2 useless functions, nuked a simple helper function with a single caller, and simplified things by changing a signature. Review URL: https://chromiumcodereview.appspot.com/10066046 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11343 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index 0e95b4b..6178815 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -2159,7 +2159,7 @@ void Genesis::TransferNamedProperties(Handle from, Handle descs = Handle(from->map()->instance_descriptors()); for (int i = 0; i < descs->number_of_descriptors(); i++) { - PropertyDetails details = PropertyDetails(descs->GetDetails(i)); + PropertyDetails details = descs->GetDetails(i); switch (details.type()) { case FIELD: { HandleScope inner; diff --git a/src/handles.cc b/src/handles.cc index 416ecbd..def1604 100644 --- a/src/handles.cc +++ b/src/handles.cc @@ -1,4 +1,4 @@ -// Copyright 2011 the V8 project authors. All rights reserved. +// Copyright 2012 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -729,9 +729,9 @@ Handle GetEnumPropertyKeys(Handle object, Handle(object->map()->instance_descriptors(), isolate); for (int i = 0; i < descs->number_of_descriptors(); i++) { - if (descs->IsProperty(i) && !descs->IsDontEnum(i)) { + if (descs->IsProperty(i) && !descs->GetDetails(i).IsDontEnum()) { storage->set(index, descs->GetKey(i)); - PropertyDetails details(descs->GetDetails(i)); + PropertyDetails details = descs->GetDetails(i); sort_array->set(index, Smi::FromInt(details.index())); if (!indices.is_null()) { if (details.type() != FIELD) { diff --git a/src/heap.cc b/src/heap.cc index ac9e029..4000548 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -3973,7 +3973,7 @@ MaybeObject* Heap::AllocateGlobalObject(JSFunction* constructor) { // Fill these accessors into the dictionary. DescriptorArray* descs = map->instance_descriptors(); for (int i = 0; i < descs->number_of_descriptors(); i++) { - PropertyDetails details(descs->GetDetails(i)); + PropertyDetails details = descs->GetDetails(i); ASSERT(details.type() == CALLBACKS); // Only accessors are expected. PropertyDetails d = PropertyDetails(details.attributes(), CALLBACKS, details.index()); diff --git a/src/objects-inl.h b/src/objects-inl.h index ac328ce..677d567 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -1933,15 +1933,15 @@ Object* DescriptorArray::GetValue(int descriptor_number) { } -Smi* DescriptorArray::GetDetails(int descriptor_number) { +PropertyDetails DescriptorArray::GetDetails(int descriptor_number) { ASSERT(descriptor_number < number_of_descriptors()); - return Smi::cast(GetContentArray()->get(ToDetailsIndex(descriptor_number))); + Object* details = GetContentArray()->get(ToDetailsIndex(descriptor_number)); + return PropertyDetails(Smi::cast(details)); } PropertyType DescriptorArray::GetType(int descriptor_number) { - ASSERT(descriptor_number < number_of_descriptors()); - return PropertyDetails(GetDetails(descriptor_number)).type(); + return GetDetails(descriptor_number).type(); } @@ -2004,15 +2004,10 @@ bool DescriptorArray::IsNullDescriptor(int descriptor_number) { } -bool DescriptorArray::IsDontEnum(int descriptor_number) { - return PropertyDetails(GetDetails(descriptor_number)).IsDontEnum(); -} - - void DescriptorArray::Get(int descriptor_number, Descriptor* desc) { desc->Init(GetKey(descriptor_number), GetValue(descriptor_number), - PropertyDetails(GetDetails(descriptor_number))); + GetDetails(descriptor_number)); } diff --git a/src/objects.cc b/src/objects.cc index 1fe27ae..ef9d498 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -2322,7 +2322,7 @@ Object* Map::GetDescriptorContents(String* sentinel_name, } // If the transition already exists, return its descriptor. if (index != DescriptorArray::kNotFound) { - PropertyDetails details(descriptors->GetDetails(index)); + PropertyDetails details = descriptors->GetDetails(index); if (details.type() == ELEMENTS_TRANSITION) { return descriptors->GetValue(index); } else { @@ -3344,7 +3344,7 @@ MaybeObject* JSObject::NormalizeProperties(PropertyNormalizationMode mode, DescriptorArray* descs = map_of_this->instance_descriptors(); for (int i = 0; i < descs->number_of_descriptors(); i++) { - PropertyDetails details(descs->GetDetails(i)); + PropertyDetails details = descs->GetDetails(i); switch (details.type()) { case CONSTANT_FUNCTION: { PropertyDetails d = @@ -4206,7 +4206,7 @@ int Map::NumberOfDescribedProperties(PropertyAttributes filter) { int result = 0; DescriptorArray* descs = instance_descriptors(); for (int i = 0; i < descs->number_of_descriptors(); i++) { - PropertyDetails details(descs->GetDetails(i)); + PropertyDetails details = descs->GetDetails(i); if (descs->IsProperty(i) && (details.attributes() & filter) == 0) { result++; } @@ -5687,7 +5687,7 @@ MaybeObject* DescriptorArray::CopyFrom(int dst_index, int src_index, const WhitenessWitness& witness) { Object* value = src->GetValue(src_index); - PropertyDetails details(src->GetDetails(src_index)); + PropertyDetails details = src->GetDetails(src_index); if (details.type() == CALLBACKS && value->IsAccessorPair()) { MaybeObject* maybe_copy = AccessorPair::cast(value)->CopyWithoutTransitions(); @@ -5730,7 +5730,7 @@ MaybeObject* DescriptorArray::CopyInsert(Descriptor* descriptor, if (replacing) { // We are replacing an existing descriptor. We keep the enumeration // index of a visible property. - PropertyType t = PropertyDetails(GetDetails(index)).type(); + PropertyType t = GetDetails(index).type(); if (t == CONSTANT_FUNCTION || t == FIELD || t == CALLBACKS || @@ -5757,8 +5757,7 @@ MaybeObject* DescriptorArray::CopyInsert(Descriptor* descriptor, int enumeration_index = NextEnumerationIndex(); if (!descriptor->ContainsTransition()) { if (keep_enumeration_index) { - descriptor->SetEnumerationIndex( - PropertyDetails(GetDetails(index)).index()); + descriptor->SetEnumerationIndex(GetDetails(index).index()); } else { descriptor->SetEnumerationIndex(enumeration_index); ++enumeration_index; @@ -5902,10 +5901,10 @@ int DescriptorArray::BinarySearch(String* name, int low, int high) { ASSERT(hash == mid_hash); // There might be more, so we find the first one and // check them all to see if we have a match. - if (name == mid_name && !is_null_descriptor(mid)) return mid; + if (name == mid_name && !IsNullDescriptor(mid)) return mid; while ((mid > low) && (GetKey(mid - 1)->Hash() == hash)) mid--; for (; (mid <= high) && (GetKey(mid)->Hash() == hash); mid++) { - if (GetKey(mid)->Equals(name) && !is_null_descriptor(mid)) return mid; + if (GetKey(mid)->Equals(name) && !IsNullDescriptor(mid)) return mid; } break; } @@ -5919,7 +5918,7 @@ int DescriptorArray::LinearSearch(String* name, int len) { String* entry = GetKey(number); if ((entry->Hash() == hash) && name->Equals(entry) && - !is_null_descriptor(number)) { + !IsNullDescriptor(number)) { return number; } } diff --git a/src/objects.h b/src/objects.h index 80c5445..d682cde 100644 --- a/src/objects.h +++ b/src/objects.h @@ -2473,7 +2473,7 @@ class DescriptorArray: public FixedArray { // Accessors for fetching instance descriptor at descriptor number. inline String* GetKey(int descriptor_number); inline Object* GetValue(int descriptor_number); - inline Smi* GetDetails(int descriptor_number); + inline PropertyDetails GetDetails(int descriptor_number); inline PropertyType GetType(int descriptor_number); inline int GetFieldIndex(int descriptor_number); inline JSFunction* GetConstantFunction(int descriptor_number); @@ -2482,7 +2482,6 @@ class DescriptorArray: public FixedArray { inline bool IsProperty(int descriptor_number); inline bool IsTransitionOnly(int descriptor_number); inline bool IsNullDescriptor(int descriptor_number); - inline bool IsDontEnum(int descriptor_number); class WhitenessWitness { public: @@ -2636,10 +2635,6 @@ class DescriptorArray: public FixedArray { return descriptor_number << 1; } - bool is_null_descriptor(int descriptor_number) { - return PropertyDetails(GetDetails(descriptor_number)).type() == - NULL_DESCRIPTOR; - } // Swap operation on FixedArray without using write barriers. static inline void NoIncrementalWriteBarrierSwap( FixedArray* array, int first, int second); diff --git a/src/property.h b/src/property.h index 04f78b2..ba5e3c8 100644 --- a/src/property.h +++ b/src/property.h @@ -214,13 +214,6 @@ class LookupResult BASE_EMBEDDED { number_ = number; } - void DescriptorResult(JSObject* holder, Smi* details, int number) { - lookup_type_ = DESCRIPTOR_TYPE; - holder_ = holder; - details_ = PropertyDetails(details); - number_ = number; - } - void ConstantResult(JSObject* holder) { lookup_type_ = CONSTANT_TYPE; holder_ = holder; diff --git a/src/runtime.cc b/src/runtime.cc index b978653..d8da56c 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -2094,7 +2094,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetReadOnlyPrototype) { DescriptorArray* instance_desc = function->map()->instance_descriptors(); int index = instance_desc->Search(name); ASSERT(index != DescriptorArray::kNotFound); - PropertyDetails details(instance_desc->GetDetails(index)); + PropertyDetails details = instance_desc->GetDetails(index); CallbacksDescriptor new_desc(name, instance_desc->GetValue(index), static_cast(details.attributes() | READ_ONLY),