OLD | NEW |
---|---|
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 1910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1921 } | 1921 } |
1922 | 1922 |
1923 | 1923 |
1924 void Oddball::set_kind(byte value) { | 1924 void Oddball::set_kind(byte value) { |
1925 WRITE_FIELD(this, kKindOffset, Smi::FromInt(value)); | 1925 WRITE_FIELD(this, kKindOffset, Smi::FromInt(value)); |
1926 } | 1926 } |
1927 | 1927 |
1928 | 1928 |
1929 ACCESSORS(Cell, value, Object, kValueOffset) | 1929 ACCESSORS(Cell, value, Object, kValueOffset) |
1930 ACCESSORS(PropertyCell, dependent_code, DependentCode, kDependentCodeOffset) | 1930 ACCESSORS(PropertyCell, dependent_code, DependentCode, kDependentCodeOffset) |
1931 ACCESSORS(PropertyCell, property_details_raw, Object, kDetailsOffset) | |
1931 ACCESSORS(PropertyCell, value, Object, kValueOffset) | 1932 ACCESSORS(PropertyCell, value, Object, kValueOffset) |
1932 | 1933 |
1933 Object* WeakCell::value() const { return READ_FIELD(this, kValueOffset); } | 1934 Object* WeakCell::value() const { return READ_FIELD(this, kValueOffset); } |
1934 | 1935 |
1935 | 1936 |
1936 void WeakCell::clear() { | 1937 void WeakCell::clear() { |
1937 DCHECK(GetHeap()->gc_state() == Heap::MARK_COMPACT); | 1938 DCHECK(GetHeap()->gc_state() == Heap::MARK_COMPACT); |
1938 WRITE_FIELD(this, kValueOffset, Smi::FromInt(0)); | 1939 WRITE_FIELD(this, kValueOffset, Smi::FromInt(0)); |
1939 } | 1940 } |
1940 | 1941 |
(...skipping 5174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7115 reinterpret_cast<v8::internal::Address>( | 7116 reinterpret_cast<v8::internal::Address>( |
7116 reinterpret_cast<intptr_t>(nullptr))); | 7117 reinterpret_cast<intptr_t>(nullptr))); |
7117 info->set_setter(*foreign); | 7118 info->set_setter(*foreign); |
7118 } | 7119 } |
7119 | 7120 |
7120 | 7121 |
7121 template<typename Derived, typename Shape, typename Key> | 7122 template<typename Derived, typename Shape, typename Key> |
7122 void Dictionary<Derived, Shape, Key>::SetEntry(int entry, | 7123 void Dictionary<Derived, Shape, Key>::SetEntry(int entry, |
7123 Handle<Object> key, | 7124 Handle<Object> key, |
7124 Handle<Object> value) { | 7125 Handle<Object> value) { |
7125 SetEntry(entry, key, value, PropertyDetails(Smi::FromInt(0))); | 7126 this->SetEntry(entry, key, value, PropertyDetails(Smi::FromInt(0))); |
7126 } | 7127 } |
7127 | 7128 |
7128 | 7129 |
7129 template<typename Derived, typename Shape, typename Key> | 7130 template<typename Derived, typename Shape, typename Key> |
7130 void Dictionary<Derived, Shape, Key>::SetEntry(int entry, | 7131 void Dictionary<Derived, Shape, Key>::SetEntry(int entry, |
7131 Handle<Object> key, | 7132 Handle<Object> key, |
7132 Handle<Object> value, | 7133 Handle<Object> value, |
7133 PropertyDetails details) { | 7134 PropertyDetails details) { |
7134 DCHECK(!key->IsName() || details.dictionary_index() > 0); | 7135 Shape::SetEntry(static_cast<Derived*>(this), entry, key, value, details); |
7135 int index = DerivedHashTable::EntryToIndex(entry); | |
7136 DisallowHeapAllocation no_gc; | |
7137 WriteBarrierMode mode = FixedArray::GetWriteBarrierMode(no_gc); | |
7138 FixedArray::set(index, *key, mode); | |
7139 FixedArray::set(index+1, *value, mode); | |
7140 FixedArray::set(index+2, details.AsSmi()); | |
7141 } | 7136 } |
7142 | 7137 |
7143 | 7138 |
7139 template <typename Key> | |
7140 template <typename Dictionary> | |
7141 void BaseDictionaryShape<Key>::SetEntry(Dictionary* dict, int entry, | |
7142 Handle<Object> key, | |
7143 Handle<Object> value, | |
7144 PropertyDetails details) { | |
7145 STATIC_ASSERT(Dictionary::kEntrySize == 3); | |
7146 DCHECK(!key->IsName() || details.dictionary_index() > 0); | |
7147 int index = dict->EntryToIndex(entry); | |
7148 DisallowHeapAllocation no_gc; | |
7149 WriteBarrierMode mode = dict->GetWriteBarrierMode(no_gc); | |
7150 dict->set(index, *key, mode); | |
7151 dict->set(index + 1, *value, mode); | |
7152 dict->set(index + 2, details.AsSmi()); | |
7153 } | |
7154 | |
7155 | |
7156 template <typename Dictionary> | |
7157 void GlobalDictionaryShape::SetEntry(Dictionary* dict, int entry, | |
7158 Handle<Object> key, Handle<Object> value, | |
7159 PropertyDetails details) { | |
7160 STATIC_ASSERT(Dictionary::kEntrySize == 2); | |
7161 DCHECK(!key->IsName() || details.dictionary_index() > 0); | |
7162 DCHECK(value->IsPropertyCell()); | |
7163 int index = dict->EntryToIndex(entry); | |
7164 DisallowHeapAllocation no_gc; | |
7165 WriteBarrierMode mode = dict->GetWriteBarrierMode(no_gc); | |
7166 dict->set(index, *key, mode); | |
7167 dict->set(index + 1, *value, mode); | |
7168 PropertyCell::cast(*value)->set_property_details(details); | |
7169 } | |
7170 | |
7171 | |
7144 bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) { | 7172 bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) { |
7145 DCHECK(other->IsNumber()); | 7173 DCHECK(other->IsNumber()); |
7146 return key == static_cast<uint32_t>(other->Number()); | 7174 return key == static_cast<uint32_t>(other->Number()); |
7147 } | 7175 } |
7148 | 7176 |
7149 | 7177 |
7150 uint32_t UnseededNumberDictionaryShape::Hash(uint32_t key) { | 7178 uint32_t UnseededNumberDictionaryShape::Hash(uint32_t key) { |
7151 return ComputeIntegerHash(key, 0); | 7179 return ComputeIntegerHash(key, 0); |
7152 } | 7180 } |
7153 | 7181 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7202 } | 7230 } |
7203 | 7231 |
7204 | 7232 |
7205 Handle<FixedArray> NameDictionary::DoGenerateNewEnumerationIndices( | 7233 Handle<FixedArray> NameDictionary::DoGenerateNewEnumerationIndices( |
7206 Handle<NameDictionary> dictionary) { | 7234 Handle<NameDictionary> dictionary) { |
7207 return DerivedDictionary::GenerateNewEnumerationIndices(dictionary); | 7235 return DerivedDictionary::GenerateNewEnumerationIndices(dictionary); |
7208 } | 7236 } |
7209 | 7237 |
7210 | 7238 |
7211 template <typename Dictionary> | 7239 template <typename Dictionary> |
7240 PropertyDetails GlobalDictionaryShape::DetailsAt(Dictionary* dict, int entry) { | |
7241 DCHECK(entry >= 0); // Not found is -1, which is not caught by get(). | |
7242 Object* raw_value = dict->ValueAt(entry); | |
7243 CHECK(raw_value->IsPropertyCell()); | |
Jakob Kummerow
2015/06/02 07:18:09
Do we need to keep this CHECK forever? Maybe add a
Igor Sheludko
2015/06/02 09:57:14
Done.
| |
7244 PropertyCell* cell = PropertyCell::cast(raw_value); | |
7245 return cell->property_details(); | |
7246 } | |
7247 | |
7248 | |
7249 template <typename Dictionary> | |
7250 void GlobalDictionaryShape::DetailsAtPut(Dictionary* dict, int entry, | |
7251 PropertyDetails value) { | |
7252 DCHECK(entry >= 0); // Not found is -1, which is not caught by get(). | |
7253 Object* raw_value = dict->ValueAt(entry); | |
7254 CHECK(raw_value->IsPropertyCell()); | |
7255 PropertyCell* cell = PropertyCell::cast(raw_value); | |
7256 cell->set_property_details(value); | |
7257 } | |
7258 | |
7259 | |
7260 template <typename Dictionary> | |
7212 bool GlobalDictionaryShape::IsDeleted(Dictionary* dict, int entry) { | 7261 bool GlobalDictionaryShape::IsDeleted(Dictionary* dict, int entry) { |
7213 DCHECK(dict->ValueAt(entry)->IsPropertyCell()); | 7262 DCHECK(dict->ValueAt(entry)->IsPropertyCell()); |
7214 return PropertyCell::cast(dict->ValueAt(entry))->value()->IsTheHole(); | 7263 return PropertyCell::cast(dict->ValueAt(entry))->value()->IsTheHole(); |
7215 } | 7264 } |
7216 | 7265 |
7217 | 7266 |
7218 bool ObjectHashTableShape::IsMatch(Handle<Object> key, Object* other) { | 7267 bool ObjectHashTableShape::IsMatch(Handle<Object> key, Object* other) { |
7219 return key->SameValue(other); | 7268 return key->SameValue(other); |
7220 } | 7269 } |
7221 | 7270 |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7660 #undef READ_SHORT_FIELD | 7709 #undef READ_SHORT_FIELD |
7661 #undef WRITE_SHORT_FIELD | 7710 #undef WRITE_SHORT_FIELD |
7662 #undef READ_BYTE_FIELD | 7711 #undef READ_BYTE_FIELD |
7663 #undef WRITE_BYTE_FIELD | 7712 #undef WRITE_BYTE_FIELD |
7664 #undef NOBARRIER_READ_BYTE_FIELD | 7713 #undef NOBARRIER_READ_BYTE_FIELD |
7665 #undef NOBARRIER_WRITE_BYTE_FIELD | 7714 #undef NOBARRIER_WRITE_BYTE_FIELD |
7666 | 7715 |
7667 } } // namespace v8::internal | 7716 } } // namespace v8::internal |
7668 | 7717 |
7669 #endif // V8_OBJECTS_INL_H_ | 7718 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |