Chromium Code Reviews| 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 !IsEmpty(); | |
|
Mads Ager (chromium)
2011/05/23 10:14:51
ASSERT(!IsEmpty()) ?
danno
2011/06/01 13:15:11
Done.
| |
| 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, |
|
Mads Ager (chromium)
2011/05/23 10:14:51
Doesn't this fit on one line? Ditto for the occurr
danno
2011/06/01 13:15:11
Done.
| |
| 2984 kInstanceDescriptorsOrBitField3Offset); | |
| 2985 if (object->IsSmi()) { | |
| 2986 return HEAP->empty_descriptor_array(); | |
| 2987 } else { | |
| 2988 return DescriptorArray::cast(object); | |
| 2989 } | |
| 2990 } | |
| 2991 | |
| 2992 | |
| 2993 void Map::init_instance_descriptors() { | |
| 2994 WRITE_FIELD(this, | |
| 2995 kInstanceDescriptorsOrBitField3Offset, | |
| 2996 0); | |
|
Mads Ager (chromium)
2011/05/23 10:14:51
Smi::FromInt(0)
It is the same, but makes it expl
danno
2011/06/01 13:15:11
Done.
| |
| 2997 } | |
| 2998 | |
| 2999 | |
| 3000 void Map::clear_instance_descriptors() { | |
| 3001 Object* object = READ_FIELD(this, | |
| 3002 kInstanceDescriptorsOrBitField3Offset); | |
| 3003 if (!object->IsSmi()) { | |
| 3004 WRITE_FIELD( | |
| 3005 this, | |
| 3006 kInstanceDescriptorsOrBitField3Offset, | |
| 3007 Smi::FromInt(DescriptorArray::cast(object)->bit_field3_storage())); | |
| 3008 } | |
| 3009 } | |
| 3010 | |
| 3011 | |
| 3012 void Map::set_instance_descriptors(DescriptorArray* value, | |
| 3013 WriteBarrierMode mode) { | |
| 3014 Object* object = READ_FIELD(this, | |
| 3015 kInstanceDescriptorsOrBitField3Offset); | |
| 3016 if (value == HEAP->empty_descriptor_array()) { | |
|
Mads Ager (chromium)
2011/05/23 10:14:51
You shouldn't have to go through thread local stor
danno
2011/06/01 13:15:11
Done.
| |
| 3017 clear_instance_descriptors(); | |
| 3018 return; | |
| 3019 } else { | |
| 3020 if (object->IsSmi()) { | |
| 3021 value->set_bit_field3_storage(Smi::cast(object)->value()); | |
| 3022 } else { | |
| 3023 value->set_bit_field3_storage( | |
| 3024 DescriptorArray::cast(object)->bit_field3_storage()); | |
| 3025 } | |
| 3026 } | |
| 3027 ASSERT(!is_shared()); | |
| 3028 WRITE_FIELD(this, kInstanceDescriptorsOrBitField3Offset, value); | |
| 3029 CONDITIONAL_WRITE_BARRIER(GetHeap(), | |
| 3030 this, | |
| 3031 kInstanceDescriptorsOrBitField3Offset, | |
| 3032 mode); | |
| 3033 } | |
| 3034 | |
| 3035 | |
| 3036 int Map::bit_field3() { | |
| 3037 Object* object = READ_FIELD(this, | |
| 3038 kInstanceDescriptorsOrBitField3Offset); | |
| 3039 if (object->IsSmi()) { | |
| 3040 return Smi::cast(object)->value(); | |
| 3041 } else { | |
| 3042 return DescriptorArray::cast(object)->bit_field3_storage(); | |
| 3043 } | |
| 3044 } | |
| 3045 | |
| 3046 | |
| 3047 void Map::set_bit_field3(int value) { | |
| 3048 ASSERT((value & 0x80000000) == 0); // bit_field3 can only contain smis | |
|
Mads Ager (chromium)
2011/05/23 10:14:51
ASSERT(Smi::IsValid(value))
danno
2011/06/01 13:15:11
Done.
| |
| 3049 Object* object = READ_FIELD(this, | |
| 3050 kInstanceDescriptorsOrBitField3Offset); | |
| 3051 if (object->IsSmi()) { | |
| 3052 WRITE_FIELD(this, | |
| 3053 kInstanceDescriptorsOrBitField3Offset, | |
| 3054 Smi::FromInt(value)); | |
| 3055 } else { | |
| 3056 DescriptorArray::cast(object)->set_bit_field3_storage(value); | |
| 3057 } | |
| 3058 } | |
| 3059 | |
| 3060 | |
| 2972 ACCESSORS(Map, code_cache, Object, kCodeCacheOffset) | 3061 ACCESSORS(Map, code_cache, Object, kCodeCacheOffset) |
| 2973 ACCESSORS(Map, prototype_transitions, FixedArray, kPrototypeTransitionsOffset) | 3062 ACCESSORS(Map, prototype_transitions, FixedArray, kPrototypeTransitionsOffset) |
| 2974 ACCESSORS(Map, constructor, Object, kConstructorOffset) | 3063 ACCESSORS(Map, constructor, Object, kConstructorOffset) |
| 2975 | 3064 |
| 2976 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset) | 3065 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset) |
| 2977 ACCESSORS(JSFunction, literals, FixedArray, kLiteralsOffset) | 3066 ACCESSORS(JSFunction, literals, FixedArray, kLiteralsOffset) |
| 2978 ACCESSORS_GCSAFE(JSFunction, next_function_link, Object, | 3067 ACCESSORS_GCSAFE(JSFunction, next_function_link, Object, |
| 2979 kNextFunctionLinkOffset) | 3068 kNextFunctionLinkOffset) |
| 2980 | 3069 |
| 2981 ACCESSORS(GlobalObject, builtins, JSBuiltinsObject, kBuiltinsOffset) | 3070 ACCESSORS(GlobalObject, builtins, JSBuiltinsObject, kBuiltinsOffset) |
| (...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4228 #undef WRITE_INT_FIELD | 4317 #undef WRITE_INT_FIELD |
| 4229 #undef READ_SHORT_FIELD | 4318 #undef READ_SHORT_FIELD |
| 4230 #undef WRITE_SHORT_FIELD | 4319 #undef WRITE_SHORT_FIELD |
| 4231 #undef READ_BYTE_FIELD | 4320 #undef READ_BYTE_FIELD |
| 4232 #undef WRITE_BYTE_FIELD | 4321 #undef WRITE_BYTE_FIELD |
| 4233 | 4322 |
| 4234 | 4323 |
| 4235 } } // namespace v8::internal | 4324 } } // namespace v8::internal |
| 4236 | 4325 |
| 4237 #endif // V8_OBJECTS_INL_H_ | 4326 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |