| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1806 Object* value, | 1806 Object* value, |
| 1807 WriteBarrierMode mode) { | 1807 WriteBarrierMode mode) { |
| 1808 ASSERT(map() != HEAP->fixed_cow_array_map()); | 1808 ASSERT(map() != HEAP->fixed_cow_array_map()); |
| 1809 ASSERT(index >= 0 && index < this->length()); | 1809 ASSERT(index >= 0 && index < this->length()); |
| 1810 int offset = kHeaderSize + index * kPointerSize; | 1810 int offset = kHeaderSize + index * kPointerSize; |
| 1811 WRITE_FIELD(this, offset, value); | 1811 WRITE_FIELD(this, offset, value); |
| 1812 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); | 1812 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); |
| 1813 } | 1813 } |
| 1814 | 1814 |
| 1815 | 1815 |
| 1816 void FixedArray::fast_set(FixedArray* array, int index, Object* value) { | 1816 void FixedArray::NoWriteBarrierSet(FixedArray* array, |
| 1817 int index, |
| 1818 Object* value) { |
| 1817 ASSERT(array->map() != HEAP->raw_unchecked_fixed_cow_array_map()); | 1819 ASSERT(array->map() != HEAP->raw_unchecked_fixed_cow_array_map()); |
| 1818 ASSERT(index >= 0 && index < array->length()); | 1820 ASSERT(index >= 0 && index < array->length()); |
| 1819 ASSERT(!HEAP->InNewSpace(value)); | 1821 ASSERT(!HEAP->InNewSpace(value)); |
| 1820 WRITE_FIELD(array, kHeaderSize + index * kPointerSize, value); | 1822 WRITE_FIELD(array, kHeaderSize + index * kPointerSize, value); |
| 1821 array->GetHeap()->incremental_marking()->RecordWrite( | |
| 1822 array, | |
| 1823 HeapObject::RawField(array, kHeaderSize + index * kPointerSize), | |
| 1824 value); | |
| 1825 } | 1823 } |
| 1826 | 1824 |
| 1827 | 1825 |
| 1828 void FixedArray::set_undefined(int index) { | 1826 void FixedArray::set_undefined(int index) { |
| 1829 ASSERT(map() != HEAP->fixed_cow_array_map()); | 1827 ASSERT(map() != HEAP->fixed_cow_array_map()); |
| 1830 set_undefined(GetHeap(), index); | 1828 set_undefined(GetHeap(), index); |
| 1831 } | 1829 } |
| 1832 | 1830 |
| 1833 | 1831 |
| 1834 void FixedArray::set_undefined(Heap* heap, int index) { | 1832 void FixedArray::set_undefined(Heap* heap, int index) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1902 Object* storage = READ_FIELD(this, kBitField3StorageOffset); | 1900 Object* storage = READ_FIELD(this, kBitField3StorageOffset); |
| 1903 return Smi::cast(storage)->value(); | 1901 return Smi::cast(storage)->value(); |
| 1904 } | 1902 } |
| 1905 | 1903 |
| 1906 void DescriptorArray::set_bit_field3_storage(int value) { | 1904 void DescriptorArray::set_bit_field3_storage(int value) { |
| 1907 ASSERT(!IsEmpty()); | 1905 ASSERT(!IsEmpty()); |
| 1908 WRITE_FIELD(this, kBitField3StorageOffset, Smi::FromInt(value)); | 1906 WRITE_FIELD(this, kBitField3StorageOffset, Smi::FromInt(value)); |
| 1909 } | 1907 } |
| 1910 | 1908 |
| 1911 | 1909 |
| 1912 void DescriptorArray::fast_swap(FixedArray* array, int first, int second) { | 1910 void DescriptorArray::NoWriteBarrierSwap(FixedArray* array, |
| 1911 int first, |
| 1912 int second) { |
| 1913 Object* tmp = array->get(first); | 1913 Object* tmp = array->get(first); |
| 1914 fast_set(array, first, array->get(second)); | 1914 NoWriteBarrierSet(array, first, array->get(second)); |
| 1915 fast_set(array, second, tmp); | 1915 NoWriteBarrierSet(array, second, tmp); |
| 1916 } | 1916 } |
| 1917 | 1917 |
| 1918 | 1918 |
| 1919 int DescriptorArray::Search(String* name) { | 1919 int DescriptorArray::Search(String* name) { |
| 1920 SLOW_ASSERT(IsSortedNoDuplicates()); | 1920 SLOW_ASSERT(IsSortedNoDuplicates()); |
| 1921 | 1921 |
| 1922 // Check for empty descriptor array. | 1922 // Check for empty descriptor array. |
| 1923 int nof = number_of_descriptors(); | 1923 int nof = number_of_descriptors(); |
| 1924 if (nof == 0) return kNotFound; | 1924 if (nof == 0) return kNotFound; |
| 1925 | 1925 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2013 } | 2013 } |
| 2014 | 2014 |
| 2015 | 2015 |
| 2016 void DescriptorArray::Get(int descriptor_number, Descriptor* desc) { | 2016 void DescriptorArray::Get(int descriptor_number, Descriptor* desc) { |
| 2017 desc->Init(GetKey(descriptor_number), | 2017 desc->Init(GetKey(descriptor_number), |
| 2018 GetValue(descriptor_number), | 2018 GetValue(descriptor_number), |
| 2019 PropertyDetails(GetDetails(descriptor_number))); | 2019 PropertyDetails(GetDetails(descriptor_number))); |
| 2020 } | 2020 } |
| 2021 | 2021 |
| 2022 | 2022 |
| 2023 void DescriptorArray::Set(int descriptor_number, Descriptor* desc) { | 2023 void DescriptorArray::Set(int descriptor_number, |
| 2024 Descriptor* desc, |
| 2025 const WhitenessWitness&) { |
| 2024 // Range check. | 2026 // Range check. |
| 2025 ASSERT(descriptor_number < number_of_descriptors()); | 2027 ASSERT(descriptor_number < number_of_descriptors()); |
| 2026 | 2028 |
| 2027 // Make sure none of the elements in desc are in new space. | 2029 // Make sure none of the elements in desc are in new space. |
| 2028 ASSERT(!HEAP->InNewSpace(desc->GetKey())); | 2030 ASSERT(!HEAP->InNewSpace(desc->GetKey())); |
| 2029 ASSERT(!HEAP->InNewSpace(desc->GetValue())); | 2031 ASSERT(!HEAP->InNewSpace(desc->GetValue())); |
| 2030 | 2032 |
| 2031 fast_set(this, ToKeyIndex(descriptor_number), desc->GetKey()); | 2033 NoWriteBarrierSet(this, |
| 2034 ToKeyIndex(descriptor_number), |
| 2035 desc->GetKey()); |
| 2032 FixedArray* content_array = GetContentArray(); | 2036 FixedArray* content_array = GetContentArray(); |
| 2033 fast_set(content_array, ToValueIndex(descriptor_number), desc->GetValue()); | 2037 NoWriteBarrierSet(content_array, |
| 2034 fast_set(content_array, ToDetailsIndex(descriptor_number), | 2038 ToValueIndex(descriptor_number), |
| 2035 desc->GetDetails().AsSmi()); | 2039 desc->GetValue()); |
| 2040 NoWriteBarrierSet(content_array, |
| 2041 ToDetailsIndex(descriptor_number), |
| 2042 desc->GetDetails().AsSmi()); |
| 2036 } | 2043 } |
| 2037 | 2044 |
| 2038 | 2045 |
| 2039 void DescriptorArray::CopyFrom(int index, DescriptorArray* src, int src_index) { | 2046 void DescriptorArray::CopyFrom(int index, |
| 2047 DescriptorArray* src, |
| 2048 int src_index, |
| 2049 const WhitenessWitness& witness) { |
| 2040 Descriptor desc; | 2050 Descriptor desc; |
| 2041 src->Get(src_index, &desc); | 2051 src->Get(src_index, &desc); |
| 2042 Set(index, &desc); | 2052 Set(index, &desc, witness); |
| 2043 } | 2053 } |
| 2044 | 2054 |
| 2045 | 2055 |
| 2046 void DescriptorArray::Swap(int first, int second) { | 2056 void DescriptorArray::NoWriteBarrierSwapDescriptors(int first, int second) { |
| 2047 fast_swap(this, ToKeyIndex(first), ToKeyIndex(second)); | 2057 NoWriteBarrierSwap(this, ToKeyIndex(first), ToKeyIndex(second)); |
| 2048 FixedArray* content_array = GetContentArray(); | 2058 FixedArray* content_array = GetContentArray(); |
| 2049 fast_swap(content_array, ToValueIndex(first), ToValueIndex(second)); | 2059 NoWriteBarrierSwap(content_array, |
| 2050 fast_swap(content_array, ToDetailsIndex(first), ToDetailsIndex(second)); | 2060 ToValueIndex(first), |
| 2061 ToValueIndex(second)); |
| 2062 NoWriteBarrierSwap(content_array, |
| 2063 ToDetailsIndex(first), |
| 2064 ToDetailsIndex(second)); |
| 2051 } | 2065 } |
| 2052 | 2066 |
| 2053 | 2067 |
| 2068 DescriptorArray::WhitenessWitness::WhitenessWitness(DescriptorArray* array) |
| 2069 : marking_(array->GetHeap()->incremental_marking()) { |
| 2070 marking_->EnterNoMarkingScope(); |
| 2071 if (array->number_of_descriptors() > 0) { |
| 2072 ASSERT(Marking::Color(array) == Marking::WHITE_OBJECT); |
| 2073 ASSERT(Marking::Color(array->GetContentArray()) == Marking::WHITE_OBJECT); |
| 2074 } |
| 2075 } |
| 2076 |
| 2077 |
| 2078 DescriptorArray::WhitenessWitness::~WhitenessWitness() { |
| 2079 marking_->LeaveNoMarkingScope(); |
| 2080 } |
| 2081 |
| 2082 |
| 2054 template<typename Shape, typename Key> | 2083 template<typename Shape, typename Key> |
| 2055 int HashTable<Shape, Key>::ComputeCapacity(int at_least_space_for) { | 2084 int HashTable<Shape, Key>::ComputeCapacity(int at_least_space_for) { |
| 2056 const int kMinCapacity = 32; | 2085 const int kMinCapacity = 32; |
| 2057 int capacity = RoundUpToPowerOf2(at_least_space_for * 2); | 2086 int capacity = RoundUpToPowerOf2(at_least_space_for * 2); |
| 2058 if (capacity < kMinCapacity) { | 2087 if (capacity < kMinCapacity) { |
| 2059 capacity = kMinCapacity; // Guarantee min capacity. | 2088 capacity = kMinCapacity; // Guarantee min capacity. |
| 2060 } | 2089 } |
| 2061 return capacity; | 2090 return capacity; |
| 2062 } | 2091 } |
| 2063 | 2092 |
| (...skipping 2390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4454 void Dictionary<Shape, Key>::SetEntry(int entry, | 4483 void Dictionary<Shape, Key>::SetEntry(int entry, |
| 4455 Object* key, | 4484 Object* key, |
| 4456 Object* value, | 4485 Object* value, |
| 4457 PropertyDetails details) { | 4486 PropertyDetails details) { |
| 4458 ASSERT(!key->IsString() || details.IsDeleted() || details.index() > 0); | 4487 ASSERT(!key->IsString() || details.IsDeleted() || details.index() > 0); |
| 4459 int index = HashTable<Shape, Key>::EntryToIndex(entry); | 4488 int index = HashTable<Shape, Key>::EntryToIndex(entry); |
| 4460 AssertNoAllocation no_gc; | 4489 AssertNoAllocation no_gc; |
| 4461 WriteBarrierMode mode = FixedArray::GetWriteBarrierMode(no_gc); | 4490 WriteBarrierMode mode = FixedArray::GetWriteBarrierMode(no_gc); |
| 4462 FixedArray::set(index, key, mode); | 4491 FixedArray::set(index, key, mode); |
| 4463 FixedArray::set(index+1, value, mode); | 4492 FixedArray::set(index+1, value, mode); |
| 4464 FixedArray::fast_set(this, index+2, details.AsSmi()); | 4493 FixedArray::NoWriteBarrierSet(this, index+2, details.AsSmi()); |
| 4465 } | 4494 } |
| 4466 | 4495 |
| 4467 | 4496 |
| 4468 bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) { | 4497 bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) { |
| 4469 ASSERT(other->IsNumber()); | 4498 ASSERT(other->IsNumber()); |
| 4470 return key == static_cast<uint32_t>(other->Number()); | 4499 return key == static_cast<uint32_t>(other->Number()); |
| 4471 } | 4500 } |
| 4472 | 4501 |
| 4473 | 4502 |
| 4474 uint32_t NumberDictionaryShape::Hash(uint32_t key) { | 4503 uint32_t NumberDictionaryShape::Hash(uint32_t key) { |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4694 #undef WRITE_INT_FIELD | 4723 #undef WRITE_INT_FIELD |
| 4695 #undef READ_SHORT_FIELD | 4724 #undef READ_SHORT_FIELD |
| 4696 #undef WRITE_SHORT_FIELD | 4725 #undef WRITE_SHORT_FIELD |
| 4697 #undef READ_BYTE_FIELD | 4726 #undef READ_BYTE_FIELD |
| 4698 #undef WRITE_BYTE_FIELD | 4727 #undef WRITE_BYTE_FIELD |
| 4699 | 4728 |
| 4700 | 4729 |
| 4701 } } // namespace v8::internal | 4730 } } // namespace v8::internal |
| 4702 | 4731 |
| 4703 #endif // V8_OBJECTS_INL_H_ | 4732 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |