Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: src/objects-inl.h

Issue 1156993018: GlobalDictionary now stores PropertyDetails in PropertyCells. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/objects.cc ('k') | src/runtime/runtime-object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Review notes: 5 // Review notes:
6 // 6 //
7 // - The use of macros in these inline functions may seem superfluous 7 // - The use of macros in these inline functions may seem superfluous
8 // but it is absolutely needed to make sure gcc generates optimal 8 // but it is absolutely needed to make sure gcc generates optimal
9 // code. gcc is not happy when attempting to inline too deep. 9 // code. gcc is not happy when attempting to inline too deep.
10 // 10 //
(...skipping 1912 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 } 1923 }
1924 1924
1925 1925
1926 void Oddball::set_kind(byte value) { 1926 void Oddball::set_kind(byte value) {
1927 WRITE_FIELD(this, kKindOffset, Smi::FromInt(value)); 1927 WRITE_FIELD(this, kKindOffset, Smi::FromInt(value));
1928 } 1928 }
1929 1929
1930 1930
1931 ACCESSORS(Cell, value, Object, kValueOffset) 1931 ACCESSORS(Cell, value, Object, kValueOffset)
1932 ACCESSORS(PropertyCell, dependent_code, DependentCode, kDependentCodeOffset) 1932 ACCESSORS(PropertyCell, dependent_code, DependentCode, kDependentCodeOffset)
1933 ACCESSORS(PropertyCell, property_details_raw, Object, kDetailsOffset)
1933 ACCESSORS(PropertyCell, value, Object, kValueOffset) 1934 ACCESSORS(PropertyCell, value, Object, kValueOffset)
1934 1935
1935 Object* WeakCell::value() const { return READ_FIELD(this, kValueOffset); } 1936 Object* WeakCell::value() const { return READ_FIELD(this, kValueOffset); }
1936 1937
1937 1938
1938 void WeakCell::clear() { 1939 void WeakCell::clear() {
1939 DCHECK(GetHeap()->gc_state() == Heap::MARK_COMPACT); 1940 DCHECK(GetHeap()->gc_state() == Heap::MARK_COMPACT);
1940 WRITE_FIELD(this, kValueOffset, Smi::FromInt(0)); 1941 WRITE_FIELD(this, kValueOffset, Smi::FromInt(0));
1941 } 1942 }
1942 1943
(...skipping 5174 matching lines...) Expand 10 before | Expand all | Expand 10 after
7117 reinterpret_cast<v8::internal::Address>( 7118 reinterpret_cast<v8::internal::Address>(
7118 reinterpret_cast<intptr_t>(nullptr))); 7119 reinterpret_cast<intptr_t>(nullptr)));
7119 info->set_setter(*foreign); 7120 info->set_setter(*foreign);
7120 } 7121 }
7121 7122
7122 7123
7123 template<typename Derived, typename Shape, typename Key> 7124 template<typename Derived, typename Shape, typename Key>
7124 void Dictionary<Derived, Shape, Key>::SetEntry(int entry, 7125 void Dictionary<Derived, Shape, Key>::SetEntry(int entry,
7125 Handle<Object> key, 7126 Handle<Object> key,
7126 Handle<Object> value) { 7127 Handle<Object> value) {
7127 SetEntry(entry, key, value, PropertyDetails(Smi::FromInt(0))); 7128 this->SetEntry(entry, key, value, PropertyDetails(Smi::FromInt(0)));
7128 } 7129 }
7129 7130
7130 7131
7131 template<typename Derived, typename Shape, typename Key> 7132 template<typename Derived, typename Shape, typename Key>
7132 void Dictionary<Derived, Shape, Key>::SetEntry(int entry, 7133 void Dictionary<Derived, Shape, Key>::SetEntry(int entry,
7133 Handle<Object> key, 7134 Handle<Object> key,
7134 Handle<Object> value, 7135 Handle<Object> value,
7135 PropertyDetails details) { 7136 PropertyDetails details) {
7136 DCHECK(!key->IsName() || details.dictionary_index() > 0); 7137 Shape::SetEntry(static_cast<Derived*>(this), entry, key, value, details);
7137 int index = DerivedHashTable::EntryToIndex(entry);
7138 DisallowHeapAllocation no_gc;
7139 WriteBarrierMode mode = FixedArray::GetWriteBarrierMode(no_gc);
7140 FixedArray::set(index, *key, mode);
7141 FixedArray::set(index+1, *value, mode);
7142 FixedArray::set(index+2, details.AsSmi());
7143 } 7138 }
7144 7139
7145 7140
7141 template <typename Key>
7142 template <typename Dictionary>
7143 void BaseDictionaryShape<Key>::SetEntry(Dictionary* dict, int entry,
7144 Handle<Object> key,
7145 Handle<Object> value,
7146 PropertyDetails details) {
7147 STATIC_ASSERT(Dictionary::kEntrySize == 3);
7148 DCHECK(!key->IsName() || details.dictionary_index() > 0);
7149 int index = dict->EntryToIndex(entry);
7150 DisallowHeapAllocation no_gc;
7151 WriteBarrierMode mode = dict->GetWriteBarrierMode(no_gc);
7152 dict->set(index, *key, mode);
7153 dict->set(index + 1, *value, mode);
7154 dict->set(index + 2, details.AsSmi());
7155 }
7156
7157
7158 template <typename Dictionary>
7159 void GlobalDictionaryShape::SetEntry(Dictionary* dict, int entry,
7160 Handle<Object> key, Handle<Object> value,
7161 PropertyDetails details) {
7162 STATIC_ASSERT(Dictionary::kEntrySize == 2);
7163 DCHECK(!key->IsName() || details.dictionary_index() > 0);
7164 DCHECK(value->IsPropertyCell());
7165 int index = dict->EntryToIndex(entry);
7166 DisallowHeapAllocation no_gc;
7167 WriteBarrierMode mode = dict->GetWriteBarrierMode(no_gc);
7168 dict->set(index, *key, mode);
7169 dict->set(index + 1, *value, mode);
7170 PropertyCell::cast(*value)->set_property_details(details);
7171 }
7172
7173
7146 bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) { 7174 bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) {
7147 DCHECK(other->IsNumber()); 7175 DCHECK(other->IsNumber());
7148 return key == static_cast<uint32_t>(other->Number()); 7176 return key == static_cast<uint32_t>(other->Number());
7149 } 7177 }
7150 7178
7151 7179
7152 uint32_t UnseededNumberDictionaryShape::Hash(uint32_t key) { 7180 uint32_t UnseededNumberDictionaryShape::Hash(uint32_t key) {
7153 return ComputeIntegerHash(key, 0); 7181 return ComputeIntegerHash(key, 0);
7154 } 7182 }
7155 7183
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
7204 } 7232 }
7205 7233
7206 7234
7207 Handle<FixedArray> NameDictionary::DoGenerateNewEnumerationIndices( 7235 Handle<FixedArray> NameDictionary::DoGenerateNewEnumerationIndices(
7208 Handle<NameDictionary> dictionary) { 7236 Handle<NameDictionary> dictionary) {
7209 return DerivedDictionary::GenerateNewEnumerationIndices(dictionary); 7237 return DerivedDictionary::GenerateNewEnumerationIndices(dictionary);
7210 } 7238 }
7211 7239
7212 7240
7213 template <typename Dictionary> 7241 template <typename Dictionary>
7242 PropertyDetails GlobalDictionaryShape::DetailsAt(Dictionary* dict, int entry) {
7243 DCHECK(entry >= 0); // Not found is -1, which is not caught by get().
7244 Object* raw_value = dict->ValueAt(entry);
7245 DCHECK(raw_value->IsPropertyCell());
7246 PropertyCell* cell = PropertyCell::cast(raw_value);
7247 return cell->property_details();
7248 }
7249
7250
7251 template <typename Dictionary>
7252 void GlobalDictionaryShape::DetailsAtPut(Dictionary* dict, int entry,
7253 PropertyDetails value) {
7254 DCHECK(entry >= 0); // Not found is -1, which is not caught by get().
7255 Object* raw_value = dict->ValueAt(entry);
7256 DCHECK(raw_value->IsPropertyCell());
7257 PropertyCell* cell = PropertyCell::cast(raw_value);
7258 cell->set_property_details(value);
7259 }
7260
7261
7262 template <typename Dictionary>
7214 bool GlobalDictionaryShape::IsDeleted(Dictionary* dict, int entry) { 7263 bool GlobalDictionaryShape::IsDeleted(Dictionary* dict, int entry) {
7215 DCHECK(dict->ValueAt(entry)->IsPropertyCell()); 7264 DCHECK(dict->ValueAt(entry)->IsPropertyCell());
7216 return PropertyCell::cast(dict->ValueAt(entry))->value()->IsTheHole(); 7265 return PropertyCell::cast(dict->ValueAt(entry))->value()->IsTheHole();
7217 } 7266 }
7218 7267
7219 7268
7220 bool ObjectHashTableShape::IsMatch(Handle<Object> key, Object* other) { 7269 bool ObjectHashTableShape::IsMatch(Handle<Object> key, Object* other) {
7221 return key->SameValue(other); 7270 return key->SameValue(other);
7222 } 7271 }
7223 7272
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
7662 #undef READ_SHORT_FIELD 7711 #undef READ_SHORT_FIELD
7663 #undef WRITE_SHORT_FIELD 7712 #undef WRITE_SHORT_FIELD
7664 #undef READ_BYTE_FIELD 7713 #undef READ_BYTE_FIELD
7665 #undef WRITE_BYTE_FIELD 7714 #undef WRITE_BYTE_FIELD
7666 #undef NOBARRIER_READ_BYTE_FIELD 7715 #undef NOBARRIER_READ_BYTE_FIELD
7667 #undef NOBARRIER_WRITE_BYTE_FIELD 7716 #undef NOBARRIER_WRITE_BYTE_FIELD
7668 7717
7669 } } // namespace v8::internal 7718 } } // namespace v8::internal
7670 7719
7671 #endif // V8_OBJECTS_INL_H_ 7720 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/runtime/runtime-object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698