Commit b7a9c022 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[cleanup] Introduce more const methods

Change-Id: I703c90cfbb91f4afc035fb32a44f33af9fe736f3
Reviewed-on: https://chromium-review.googlesource.com/548459
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46392}
parent 9cb2211c
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
inline FieldIndex FieldIndex::ForInObjectOffset(int offset, const Map* map) {
inline FieldIndex FieldIndex::ForInObjectOffset(int offset, Map* map) {
DCHECK((offset % kPointerSize) == 0); DCHECK((offset % kPointerSize) == 0);
int index = offset / kPointerSize; int index = offset / kPointerSize;
DCHECK(map == NULL || DCHECK(map == NULL ||
...@@ -21,8 +20,7 @@ inline FieldIndex FieldIndex::ForInObjectOffset(int offset, Map* map) { ...@@ -21,8 +20,7 @@ inline FieldIndex FieldIndex::ForInObjectOffset(int offset, Map* map) {
return FieldIndex(true, index, false, 0, 0, true); return FieldIndex(true, index, false, 0, 0, true);
} }
inline FieldIndex FieldIndex::ForPropertyIndex(const Map* map,
inline FieldIndex FieldIndex::ForPropertyIndex(Map* map,
int property_index, int property_index,
bool is_double) { bool is_double) {
DCHECK(map->instance_type() >= FIRST_NONSTRING_TYPE); DCHECK(map->instance_type() >= FIRST_NONSTRING_TYPE);
...@@ -42,7 +40,8 @@ inline FieldIndex FieldIndex::ForPropertyIndex(Map* map, ...@@ -42,7 +40,8 @@ inline FieldIndex FieldIndex::ForPropertyIndex(Map* map,
// Takes an index as computed by GetLoadByFieldIndex and reconstructs a // Takes an index as computed by GetLoadByFieldIndex and reconstructs a
// FieldIndex object from it. // FieldIndex object from it.
inline FieldIndex FieldIndex::ForLoadByFieldIndex(Map* map, int orig_index) { inline FieldIndex FieldIndex::ForLoadByFieldIndex(const Map* map,
int orig_index) {
int field_index = orig_index; int field_index = orig_index;
bool is_inobject = true; bool is_inobject = true;
bool is_double = field_index & 1; bool is_double = field_index & 1;
...@@ -85,7 +84,8 @@ inline int FieldIndex::GetLoadByFieldIndex() const { ...@@ -85,7 +84,8 @@ inline int FieldIndex::GetLoadByFieldIndex() const {
return is_double() ? (result | 1) : result; return is_double() ? (result | 1) : result;
} }
inline FieldIndex FieldIndex::ForDescriptor(Map* map, int descriptor_index) { inline FieldIndex FieldIndex::ForDescriptor(const Map* map,
int descriptor_index) {
PropertyDetails details = PropertyDetails details =
map->instance_descriptors()->GetDetails(descriptor_index); map->instance_descriptors()->GetDetails(descriptor_index);
int field_index = details.field_index(); int field_index = details.field_index();
......
...@@ -21,12 +21,11 @@ class FieldIndex final { ...@@ -21,12 +21,11 @@ class FieldIndex final {
public: public:
FieldIndex() : bit_field_(0) {} FieldIndex() : bit_field_(0) {}
static FieldIndex ForPropertyIndex(Map* map, static FieldIndex ForPropertyIndex(const Map* map, int index,
int index,
bool is_double = false); bool is_double = false);
static FieldIndex ForInObjectOffset(int offset, Map* map = NULL); static FieldIndex ForInObjectOffset(int offset, const Map* map = NULL);
static FieldIndex ForDescriptor(Map* map, int descriptor_index); static FieldIndex ForDescriptor(const Map* map, int descriptor_index);
static FieldIndex ForLoadByFieldIndex(Map* map, int index); static FieldIndex ForLoadByFieldIndex(const Map* map, int index);
static FieldIndex FromFieldAccessStubKey(int key); static FieldIndex FromFieldAccessStubKey(int key);
int GetLoadByFieldIndex() const; int GetLoadByFieldIndex() const;
......
...@@ -3088,8 +3088,7 @@ Heap::RootListIndex Heap::RootIndexForEmptyFixedTypedArray( ...@@ -3088,8 +3088,7 @@ Heap::RootListIndex Heap::RootIndexForEmptyFixedTypedArray(
} }
} }
FixedTypedArrayBase* Heap::EmptyFixedTypedArrayForMap(const Map* map) {
FixedTypedArrayBase* Heap::EmptyFixedTypedArrayForMap(Map* map) {
return FixedTypedArrayBase::cast( return FixedTypedArrayBase::cast(
roots_[RootIndexForEmptyFixedTypedArray(map->elements_kind())]); roots_[RootIndexForEmptyFixedTypedArray(map->elements_kind())]);
} }
......
...@@ -1115,7 +1115,7 @@ class Heap { ...@@ -1115,7 +1115,7 @@ class Heap {
RootListIndex RootIndexForFixedTypedArray(ExternalArrayType array_type); RootListIndex RootIndexForFixedTypedArray(ExternalArrayType array_type);
RootListIndex RootIndexForEmptyFixedTypedArray(ElementsKind kind); RootListIndex RootIndexForEmptyFixedTypedArray(ElementsKind kind);
FixedTypedArrayBase* EmptyFixedTypedArrayForMap(Map* map); FixedTypedArrayBase* EmptyFixedTypedArrayForMap(const Map* map);
void RegisterStrongRoots(Object** start, Object** end); void RegisterStrongRoots(Object** start, Object** end);
void UnregisterStrongRoots(Object** start); void UnregisterStrongRoots(Object** start);
......
This diff is collapsed.
...@@ -2144,7 +2144,7 @@ Maybe<bool> JSReceiver::SetOrCopyDataProperties( ...@@ -2144,7 +2144,7 @@ Maybe<bool> JSReceiver::SetOrCopyDataProperties(
return Just(true); return Just(true);
} }
Map* Object::GetPrototypeChainRootMap(Isolate* isolate) { Map* Object::GetPrototypeChainRootMap(Isolate* isolate) const {
DisallowHeapAllocation no_alloc; DisallowHeapAllocation no_alloc;
if (IsSmi()) { if (IsSmi()) {
Context* native_context = isolate->context()->native_context(); Context* native_context = isolate->context()->native_context();
...@@ -2153,14 +2153,14 @@ Map* Object::GetPrototypeChainRootMap(Isolate* isolate) { ...@@ -2153,14 +2153,14 @@ Map* Object::GetPrototypeChainRootMap(Isolate* isolate) {
// The object is either a number, a string, a symbol, a boolean, a real JS // The object is either a number, a string, a symbol, a boolean, a real JS
// object, or a Harmony proxy. // object, or a Harmony proxy.
HeapObject* heap_object = HeapObject::cast(this); const HeapObject* heap_object = HeapObject::cast(this);
return heap_object->map()->GetPrototypeChainRootMap(isolate); return heap_object->map()->GetPrototypeChainRootMap(isolate);
} }
Map* Map::GetPrototypeChainRootMap(Isolate* isolate) { Map* Map::GetPrototypeChainRootMap(Isolate* isolate) const {
DisallowHeapAllocation no_alloc; DisallowHeapAllocation no_alloc;
if (IsJSReceiverMap()) { if (IsJSReceiverMap()) {
return this; return const_cast<Map*>(this);
} }
int constructor_function_index = GetConstructorFunctionIndex(); int constructor_function_index = GetConstructorFunctionIndex();
if (constructor_function_index != Map::kNoConstructorFunctionIndex) { if (constructor_function_index != Map::kNoConstructorFunctionIndex) {
...@@ -3458,11 +3458,13 @@ Handle<Context> JSReceiver::GetCreationContext() { ...@@ -3458,11 +3458,13 @@ Handle<Context> JSReceiver::GetCreationContext() {
: Handle<Context>::null(); : Handle<Context>::null();
} }
// static
Handle<Object> Map::WrapFieldType(Handle<FieldType> type) { Handle<Object> Map::WrapFieldType(Handle<FieldType> type) {
if (type->IsClass()) return Map::WeakCellForMap(type->AsClass()); if (type->IsClass()) return Map::WeakCellForMap(type->AsClass());
return type; return type;
} }
// static
FieldType* Map::UnwrapFieldType(Object* wrapped_type) { FieldType* Map::UnwrapFieldType(Object* wrapped_type) {
Object* value = wrapped_type; Object* value = wrapped_type;
if (value->IsWeakCell()) { if (value->IsWeakCell()) {
...@@ -3550,7 +3552,7 @@ const char* Representation::Mnemonic() const { ...@@ -3550,7 +3552,7 @@ const char* Representation::Mnemonic() const {
} }
} }
bool Map::TransitionRemovesTaggedField(Map* target) { bool Map::TransitionRemovesTaggedField(Map* target) const {
int inobject = NumberOfFields(); int inobject = NumberOfFields();
int target_inobject = target->NumberOfFields(); int target_inobject = target->NumberOfFields();
for (int i = target_inobject; i < inobject; i++) { for (int i = target_inobject; i < inobject; i++) {
...@@ -3560,7 +3562,7 @@ bool Map::TransitionRemovesTaggedField(Map* target) { ...@@ -3560,7 +3562,7 @@ bool Map::TransitionRemovesTaggedField(Map* target) {
return false; return false;
} }
bool Map::TransitionChangesTaggedFieldToUntaggedField(Map* target) { bool Map::TransitionChangesTaggedFieldToUntaggedField(Map* target) const {
int inobject = NumberOfFields(); int inobject = NumberOfFields();
int target_inobject = target->NumberOfFields(); int target_inobject = target->NumberOfFields();
int limit = Min(inobject, target_inobject); int limit = Min(inobject, target_inobject);
...@@ -3573,12 +3575,12 @@ bool Map::TransitionChangesTaggedFieldToUntaggedField(Map* target) { ...@@ -3573,12 +3575,12 @@ bool Map::TransitionChangesTaggedFieldToUntaggedField(Map* target) {
return false; return false;
} }
bool Map::TransitionRequiresSynchronizationWithGC(Map* target) { bool Map::TransitionRequiresSynchronizationWithGC(Map* target) const {
return TransitionRemovesTaggedField(target) || return TransitionRemovesTaggedField(target) ||
TransitionChangesTaggedFieldToUntaggedField(target); TransitionChangesTaggedFieldToUntaggedField(target);
} }
bool Map::InstancesNeedRewriting(Map* target) { bool Map::InstancesNeedRewriting(Map* target) const {
int target_number_of_fields = target->NumberOfFields(); int target_number_of_fields = target->NumberOfFields();
int target_inobject = target->GetInObjectProperties(); int target_inobject = target->GetInObjectProperties();
int target_unused = target->unused_property_fields(); int target_unused = target->unused_property_fields();
...@@ -3591,7 +3593,7 @@ bool Map::InstancesNeedRewriting(Map* target) { ...@@ -3591,7 +3593,7 @@ bool Map::InstancesNeedRewriting(Map* target) {
bool Map::InstancesNeedRewriting(Map* target, int target_number_of_fields, bool Map::InstancesNeedRewriting(Map* target, int target_number_of_fields,
int target_inobject, int target_unused, int target_inobject, int target_unused,
int* old_number_of_fields) { int* old_number_of_fields) const {
// If fields were added (or removed), rewrite the instance. // If fields were added (or removed), rewrite the instance.
*old_number_of_fields = NumberOfFields(); *old_number_of_fields = NumberOfFields();
DCHECK(target_number_of_fields >= *old_number_of_fields); DCHECK(target_number_of_fields >= *old_number_of_fields);
...@@ -4051,7 +4053,7 @@ void JSObject::ForceSetPrototype(Handle<JSObject> object, ...@@ -4051,7 +4053,7 @@ void JSObject::ForceSetPrototype(Handle<JSObject> object,
JSObject::MigrateToMap(object, new_map); JSObject::MigrateToMap(object, new_map);
} }
int Map::NumberOfFields() { int Map::NumberOfFields() const {
DescriptorArray* descriptors = instance_descriptors(); DescriptorArray* descriptors = instance_descriptors();
int result = 0; int result = 0;
for (int i = 0; i < NumberOfOwnDescriptors(); i++) { for (int i = 0; i < NumberOfOwnDescriptors(); i++) {
...@@ -4175,9 +4177,8 @@ void Map::ReplaceDescriptors(DescriptorArray* new_descriptors, ...@@ -4175,9 +4177,8 @@ void Map::ReplaceDescriptors(DescriptorArray* new_descriptors,
set_owns_descriptors(false); set_owns_descriptors(false);
} }
Map* Map::FindRootMap() const {
Map* Map::FindRootMap() { const Map* result = this;
Map* result = this;
Isolate* isolate = GetIsolate(); Isolate* isolate = GetIsolate();
while (true) { while (true) {
Object* back = result->GetBackPointer(); Object* back = result->GetBackPointer();
...@@ -4187,26 +4188,25 @@ Map* Map::FindRootMap() { ...@@ -4187,26 +4188,25 @@ Map* Map::FindRootMap() {
DCHECK(result->owns_descriptors()); DCHECK(result->owns_descriptors());
DCHECK_EQ(result->NumberOfOwnDescriptors(), DCHECK_EQ(result->NumberOfOwnDescriptors(),
result->instance_descriptors()->number_of_descriptors()); result->instance_descriptors()->number_of_descriptors());
return result; return const_cast<Map*>(result);
} }
result = Map::cast(back); result = Map::cast(back);
} }
} }
Map* Map::FindFieldOwner(int descriptor) const {
Map* Map::FindFieldOwner(int descriptor) {
DisallowHeapAllocation no_allocation; DisallowHeapAllocation no_allocation;
DCHECK_EQ(kField, instance_descriptors()->GetDetails(descriptor).location()); DCHECK_EQ(kField, instance_descriptors()->GetDetails(descriptor).location());
Map* result = this; const Map* result = this;
Isolate* isolate = GetIsolate(); Isolate* isolate = GetIsolate();
while (true) { while (true) {
Object* back = result->GetBackPointer(); Object* back = result->GetBackPointer();
if (back->IsUndefined(isolate)) break; if (back->IsUndefined(isolate)) break;
Map* parent = Map::cast(back); const Map* parent = Map::cast(back);
if (parent->NumberOfOwnDescriptors() <= descriptor) break; if (parent->NumberOfOwnDescriptors() <= descriptor) break;
result = parent; result = parent;
} }
return result; return const_cast<Map*>(result);
} }
void Map::UpdateFieldType(int descriptor, Handle<Name> name, void Map::UpdateFieldType(int descriptor, Handle<Name> name,
...@@ -5112,8 +5112,7 @@ Map* Map::LookupElementsTransitionMap(ElementsKind to_kind) { ...@@ -5112,8 +5112,7 @@ Map* Map::LookupElementsTransitionMap(ElementsKind to_kind) {
return nullptr; return nullptr;
} }
bool Map::IsMapInArrayPrototypeChain() const {
bool Map::IsMapInArrayPrototypeChain() {
Isolate* isolate = GetIsolate(); Isolate* isolate = GetIsolate();
if (isolate->initial_array_prototype()->map() == this) { if (isolate->initial_array_prototype()->map() == this) {
return true; return true;
...@@ -8278,7 +8277,7 @@ bool JSObject::HasEnumerableElements() { ...@@ -8278,7 +8277,7 @@ bool JSObject::HasEnumerableElements() {
UNREACHABLE(); UNREACHABLE();
} }
int Map::NumberOfEnumerableProperties() { int Map::NumberOfEnumerableProperties() const {
int result = 0; int result = 0;
DescriptorArray* descs = instance_descriptors(); DescriptorArray* descs = instance_descriptors();
int limit = NumberOfOwnDescriptors(); int limit = NumberOfOwnDescriptors();
...@@ -8291,8 +8290,7 @@ int Map::NumberOfEnumerableProperties() { ...@@ -8291,8 +8290,7 @@ int Map::NumberOfEnumerableProperties() {
return result; return result;
} }
int Map::NextFreePropertyIndex() const {
int Map::NextFreePropertyIndex() {
int free_index = 0; int free_index = 0;
int number_of_own_descriptors = NumberOfOwnDescriptors(); int number_of_own_descriptors = NumberOfOwnDescriptors();
DescriptorArray* descs = instance_descriptors(); DescriptorArray* descs = instance_descriptors();
...@@ -8306,8 +8304,7 @@ int Map::NextFreePropertyIndex() { ...@@ -8306,8 +8304,7 @@ int Map::NextFreePropertyIndex() {
return free_index; return free_index;
} }
bool Map::OnlyHasSimpleProperties() const {
bool Map::OnlyHasSimpleProperties() {
// Wrapped string elements aren't explicitly stored in the elements backing // Wrapped string elements aren't explicitly stored in the elements backing
// store, but are loaded indirectly from the underlying string. // store, but are loaded indirectly from the underlying string.
return !IsStringWrapperElementsKind(elements_kind()) && return !IsStringWrapperElementsKind(elements_kind()) &&
...@@ -11976,7 +11973,7 @@ int Map::Hash() { ...@@ -11976,7 +11973,7 @@ int Map::Hash() {
namespace { namespace {
bool CheckEquivalent(Map* first, Map* second) { bool CheckEquivalent(const Map* first, const Map* second) {
return first->GetConstructor() == second->GetConstructor() && return first->GetConstructor() == second->GetConstructor() &&
first->prototype() == second->prototype() && first->prototype() == second->prototype() &&
first->instance_type() == second->instance_type() && first->instance_type() == second->instance_type() &&
...@@ -11988,8 +11985,7 @@ bool CheckEquivalent(Map* first, Map* second) { ...@@ -11988,8 +11985,7 @@ bool CheckEquivalent(Map* first, Map* second) {
} // namespace } // namespace
bool Map::EquivalentToForTransition(const Map* other) const {
bool Map::EquivalentToForTransition(Map* other) {
if (!CheckEquivalent(this, other)) return false; if (!CheckEquivalent(this, other)) return false;
if (instance_type() == JS_FUNCTION_TYPE) { if (instance_type() == JS_FUNCTION_TYPE) {
// JSFunctions require more checks to ensure that sloppy function is // JSFunctions require more checks to ensure that sloppy function is
...@@ -12001,9 +11997,8 @@ bool Map::EquivalentToForTransition(Map* other) { ...@@ -12001,9 +11997,8 @@ bool Map::EquivalentToForTransition(Map* other) {
return true; return true;
} }
bool Map::EquivalentToForNormalization(const Map* other,
bool Map::EquivalentToForNormalization(Map* other, PropertyNormalizationMode mode) const {
PropertyNormalizationMode mode) {
int properties = int properties =
mode == CLEAR_INOBJECT_PROPERTIES ? 0 : other->GetInObjectProperties(); mode == CLEAR_INOBJECT_PROPERTIES ? 0 : other->GetInObjectProperties();
return CheckEquivalent(this, other) && bit_field2() == other->bit_field2() && return CheckEquivalent(this, other) && bit_field2() == other->bit_field2() &&
......
This diff is collapsed.
...@@ -68,13 +68,13 @@ class BaseShape { ...@@ -68,13 +68,13 @@ class BaseShape {
class V8_EXPORT_PRIVATE HashTableBase : public NON_EXPORTED_BASE(FixedArray) { class V8_EXPORT_PRIVATE HashTableBase : public NON_EXPORTED_BASE(FixedArray) {
public: public:
// Returns the number of elements in the hash table. // Returns the number of elements in the hash table.
inline int NumberOfElements(); inline int NumberOfElements() const;
// Returns the number of deleted elements in the hash table. // Returns the number of deleted elements in the hash table.
inline int NumberOfDeletedElements(); inline int NumberOfDeletedElements() const;
// Returns the capacity of the hash table. // Returns the capacity of the hash table.
inline int Capacity(); inline int Capacity() const;
// ElementAdded should be called whenever an element is added to a // ElementAdded should be called whenever an element is added to a
// hash table. // hash table.
...@@ -678,7 +678,9 @@ class SmallOrderedHashTable : public HeapObject { ...@@ -678,7 +678,9 @@ class SmallOrderedHashTable : public HeapObject {
return ((padding_offset + kPointerSize - 1) / kPointerSize) * kPointerSize; return ((padding_offset + kPointerSize - 1) / kPointerSize) * kPointerSize;
} }
int GetDataTableStartOffset() { return GetDataTableStartOffset(Capacity()); } int GetDataTableStartOffset() const {
return GetDataTableStartOffset(Capacity());
}
static int Size(int capacity) { static int Size(int capacity) {
int data_table_start = GetDataTableStartOffset(capacity); int data_table_start = GetDataTableStartOffset(capacity);
...@@ -686,39 +688,45 @@ class SmallOrderedHashTable : public HeapObject { ...@@ -686,39 +688,45 @@ class SmallOrderedHashTable : public HeapObject {
return data_table_start + data_table_size; return data_table_start + data_table_size;
} }
int Size() { return Size(Capacity()); } int Size() const { return Size(Capacity()); }
void SetFirstEntry(int bucket, byte value) { void SetFirstEntry(int bucket, byte value) {
set(kBucketsStartOffset + bucket, value); set(kBucketsStartOffset + bucket, value);
} }
int GetFirstEntry(int bucket) { return get(kBucketsStartOffset + bucket); } int GetFirstEntry(int bucket) const {
return get(kBucketsStartOffset + bucket);
}
void SetNextEntry(int entry, int next_entry) { void SetNextEntry(int entry, int next_entry) {
set(GetChainTableOffset() + entry, next_entry); set(GetChainTableOffset() + entry, next_entry);
} }
int GetNextEntry(int entry) { return get(GetChainTableOffset() + entry); } int GetNextEntry(int entry) const {
return get(GetChainTableOffset() + entry);
}
Object* GetDataEntry(int entry, int relative_index) { Object* GetDataEntry(int entry, int relative_index) {
int entry_offset = GetDataEntryOffset(entry, relative_index); int entry_offset = GetDataEntryOffset(entry, relative_index);
return READ_FIELD(this, entry_offset); return READ_FIELD(this, entry_offset);
} }
Object* KeyAt(int entry) { Object* KeyAt(int entry) const {
int entry_offset = GetDataEntryOffset(entry, Derived::kKeyIndex); int entry_offset = GetDataEntryOffset(entry, Derived::kKeyIndex);
return READ_FIELD(this, entry_offset); return READ_FIELD(this, entry_offset);
} }
int HashToBucket(int hash) { return hash & (NumberOfBuckets() - 1); } int HashToBucket(int hash) const { return hash & (NumberOfBuckets() - 1); }
int HashToFirstEntry(int hash) { int HashToFirstEntry(int hash) const {
int bucket = HashToBucket(hash); int bucket = HashToBucket(hash);
int entry = GetFirstEntry(bucket); int entry = GetFirstEntry(bucket);
return entry; return entry;
} }
int GetChainTableOffset() { return kBucketsStartOffset + NumberOfBuckets(); } int GetChainTableOffset() const {
return kBucketsStartOffset + NumberOfBuckets();
}
void SetNumberOfBuckets(int num) { set(kNumberOfBucketsOffset, num); } void SetNumberOfBuckets(int num) { set(kNumberOfBucketsOffset, num); }
...@@ -728,11 +736,13 @@ class SmallOrderedHashTable : public HeapObject { ...@@ -728,11 +736,13 @@ class SmallOrderedHashTable : public HeapObject {
set(kNumberOfDeletedElementsOffset, num); set(kNumberOfDeletedElementsOffset, num);
} }
int NumberOfElements() { return get(kNumberOfElementsOffset); } int NumberOfElements() const { return get(kNumberOfElementsOffset); }
int NumberOfDeletedElements() { return get(kNumberOfDeletedElementsOffset); } int NumberOfDeletedElements() const {
return get(kNumberOfDeletedElementsOffset);
}
int NumberOfBuckets() { return get(kNumberOfBucketsOffset); } int NumberOfBuckets() const { return get(kNumberOfBucketsOffset); }
static const byte kNotFound = 0xFF; static const byte kNotFound = 0xFF;
static const int kMinCapacity = 4; static const int kMinCapacity = 4;
...@@ -768,7 +778,7 @@ class SmallOrderedHashTable : public HeapObject { ...@@ -768,7 +778,7 @@ class SmallOrderedHashTable : public HeapObject {
protected: protected:
// This is used for accessing the non |DataTable| part of the // This is used for accessing the non |DataTable| part of the
// structure. // structure.
byte get(int index) { byte get(int index) const {
return READ_BYTE_FIELD(this, kHeaderSize + (index * kOneByteSize)); return READ_BYTE_FIELD(this, kHeaderSize + (index * kOneByteSize));
} }
...@@ -776,7 +786,7 @@ class SmallOrderedHashTable : public HeapObject { ...@@ -776,7 +786,7 @@ class SmallOrderedHashTable : public HeapObject {
WRITE_BYTE_FIELD(this, kHeaderSize + (index * kOneByteSize), value); WRITE_BYTE_FIELD(this, kHeaderSize + (index * kOneByteSize), value);
} }
int GetDataEntryOffset(int entry, int relative_index) { int GetDataEntryOffset(int entry, int relative_index) const {
int datatable_start = GetDataTableStartOffset(); int datatable_start = GetDataTableStartOffset();
int offset_in_datatable = entry * Derived::kEntrySize * kPointerSize; int offset_in_datatable = entry * Derived::kEntrySize * kPointerSize;
int offset_in_entry = relative_index * kPointerSize; int offset_in_entry = relative_index * kPointerSize;
...@@ -784,9 +794,11 @@ class SmallOrderedHashTable : public HeapObject { ...@@ -784,9 +794,11 @@ class SmallOrderedHashTable : public HeapObject {
} }
// Returns the number elements that can fit into the allocated buffer. // Returns the number elements that can fit into the allocated buffer.
int Capacity() { return NumberOfBuckets() * kLoadFactor; } int Capacity() const { return NumberOfBuckets() * kLoadFactor; }
int UsedCapacity() { return NumberOfElements() + NumberOfDeletedElements(); } int UsedCapacity() const {
return NumberOfElements() + NumberOfDeletedElements();
}
}; };
class SmallOrderedHashSet : public SmallOrderedHashTable<SmallOrderedHashSet> { class SmallOrderedHashSet : public SmallOrderedHashTable<SmallOrderedHashSet> {
......
This diff is collapsed.
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
#define RELAXED_READ_BYTE_FIELD(p, offset) \ #define RELAXED_READ_BYTE_FIELD(p, offset) \
static_cast<byte>(base::Relaxed_Load( \ static_cast<byte>(base::Relaxed_Load( \
reinterpret_cast<base::Atomic8*>(FIELD_ADDR(p, offset)))) reinterpret_cast<const base::Atomic8*>(FIELD_ADDR_CONST(p, offset))))
#define WRITE_BYTE_FIELD(p, offset, value) \ #define WRITE_BYTE_FIELD(p, offset, value) \
(*reinterpret_cast<byte*>(FIELD_ADDR(p, offset)) = value) (*reinterpret_cast<byte*>(FIELD_ADDR(p, offset)) = value)
......
...@@ -181,7 +181,7 @@ Map* TransitionArray::SearchTransition(Map* map, PropertyKind kind, Name* name, ...@@ -181,7 +181,7 @@ Map* TransitionArray::SearchTransition(Map* map, PropertyKind kind, Name* name,
// static // static
Map* TransitionArray::SearchSpecial(Map* map, Symbol* name) { Map* TransitionArray::SearchSpecial(const Map* map, Symbol* name) {
Object* raw_transitions = map->raw_transitions(); Object* raw_transitions = map->raw_transitions();
if (IsFullTransitionArray(raw_transitions)) { if (IsFullTransitionArray(raw_transitions)) {
TransitionArray* transitions = TransitionArray::cast(raw_transitions); TransitionArray* transitions = TransitionArray::cast(raw_transitions);
......
...@@ -51,7 +51,7 @@ class TransitionArray: public FixedArray { ...@@ -51,7 +51,7 @@ class TransitionArray: public FixedArray {
return MaybeHandle<Map>(); return MaybeHandle<Map>();
} }
static Map* SearchSpecial(Map* map, Symbol* name); static Map* SearchSpecial(const Map* map, Symbol* name);
static Handle<Map> FindTransitionToField(Handle<Map> map, Handle<Name> name); static Handle<Map> FindTransitionToField(Handle<Map> map, Handle<Name> name);
......
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