From: bmeurer@chromium.org Date: Tue, 18 Feb 2014 11:30:51 +0000 (+0000) Subject: Consistent use of const for LookupResult. X-Git-Tag: upstream/4.7.83~10656 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a7c82c49f4a788398bac3c16e50462eb9a2b9016;p=platform%2Fupstream%2Fv8.git Consistent use of const for LookupResult. R=svenpanne@chromium.org Review URL: https://codereview.chromium.org/170073003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19438 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/objects-inl.h b/src/objects-inl.h index 0cc0d09..ea7deda 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -59,7 +59,7 @@ PropertyDetails::PropertyDetails(Smi* smi) { } -Smi* PropertyDetails::AsSmi() { +Smi* PropertyDetails::AsSmi() const { // Ensure the upper 2 bits have the same value by sign extending it. This is // necessary to be able to use the 31st bit of the property details. int value = value_ << 1; @@ -67,7 +67,7 @@ Smi* PropertyDetails::AsSmi() { } -PropertyDetails PropertyDetails::AsDeleted() { +PropertyDetails PropertyDetails::AsDeleted() const { Smi* smi = Smi::FromInt(value_ | DeletedField::encode(1)); return PropertyDetails(smi); } diff --git a/src/objects.cc b/src/objects.cc index 84fcee7..3156edc 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -687,7 +687,7 @@ PropertyAttributes JSObject::GetPropertyAttributeWithFailedAccessCheck( } -Object* JSObject::GetNormalizedProperty(LookupResult* result) { +Object* JSObject::GetNormalizedProperty(const LookupResult* result) { ASSERT(!HasFastProperties()); Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry()); if (IsGlobalObject()) { @@ -699,7 +699,7 @@ Object* JSObject::GetNormalizedProperty(LookupResult* result) { void JSObject::SetNormalizedProperty(Handle object, - LookupResult* result, + const LookupResult* result, Handle value) { ASSERT(!object->HasFastProperties()); NameDictionary* property_dictionary = object->property_dictionary(); diff --git a/src/objects.h b/src/objects.h index cd152a2..710d2ba 100644 --- a/src/objects.h +++ b/src/objects.h @@ -2284,12 +2284,12 @@ class JSObject: public JSReceiver { // Retrieve a value in a normalized object given a lookup result. // Handles the special representation of JS global objects. - Object* GetNormalizedProperty(LookupResult* result); + Object* GetNormalizedProperty(const LookupResult* result); // Sets the property value in a normalized object given a lookup result. // Handles the special representation of JS global objects. static void SetNormalizedProperty(Handle object, - LookupResult* result, + const LookupResult* result, Handle value); // Sets the property value in a normalized object given (key, value, details). diff --git a/src/property-details.h b/src/property-details.h index 5f0920b..7bc553a 100644 --- a/src/property-details.h +++ b/src/property-details.h @@ -233,11 +233,11 @@ class PropertyDetails BASE_EMBEDDED { | FieldIndexField::encode(field_index); } - int pointer() { return DescriptorPointer::decode(value_); } + int pointer() const { return DescriptorPointer::decode(value_); } PropertyDetails set_pointer(int i) { return PropertyDetails(value_, i); } - PropertyDetails CopyWithRepresentation(Representation representation) { + PropertyDetails CopyWithRepresentation(Representation representation) const { return PropertyDetails(value_, representation); } PropertyDetails CopyAddAttributes(PropertyAttributes new_attributes) { @@ -248,7 +248,7 @@ class PropertyDetails BASE_EMBEDDED { // Conversion for storing details as Object*. explicit inline PropertyDetails(Smi* smi); - inline Smi* AsSmi(); + inline Smi* AsSmi() const; static uint8_t EncodeRepresentation(Representation representation) { return representation.kind(); @@ -258,26 +258,26 @@ class PropertyDetails BASE_EMBEDDED { return Representation::FromKind(static_cast(bits)); } - PropertyType type() { return TypeField::decode(value_); } + PropertyType type() const { return TypeField::decode(value_); } PropertyAttributes attributes() const { return AttributesField::decode(value_); } - int dictionary_index() { + int dictionary_index() const { return DictionaryStorageField::decode(value_); } - Representation representation() { + Representation representation() const { ASSERT(type() != NORMAL); return DecodeRepresentation(RepresentationField::decode(value_)); } - int field_index() { + int field_index() const { return FieldIndexField::decode(value_); } - inline PropertyDetails AsDeleted(); + inline PropertyDetails AsDeleted() const; static bool IsValidIndex(int index) { return DictionaryStorageField::is_valid(index); diff --git a/src/property.h b/src/property.h index 76dbae4..03dd66e 100644 --- a/src/property.h +++ b/src/property.h @@ -242,90 +242,90 @@ class LookupResult BASE_EMBEDDED { holder_ = NULL; } - JSObject* holder() { + JSObject* holder() const { ASSERT(IsFound()); return JSObject::cast(holder_); } - JSProxy* proxy() { + JSProxy* proxy() const { ASSERT(IsFound()); return JSProxy::cast(holder_); } - PropertyType type() { + PropertyType type() const { ASSERT(IsFound()); return details_.type(); } - Representation representation() { + Representation representation() const { ASSERT(IsFound()); ASSERT(!IsTransition()); ASSERT(details_.type() != NONEXISTENT); return details_.representation(); } - PropertyAttributes GetAttributes() { + PropertyAttributes GetAttributes() const { ASSERT(!IsTransition()); ASSERT(IsFound()); ASSERT(details_.type() != NONEXISTENT); return details_.attributes(); } - PropertyDetails GetPropertyDetails() { + PropertyDetails GetPropertyDetails() const { ASSERT(!IsTransition()); return details_; } - bool IsFastPropertyType() { + bool IsFastPropertyType() const { ASSERT(IsFound()); return IsTransition() || type() != NORMAL; } // Property callbacks does not include transitions to callbacks. - bool IsPropertyCallbacks() { + bool IsPropertyCallbacks() const { ASSERT(!(details_.type() == CALLBACKS && !IsFound())); return details_.type() == CALLBACKS; } - bool IsReadOnly() { + bool IsReadOnly() const { ASSERT(IsFound()); ASSERT(!IsTransition()); ASSERT(details_.type() != NONEXISTENT); return details_.IsReadOnly(); } - bool IsField() { + bool IsField() const { ASSERT(!(details_.type() == FIELD && !IsFound())); return details_.type() == FIELD; } - bool IsNormal() { + bool IsNormal() const { ASSERT(!(details_.type() == NORMAL && !IsFound())); return details_.type() == NORMAL; } - bool IsConstant() { + bool IsConstant() const { ASSERT(!(details_.type() == CONSTANT && !IsFound())); return details_.type() == CONSTANT; } - bool IsConstantFunction() { + bool IsConstantFunction() const { return IsConstant() && GetValue()->IsJSFunction(); } - bool IsDontDelete() { return details_.IsDontDelete(); } - bool IsDontEnum() { return details_.IsDontEnum(); } - bool IsFound() { return lookup_type_ != NOT_FOUND; } - bool IsTransition() { return lookup_type_ == TRANSITION_TYPE; } - bool IsHandler() { return lookup_type_ == HANDLER_TYPE; } - bool IsInterceptor() { return lookup_type_ == INTERCEPTOR_TYPE; } + bool IsDontDelete() const { return details_.IsDontDelete(); } + bool IsDontEnum() const { return details_.IsDontEnum(); } + bool IsFound() const { return lookup_type_ != NOT_FOUND; } + bool IsTransition() const { return lookup_type_ == TRANSITION_TYPE; } + bool IsHandler() const { return lookup_type_ == HANDLER_TYPE; } + bool IsInterceptor() const { return lookup_type_ == INTERCEPTOR_TYPE; } // Is the result is a property excluding transitions and the null descriptor? - bool IsProperty() { + bool IsProperty() const { return IsFound() && !IsTransition(); } - bool IsDataProperty() { + bool IsDataProperty() const { switch (type()) { case FIELD: case NORMAL: @@ -345,10 +345,10 @@ class LookupResult BASE_EMBEDDED { return false; } - bool IsCacheable() { return cacheable_; } + bool IsCacheable() const { return cacheable_; } void DisallowCaching() { cacheable_ = false; } - Object* GetLazyValue() { + Object* GetLazyValue() const { switch (type()) { case FIELD: return holder()->RawFastPropertyAt(GetFieldIndex().field_index()); @@ -373,88 +373,88 @@ class LookupResult BASE_EMBEDDED { return NULL; } - Map* GetTransitionTarget(Map* map) { + Map* GetTransitionTarget(Map* map) const { ASSERT(IsTransition()); TransitionArray* transitions = map->transitions(); return transitions->GetTarget(number_); } - Map* GetTransitionTarget() { + Map* GetTransitionTarget() const { return GetTransitionTarget(holder()->map()); } - PropertyDetails GetTransitionDetails(Map* map) { + PropertyDetails GetTransitionDetails(Map* map) const { ASSERT(IsTransition()); TransitionArray* transitions = map->transitions(); return transitions->GetTargetDetails(number_); } - PropertyDetails GetTransitionDetails() { + PropertyDetails GetTransitionDetails() const { return GetTransitionDetails(holder()->map()); } - bool IsTransitionToField(Map* map) { + bool IsTransitionToField(Map* map) const { return IsTransition() && GetTransitionDetails(map).type() == FIELD; } - bool IsTransitionToConstant(Map* map) { + bool IsTransitionToConstant(Map* map) const { return IsTransition() && GetTransitionDetails(map).type() == CONSTANT; } - Map* GetTransitionMap() { + Map* GetTransitionMap() const { ASSERT(IsTransition()); return Map::cast(GetValue()); } - Map* GetTransitionMapFromMap(Map* map) { + Map* GetTransitionMapFromMap(Map* map) const { ASSERT(IsTransition()); return map->transitions()->GetTarget(number_); } - int GetTransitionIndex() { + int GetTransitionIndex() const { ASSERT(IsTransition()); return number_; } - int GetDescriptorIndex() { + int GetDescriptorIndex() const { ASSERT(lookup_type_ == DESCRIPTOR_TYPE); return number_; } - PropertyIndex GetFieldIndex() { + PropertyIndex GetFieldIndex() const { ASSERT(lookup_type_ == DESCRIPTOR_TYPE); return PropertyIndex::NewFieldIndex(GetFieldIndexFromMap(holder()->map())); } - int GetLocalFieldIndexFromMap(Map* map) { + int GetLocalFieldIndexFromMap(Map* map) const { return GetFieldIndexFromMap(map) - map->inobject_properties(); } - int GetDictionaryEntry() { + int GetDictionaryEntry() const { ASSERT(lookup_type_ == DICTIONARY_TYPE); return number_; } - JSFunction* GetConstantFunction() { + JSFunction* GetConstantFunction() const { ASSERT(type() == CONSTANT); return JSFunction::cast(GetValue()); } - Object* GetConstantFromMap(Map* map) { + Object* GetConstantFromMap(Map* map) const { ASSERT(type() == CONSTANT); return GetValueFromMap(map); } - JSFunction* GetConstantFunctionFromMap(Map* map) { + JSFunction* GetConstantFunctionFromMap(Map* map) const { return JSFunction::cast(GetConstantFromMap(map)); } - Object* GetConstant() { + Object* GetConstant() const { ASSERT(type() == CONSTANT); return GetValue(); } - Object* GetCallbackObject() { + Object* GetCallbackObject() const { ASSERT(type() == CALLBACKS && !IsTransition()); return GetValue(); } @@ -463,7 +463,7 @@ class LookupResult BASE_EMBEDDED { void Print(FILE* out); #endif - Object* GetValue() { + Object* GetValue() const { if (lookup_type_ == DESCRIPTOR_TYPE) { return GetValueFromMap(holder()->map()); }