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 4748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4759 if (length() == 0) return 0; | 4759 if (length() == 0) return 0; |
4760 return Smi::cast(get(group))->value(); | 4760 return Smi::cast(get(group))->value(); |
4761 } | 4761 } |
4762 | 4762 |
4763 | 4763 |
4764 void DependentCode::set_number_of_entries(DependencyGroup group, int value) { | 4764 void DependentCode::set_number_of_entries(DependencyGroup group, int value) { |
4765 set(group, Smi::FromInt(value)); | 4765 set(group, Smi::FromInt(value)); |
4766 } | 4766 } |
4767 | 4767 |
4768 | 4768 |
4769 bool DependentCode::is_code_at(int i) { | |
4770 return get(kCodesStartIndex + i)->IsCode(); | |
4771 } | |
4772 | |
4773 Code* DependentCode::code_at(int i) { | |
4774 return Code::cast(get(kCodesStartIndex + i)); | |
4775 } | |
4776 | |
4777 | |
4778 CompilationInfo* DependentCode::compilation_info_at(int i) { | |
4779 return reinterpret_cast<CompilationInfo*>( | |
4780 Foreign::cast(get(kCodesStartIndex + i))->foreign_address()); | |
4781 } | |
4782 | |
4783 | |
4784 void DependentCode::set_object_at(int i, Object* object) { | 4769 void DependentCode::set_object_at(int i, Object* object) { |
4785 set(kCodesStartIndex + i, object); | 4770 set(kCodesStartIndex + i, object); |
4786 } | 4771 } |
4787 | 4772 |
4788 | 4773 |
4789 Object* DependentCode::object_at(int i) { | 4774 Object* DependentCode::object_at(int i) { |
4790 return get(kCodesStartIndex + i); | 4775 return get(kCodesStartIndex + i); |
4791 } | 4776 } |
4792 | 4777 |
4793 | 4778 |
4794 Object** DependentCode::slot_at(int i) { | |
4795 return RawFieldOfElementAt(kCodesStartIndex + i); | |
4796 } | |
4797 | |
4798 | |
4799 void DependentCode::clear_at(int i) { | 4779 void DependentCode::clear_at(int i) { |
4800 set_undefined(kCodesStartIndex + i); | 4780 set_undefined(kCodesStartIndex + i); |
4801 } | 4781 } |
4802 | 4782 |
4803 | 4783 |
4804 void DependentCode::copy(int from, int to) { | 4784 void DependentCode::copy(int from, int to) { |
4805 set(kCodesStartIndex + to, get(kCodesStartIndex + from)); | 4785 set(kCodesStartIndex + to, get(kCodesStartIndex + from)); |
4806 } | 4786 } |
4807 | 4787 |
4808 | 4788 |
(...skipping 2412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7221 | 7201 |
7222 | 7202 |
7223 Handle<ObjectHashTable> ObjectHashTable::Shrink( | 7203 Handle<ObjectHashTable> ObjectHashTable::Shrink( |
7224 Handle<ObjectHashTable> table, Handle<Object> key) { | 7204 Handle<ObjectHashTable> table, Handle<Object> key) { |
7225 return DerivedHashTable::Shrink(table, key); | 7205 return DerivedHashTable::Shrink(table, key); |
7226 } | 7206 } |
7227 | 7207 |
7228 | 7208 |
7229 template <int entrysize> | 7209 template <int entrysize> |
7230 bool WeakHashTableShape<entrysize>::IsMatch(Handle<Object> key, Object* other) { | 7210 bool WeakHashTableShape<entrysize>::IsMatch(Handle<Object> key, Object* other) { |
7231 return key->SameValue(other); | 7211 if (other->IsWeakCell()) other = WeakCell::cast(other)->value(); |
| 7212 return key->IsWeakCell() ? WeakCell::cast(*key)->value() == other |
| 7213 : *key == other; |
7232 } | 7214 } |
7233 | 7215 |
7234 | 7216 |
7235 template <int entrysize> | 7217 template <int entrysize> |
7236 uint32_t WeakHashTableShape<entrysize>::Hash(Handle<Object> key) { | 7218 uint32_t WeakHashTableShape<entrysize>::Hash(Handle<Object> key) { |
7237 intptr_t hash = reinterpret_cast<intptr_t>(*key); | 7219 intptr_t hash = |
| 7220 key->IsWeakCell() |
| 7221 ? reinterpret_cast<intptr_t>(WeakCell::cast(*key)->value()) |
| 7222 : reinterpret_cast<intptr_t>(*key); |
7238 return (uint32_t)(hash & 0xFFFFFFFF); | 7223 return (uint32_t)(hash & 0xFFFFFFFF); |
7239 } | 7224 } |
7240 | 7225 |
7241 | 7226 |
7242 template <int entrysize> | 7227 template <int entrysize> |
7243 uint32_t WeakHashTableShape<entrysize>::HashForObject(Handle<Object> key, | 7228 uint32_t WeakHashTableShape<entrysize>::HashForObject(Handle<Object> key, |
7244 Object* other) { | 7229 Object* other) { |
| 7230 if (other->IsWeakCell()) other = WeakCell::cast(other)->value(); |
7245 intptr_t hash = reinterpret_cast<intptr_t>(other); | 7231 intptr_t hash = reinterpret_cast<intptr_t>(other); |
7246 return (uint32_t)(hash & 0xFFFFFFFF); | 7232 return (uint32_t)(hash & 0xFFFFFFFF); |
7247 } | 7233 } |
7248 | 7234 |
7249 | 7235 |
7250 template <int entrysize> | 7236 template <int entrysize> |
7251 Handle<Object> WeakHashTableShape<entrysize>::AsHandle(Isolate* isolate, | 7237 Handle<Object> WeakHashTableShape<entrysize>::AsHandle(Isolate* isolate, |
7252 Handle<Object> key) { | 7238 Handle<Object> key) { |
7253 return key; | 7239 return key; |
7254 } | 7240 } |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7626 #undef READ_SHORT_FIELD | 7612 #undef READ_SHORT_FIELD |
7627 #undef WRITE_SHORT_FIELD | 7613 #undef WRITE_SHORT_FIELD |
7628 #undef READ_BYTE_FIELD | 7614 #undef READ_BYTE_FIELD |
7629 #undef WRITE_BYTE_FIELD | 7615 #undef WRITE_BYTE_FIELD |
7630 #undef NOBARRIER_READ_BYTE_FIELD | 7616 #undef NOBARRIER_READ_BYTE_FIELD |
7631 #undef NOBARRIER_WRITE_BYTE_FIELD | 7617 #undef NOBARRIER_WRITE_BYTE_FIELD |
7632 | 7618 |
7633 } } // namespace v8::internal | 7619 } } // namespace v8::internal |
7634 | 7620 |
7635 #endif // V8_OBJECTS_INL_H_ | 7621 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |