OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1961 WRITE_FIELD(this, offset, value); | 1961 WRITE_FIELD(this, offset, value); |
1962 WRITE_BARRIER(GetHeap(), this, offset, value); | 1962 WRITE_BARRIER(GetHeap(), this, offset, value); |
1963 } else { | 1963 } else { |
1964 ASSERT(index < properties()->length()); | 1964 ASSERT(index < properties()->length()); |
1965 properties()->set(index, value); | 1965 properties()->set(index, value); |
1966 } | 1966 } |
1967 } | 1967 } |
1968 | 1968 |
1969 | 1969 |
1970 int JSObject::GetInObjectPropertyOffset(int index) { | 1970 int JSObject::GetInObjectPropertyOffset(int index) { |
1971 // Adjust for the number of properties stored in the object. | 1971 return map()->GetInObjectPropertyOffset(index); |
1972 index -= map()->inobject_properties(); | |
1973 ASSERT(index < 0); | |
1974 return map()->instance_size() + (index * kPointerSize); | |
1975 } | 1972 } |
1976 | 1973 |
1977 | 1974 |
1978 Object* JSObject::InObjectPropertyAt(int index) { | 1975 Object* JSObject::InObjectPropertyAt(int index) { |
1979 // Adjust for the number of properties stored in the object. | 1976 int offset = GetInObjectPropertyOffset(index); |
1980 index -= map()->inobject_properties(); | |
1981 ASSERT(index < 0); | |
1982 int offset = map()->instance_size() + (index * kPointerSize); | |
1983 return READ_FIELD(this, offset); | 1977 return READ_FIELD(this, offset); |
1984 } | 1978 } |
1985 | 1979 |
1986 | 1980 |
1987 Object* JSObject::InObjectPropertyAtPut(int index, | 1981 Object* JSObject::InObjectPropertyAtPut(int index, |
1988 Object* value, | 1982 Object* value, |
1989 WriteBarrierMode mode) { | 1983 WriteBarrierMode mode) { |
1990 // Adjust for the number of properties stored in the object. | 1984 // Adjust for the number of properties stored in the object. |
1991 index -= map()->inobject_properties(); | 1985 int offset = GetInObjectPropertyOffset(index); |
1992 ASSERT(index < 0); | |
1993 int offset = map()->instance_size() + (index * kPointerSize); | |
1994 WRITE_FIELD(this, offset, value); | 1986 WRITE_FIELD(this, offset, value); |
1995 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); | 1987 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); |
1996 return value; | 1988 return value; |
1997 } | 1989 } |
1998 | 1990 |
1999 | 1991 |
2000 | 1992 |
2001 void JSObject::InitializeBody(Map* map, | 1993 void JSObject::InitializeBody(Map* map, |
2002 Object* pre_allocated_value, | 1994 Object* pre_allocated_value, |
2003 Object* filler_value) { | 1995 Object* filler_value) { |
(...skipping 1780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3784 int Map::inobject_properties() { | 3776 int Map::inobject_properties() { |
3785 return READ_BYTE_FIELD(this, kInObjectPropertiesOffset); | 3777 return READ_BYTE_FIELD(this, kInObjectPropertiesOffset); |
3786 } | 3778 } |
3787 | 3779 |
3788 | 3780 |
3789 int Map::pre_allocated_property_fields() { | 3781 int Map::pre_allocated_property_fields() { |
3790 return READ_BYTE_FIELD(this, kPreAllocatedPropertyFieldsOffset); | 3782 return READ_BYTE_FIELD(this, kPreAllocatedPropertyFieldsOffset); |
3791 } | 3783 } |
3792 | 3784 |
3793 | 3785 |
| 3786 int Map::GetInObjectPropertyOffset(int index) { |
| 3787 // Adjust for the number of properties stored in the object. |
| 3788 index -= inobject_properties(); |
| 3789 ASSERT(index < 0); |
| 3790 return instance_size() + (index * kPointerSize); |
| 3791 } |
| 3792 |
| 3793 |
3794 int HeapObject::SizeFromMap(Map* map) { | 3794 int HeapObject::SizeFromMap(Map* map) { |
3795 int instance_size = map->instance_size(); | 3795 int instance_size = map->instance_size(); |
3796 if (instance_size != kVariableSizeSentinel) return instance_size; | 3796 if (instance_size != kVariableSizeSentinel) return instance_size; |
3797 // Only inline the most frequent cases. | 3797 // Only inline the most frequent cases. |
3798 int instance_type = static_cast<int>(map->instance_type()); | 3798 int instance_type = static_cast<int>(map->instance_type()); |
3799 if (instance_type == FIXED_ARRAY_TYPE) { | 3799 if (instance_type == FIXED_ARRAY_TYPE) { |
3800 return FixedArray::BodyDescriptor::SizeOf(map, this); | 3800 return FixedArray::BodyDescriptor::SizeOf(map, this); |
3801 } | 3801 } |
3802 if (instance_type == ASCII_STRING_TYPE || | 3802 if (instance_type == ASCII_STRING_TYPE || |
3803 instance_type == ASCII_INTERNALIZED_STRING_TYPE) { | 3803 instance_type == ASCII_INTERNALIZED_STRING_TYPE) { |
(...skipping 2983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6787 #undef READ_UINT32_FIELD | 6787 #undef READ_UINT32_FIELD |
6788 #undef WRITE_UINT32_FIELD | 6788 #undef WRITE_UINT32_FIELD |
6789 #undef READ_SHORT_FIELD | 6789 #undef READ_SHORT_FIELD |
6790 #undef WRITE_SHORT_FIELD | 6790 #undef WRITE_SHORT_FIELD |
6791 #undef READ_BYTE_FIELD | 6791 #undef READ_BYTE_FIELD |
6792 #undef WRITE_BYTE_FIELD | 6792 #undef WRITE_BYTE_FIELD |
6793 | 6793 |
6794 } } // namespace v8::internal | 6794 } } // namespace v8::internal |
6795 | 6795 |
6796 #endif // V8_OBJECTS_INL_H_ | 6796 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |