| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1342 | 1342 |
| 1343 | 1343 |
| 1344 void FixedArray::set(int index, Object* value) { | 1344 void FixedArray::set(int index, Object* value) { |
| 1345 ASSERT(index >= 0 && index < this->length()); | 1345 ASSERT(index >= 0 && index < this->length()); |
| 1346 int offset = kHeaderSize + index * kPointerSize; | 1346 int offset = kHeaderSize + index * kPointerSize; |
| 1347 WRITE_FIELD(this, offset, value); | 1347 WRITE_FIELD(this, offset, value); |
| 1348 WRITE_BARRIER(this, offset); | 1348 WRITE_BARRIER(this, offset); |
| 1349 } | 1349 } |
| 1350 | 1350 |
| 1351 | 1351 |
| 1352 WriteBarrierMode HeapObject::GetWriteBarrierMode() { | 1352 WriteBarrierMode HeapObject::GetWriteBarrierMode(const AssertNoAllocation&) { |
| 1353 if (Heap::InNewSpace(this)) return SKIP_WRITE_BARRIER; | 1353 if (Heap::InNewSpace(this)) return SKIP_WRITE_BARRIER; |
| 1354 return UPDATE_WRITE_BARRIER; | 1354 return UPDATE_WRITE_BARRIER; |
| 1355 } | 1355 } |
| 1356 | 1356 |
| 1357 | 1357 |
| 1358 void FixedArray::set(int index, | 1358 void FixedArray::set(int index, |
| 1359 Object* value, | 1359 Object* value, |
| 1360 WriteBarrierMode mode) { | 1360 WriteBarrierMode mode) { |
| 1361 ASSERT(index >= 0 && index < this->length()); | 1361 ASSERT(index >= 0 && index < this->length()); |
| 1362 int offset = kHeaderSize + index * kPointerSize; | 1362 int offset = kHeaderSize + index * kPointerSize; |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1541 | 1541 |
| 1542 uint32_t NumberDictionary::max_number_key() { | 1542 uint32_t NumberDictionary::max_number_key() { |
| 1543 ASSERT(!requires_slow_elements()); | 1543 ASSERT(!requires_slow_elements()); |
| 1544 Object* max_index_object = get(kMaxNumberKeyIndex); | 1544 Object* max_index_object = get(kMaxNumberKeyIndex); |
| 1545 if (!max_index_object->IsSmi()) return 0; | 1545 if (!max_index_object->IsSmi()) return 0; |
| 1546 uint32_t value = static_cast<uint32_t>(Smi::cast(max_index_object)->value()); | 1546 uint32_t value = static_cast<uint32_t>(Smi::cast(max_index_object)->value()); |
| 1547 return value >> kRequiresSlowElementsTagSize; | 1547 return value >> kRequiresSlowElementsTagSize; |
| 1548 } | 1548 } |
| 1549 | 1549 |
| 1550 void NumberDictionary::set_requires_slow_elements() { | 1550 void NumberDictionary::set_requires_slow_elements() { |
| 1551 set(kMaxNumberKeyIndex, | 1551 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask)); |
| 1552 Smi::FromInt(kRequiresSlowElementsMask), | |
| 1553 SKIP_WRITE_BARRIER); | |
| 1554 } | 1552 } |
| 1555 | 1553 |
| 1556 | 1554 |
| 1557 // ------------------------------------ | 1555 // ------------------------------------ |
| 1558 // Cast operations | 1556 // Cast operations |
| 1559 | 1557 |
| 1560 | 1558 |
| 1561 CAST_ACCESSOR(FixedArray) | 1559 CAST_ACCESSOR(FixedArray) |
| 1562 CAST_ACCESSOR(DescriptorArray) | 1560 CAST_ACCESSOR(DescriptorArray) |
| 1563 CAST_ACCESSOR(SymbolTable) | 1561 CAST_ACCESSOR(SymbolTable) |
| (...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2966 set_flag(Smi::FromInt(rest_value | AttributesField::encode(attributes))); | 2964 set_flag(Smi::FromInt(rest_value | AttributesField::encode(attributes))); |
| 2967 } | 2965 } |
| 2968 | 2966 |
| 2969 template<typename Shape, typename Key> | 2967 template<typename Shape, typename Key> |
| 2970 void Dictionary<Shape, Key>::SetEntry(int entry, | 2968 void Dictionary<Shape, Key>::SetEntry(int entry, |
| 2971 Object* key, | 2969 Object* key, |
| 2972 Object* value, | 2970 Object* value, |
| 2973 PropertyDetails details) { | 2971 PropertyDetails details) { |
| 2974 ASSERT(!key->IsString() || details.IsDeleted() || details.index() > 0); | 2972 ASSERT(!key->IsString() || details.IsDeleted() || details.index() > 0); |
| 2975 int index = HashTable<Shape, Key>::EntryToIndex(entry); | 2973 int index = HashTable<Shape, Key>::EntryToIndex(entry); |
| 2976 WriteBarrierMode mode = FixedArray::GetWriteBarrierMode(); | 2974 AssertNoAllocation no_gc; |
| 2975 WriteBarrierMode mode = FixedArray::GetWriteBarrierMode(no_gc); |
| 2977 FixedArray::set(index, key, mode); | 2976 FixedArray::set(index, key, mode); |
| 2978 FixedArray::set(index+1, value, mode); | 2977 FixedArray::set(index+1, value, mode); |
| 2979 FixedArray::fast_set(this, index+2, details.AsSmi()); | 2978 FixedArray::fast_set(this, index+2, details.AsSmi()); |
| 2980 } | 2979 } |
| 2981 | 2980 |
| 2982 | 2981 |
| 2983 void Map::ClearCodeCache() { | 2982 void Map::ClearCodeCache() { |
| 2984 // No write barrier is needed since empty_fixed_array is not in new space. | 2983 // No write barrier is needed since empty_fixed_array is not in new space. |
| 2985 // Please note this function is used during marking: | 2984 // Please note this function is used during marking: |
| 2986 // - MarkCompactCollector::MarkUnmarkedObject | 2985 // - MarkCompactCollector::MarkUnmarkedObject |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3000 // It's a performance benefit to keep a frequently used array in new-space. | 2999 // It's a performance benefit to keep a frequently used array in new-space. |
| 3001 } else if (!Heap::new_space()->Contains(elts) && | 3000 } else if (!Heap::new_space()->Contains(elts) && |
| 3002 required_size < kArraySizeThatFitsComfortablyInNewSpace) { | 3001 required_size < kArraySizeThatFitsComfortablyInNewSpace) { |
| 3003 // Expand will allocate a new backing store in new space even if the size | 3002 // Expand will allocate a new backing store in new space even if the size |
| 3004 // we asked for isn't larger than what we had before. | 3003 // we asked for isn't larger than what we had before. |
| 3005 Expand(required_size); | 3004 Expand(required_size); |
| 3006 } | 3005 } |
| 3007 } | 3006 } |
| 3008 | 3007 |
| 3009 | 3008 |
| 3009 void JSArray::set_length(Smi* length) { |
| 3010 set_length(static_cast<Object*>(length), SKIP_WRITE_BARRIER); |
| 3011 } |
| 3012 |
| 3013 |
| 3010 void JSArray::SetContent(FixedArray* storage) { | 3014 void JSArray::SetContent(FixedArray* storage) { |
| 3011 set_length(Smi::FromInt(storage->length()), SKIP_WRITE_BARRIER); | 3015 set_length(Smi::FromInt(storage->length())); |
| 3012 set_elements(storage); | 3016 set_elements(storage); |
| 3013 } | 3017 } |
| 3014 | 3018 |
| 3015 | 3019 |
| 3016 Object* FixedArray::Copy() { | 3020 Object* FixedArray::Copy() { |
| 3017 if (length() == 0) return this; | 3021 if (length() == 0) return this; |
| 3018 return Heap::CopyFixedArray(this); | 3022 return Heap::CopyFixedArray(this); |
| 3019 } | 3023 } |
| 3020 | 3024 |
| 3021 | 3025 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3036 #undef WRITE_INT_FIELD | 3040 #undef WRITE_INT_FIELD |
| 3037 #undef READ_SHORT_FIELD | 3041 #undef READ_SHORT_FIELD |
| 3038 #undef WRITE_SHORT_FIELD | 3042 #undef WRITE_SHORT_FIELD |
| 3039 #undef READ_BYTE_FIELD | 3043 #undef READ_BYTE_FIELD |
| 3040 #undef WRITE_BYTE_FIELD | 3044 #undef WRITE_BYTE_FIELD |
| 3041 | 3045 |
| 3042 | 3046 |
| 3043 } } // namespace v8::internal | 3047 } } // namespace v8::internal |
| 3044 | 3048 |
| 3045 #endif // V8_OBJECTS_INL_H_ | 3049 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |