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 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1667 WRITE_FIELD(this, kHeaderSize + index * kPointerSize, heap->null_value()); | 1667 WRITE_FIELD(this, kHeaderSize + index * kPointerSize, heap->null_value()); |
1668 } | 1668 } |
1669 | 1669 |
1670 | 1670 |
1671 Object** FixedArray::data_start() { | 1671 Object** FixedArray::data_start() { |
1672 return HeapObject::RawField(this, kHeaderSize); | 1672 return HeapObject::RawField(this, kHeaderSize); |
1673 } | 1673 } |
1674 | 1674 |
1675 | 1675 |
1676 bool DescriptorArray::IsEmpty() { | 1676 bool DescriptorArray::IsEmpty() { |
1677 ASSERT(this->length() > kFirstIndex || | 1677 ASSERT(this->IsSmi() || |
| 1678 this->length() > kFirstIndex || |
1678 this == HEAP->empty_descriptor_array()); | 1679 this == HEAP->empty_descriptor_array()); |
1679 return length() <= kFirstIndex; | 1680 return this->IsSmi() || length() <= kFirstIndex; |
1680 } | 1681 } |
1681 | 1682 |
1682 | 1683 |
| 1684 int DescriptorArray::bit_field3_storage() { |
| 1685 Object* storage = READ_FIELD(this, kBitField3StorageOffset); |
| 1686 return Smi::cast(storage)->value(); |
| 1687 } |
| 1688 |
| 1689 void DescriptorArray::set_bit_field3_storage(int value) { |
| 1690 ASSERT(!IsEmpty()); |
| 1691 WRITE_FIELD(this, kBitField3StorageOffset, Smi::FromInt(value)); |
| 1692 } |
| 1693 |
| 1694 |
1683 void DescriptorArray::fast_swap(FixedArray* array, int first, int second) { | 1695 void DescriptorArray::fast_swap(FixedArray* array, int first, int second) { |
1684 Object* tmp = array->get(first); | 1696 Object* tmp = array->get(first); |
1685 fast_set(array, first, array->get(second)); | 1697 fast_set(array, first, array->get(second)); |
1686 fast_set(array, second, tmp); | 1698 fast_set(array, second, tmp); |
1687 } | 1699 } |
1688 | 1700 |
1689 | 1701 |
1690 int DescriptorArray::Search(String* name) { | 1702 int DescriptorArray::Search(String* name) { |
1691 SLOW_ASSERT(IsSortedNoDuplicates()); | 1703 SLOW_ASSERT(IsSortedNoDuplicates()); |
1692 | 1704 |
(...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2960 { MaybeObject* maybe_obj = CopyDropTransitions(); | 2972 { MaybeObject* maybe_obj = CopyDropTransitions(); |
2961 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 2973 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
2962 } | 2974 } |
2963 Map* new_map = Map::cast(obj); | 2975 Map* new_map = Map::cast(obj); |
2964 new_map->set_has_fast_elements(false); | 2976 new_map->set_has_fast_elements(false); |
2965 isolate()->counters()->map_fast_to_slow_elements()->Increment(); | 2977 isolate()->counters()->map_fast_to_slow_elements()->Increment(); |
2966 return new_map; | 2978 return new_map; |
2967 } | 2979 } |
2968 | 2980 |
2969 | 2981 |
2970 ACCESSORS(Map, instance_descriptors, DescriptorArray, | 2982 DescriptorArray* Map::instance_descriptors() { |
2971 kInstanceDescriptorsOffset) | 2983 Object* object = READ_FIELD(this, kInstanceDescriptorsOrBitField3Offset); |
| 2984 if (object->IsSmi()) { |
| 2985 return HEAP->empty_descriptor_array(); |
| 2986 } else { |
| 2987 return DescriptorArray::cast(object); |
| 2988 } |
| 2989 } |
| 2990 |
| 2991 |
| 2992 void Map::init_instance_descriptors() { |
| 2993 WRITE_FIELD(this, kInstanceDescriptorsOrBitField3Offset, Smi::FromInt(0)); |
| 2994 } |
| 2995 |
| 2996 |
| 2997 void Map::clear_instance_descriptors() { |
| 2998 Object* object = READ_FIELD(this, |
| 2999 kInstanceDescriptorsOrBitField3Offset); |
| 3000 if (!object->IsSmi()) { |
| 3001 WRITE_FIELD( |
| 3002 this, |
| 3003 kInstanceDescriptorsOrBitField3Offset, |
| 3004 Smi::FromInt(DescriptorArray::cast(object)->bit_field3_storage())); |
| 3005 } |
| 3006 } |
| 3007 |
| 3008 |
| 3009 void Map::set_instance_descriptors(DescriptorArray* value, |
| 3010 WriteBarrierMode mode) { |
| 3011 Object* object = READ_FIELD(this, |
| 3012 kInstanceDescriptorsOrBitField3Offset); |
| 3013 if (value == isolate()->heap()->empty_descriptor_array()) { |
| 3014 clear_instance_descriptors(); |
| 3015 return; |
| 3016 } else { |
| 3017 if (object->IsSmi()) { |
| 3018 value->set_bit_field3_storage(Smi::cast(object)->value()); |
| 3019 } else { |
| 3020 value->set_bit_field3_storage( |
| 3021 DescriptorArray::cast(object)->bit_field3_storage()); |
| 3022 } |
| 3023 } |
| 3024 ASSERT(!is_shared()); |
| 3025 WRITE_FIELD(this, kInstanceDescriptorsOrBitField3Offset, value); |
| 3026 CONDITIONAL_WRITE_BARRIER(GetHeap(), |
| 3027 this, |
| 3028 kInstanceDescriptorsOrBitField3Offset, |
| 3029 mode); |
| 3030 } |
| 3031 |
| 3032 |
| 3033 int Map::bit_field3() { |
| 3034 Object* object = READ_FIELD(this, |
| 3035 kInstanceDescriptorsOrBitField3Offset); |
| 3036 if (object->IsSmi()) { |
| 3037 return Smi::cast(object)->value(); |
| 3038 } else { |
| 3039 return DescriptorArray::cast(object)->bit_field3_storage(); |
| 3040 } |
| 3041 } |
| 3042 |
| 3043 |
| 3044 void Map::set_bit_field3(int value) { |
| 3045 ASSERT(Smi::IsValid(value)); |
| 3046 Object* object = READ_FIELD(this, |
| 3047 kInstanceDescriptorsOrBitField3Offset); |
| 3048 if (object->IsSmi()) { |
| 3049 WRITE_FIELD(this, |
| 3050 kInstanceDescriptorsOrBitField3Offset, |
| 3051 Smi::FromInt(value)); |
| 3052 } else { |
| 3053 DescriptorArray::cast(object)->set_bit_field3_storage(value); |
| 3054 } |
| 3055 } |
| 3056 |
| 3057 |
2972 ACCESSORS(Map, code_cache, Object, kCodeCacheOffset) | 3058 ACCESSORS(Map, code_cache, Object, kCodeCacheOffset) |
2973 ACCESSORS(Map, prototype_transitions, FixedArray, kPrototypeTransitionsOffset) | 3059 ACCESSORS(Map, prototype_transitions, FixedArray, kPrototypeTransitionsOffset) |
2974 ACCESSORS(Map, constructor, Object, kConstructorOffset) | 3060 ACCESSORS(Map, constructor, Object, kConstructorOffset) |
2975 | 3061 |
2976 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset) | 3062 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset) |
2977 ACCESSORS(JSFunction, literals, FixedArray, kLiteralsOffset) | 3063 ACCESSORS(JSFunction, literals, FixedArray, kLiteralsOffset) |
2978 ACCESSORS_GCSAFE(JSFunction, next_function_link, Object, | 3064 ACCESSORS_GCSAFE(JSFunction, next_function_link, Object, |
2979 kNextFunctionLinkOffset) | 3065 kNextFunctionLinkOffset) |
2980 | 3066 |
2981 ACCESSORS(GlobalObject, builtins, JSBuiltinsObject, kBuiltinsOffset) | 3067 ACCESSORS(GlobalObject, builtins, JSBuiltinsObject, kBuiltinsOffset) |
(...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4228 #undef WRITE_INT_FIELD | 4314 #undef WRITE_INT_FIELD |
4229 #undef READ_SHORT_FIELD | 4315 #undef READ_SHORT_FIELD |
4230 #undef WRITE_SHORT_FIELD | 4316 #undef WRITE_SHORT_FIELD |
4231 #undef READ_BYTE_FIELD | 4317 #undef READ_BYTE_FIELD |
4232 #undef WRITE_BYTE_FIELD | 4318 #undef WRITE_BYTE_FIELD |
4233 | 4319 |
4234 | 4320 |
4235 } } // namespace v8::internal | 4321 } } // namespace v8::internal |
4236 | 4322 |
4237 #endif // V8_OBJECTS_INL_H_ | 4323 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |