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
This commit is contained in:
parent
d919414b6f
commit
999fb73bc6
@ -2159,7 +2159,7 @@ void Genesis::TransferNamedProperties(Handle<JSObject> from,
|
||||
Handle<DescriptorArray> descs =
|
||||
Handle<DescriptorArray>(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;
|
||||
|
@ -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<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object,
|
||||
Handle<DescriptorArray>(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) {
|
||||
|
@ -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());
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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<PropertyAttributes>(details.attributes() | READ_ONLY),
|
||||
|
Loading…
Reference in New Issue
Block a user