| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 | 1193 |
| 1194 int JSObject::GetInternalFieldCount() { | 1194 int JSObject::GetInternalFieldCount() { |
| 1195 ASSERT(1 << kPointerSizeLog2 == kPointerSize); | 1195 ASSERT(1 << kPointerSizeLog2 == kPointerSize); |
| 1196 // Make sure to adjust for the number of in-object properties. These | 1196 // Make sure to adjust for the number of in-object properties. These |
| 1197 // properties do contribute to the size, but are not internal fields. | 1197 // properties do contribute to the size, but are not internal fields. |
| 1198 return ((Size() - GetHeaderSize()) >> kPointerSizeLog2) - | 1198 return ((Size() - GetHeaderSize()) >> kPointerSizeLog2) - |
| 1199 map()->inobject_properties(); | 1199 map()->inobject_properties(); |
| 1200 } | 1200 } |
| 1201 | 1201 |
| 1202 | 1202 |
| 1203 int JSObject::GetInternalFieldOffset(int index) { |
| 1204 ASSERT(index < GetInternalFieldCount() && index >= 0); |
| 1205 return GetHeaderSize() + (kPointerSize * index); |
| 1206 } |
| 1207 |
| 1208 |
| 1203 Object* JSObject::GetInternalField(int index) { | 1209 Object* JSObject::GetInternalField(int index) { |
| 1204 ASSERT(index < GetInternalFieldCount() && index >= 0); | 1210 ASSERT(index < GetInternalFieldCount() && index >= 0); |
| 1205 // Internal objects do follow immediately after the header, whereas in-object | 1211 // Internal objects do follow immediately after the header, whereas in-object |
| 1206 // properties are at the end of the object. Therefore there is no need | 1212 // properties are at the end of the object. Therefore there is no need |
| 1207 // to adjust the index here. | 1213 // to adjust the index here. |
| 1208 return READ_FIELD(this, GetHeaderSize() + (kPointerSize * index)); | 1214 return READ_FIELD(this, GetHeaderSize() + (kPointerSize * index)); |
| 1209 } | 1215 } |
| 1210 | 1216 |
| 1211 | 1217 |
| 1212 void JSObject::SetInternalField(int index, Object* value) { | 1218 void JSObject::SetInternalField(int index, Object* value) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1244 WRITE_FIELD(this, offset, value); | 1250 WRITE_FIELD(this, offset, value); |
| 1245 WRITE_BARRIER(this, offset, value); | 1251 WRITE_BARRIER(this, offset, value); |
| 1246 } else { | 1252 } else { |
| 1247 ASSERT(index < properties()->length()); | 1253 ASSERT(index < properties()->length()); |
| 1248 properties()->set(index, value); | 1254 properties()->set(index, value); |
| 1249 } | 1255 } |
| 1250 return value; | 1256 return value; |
| 1251 } | 1257 } |
| 1252 | 1258 |
| 1253 | 1259 |
| 1260 int JSObject::GetInObjectPropertyOffset(int index) { |
| 1261 // Adjust for the number of properties stored in the object. |
| 1262 index -= map()->inobject_properties(); |
| 1263 ASSERT(index < 0); |
| 1264 return map()->instance_size() + (index * kPointerSize); |
| 1265 } |
| 1266 |
| 1267 |
| 1254 Object* JSObject::InObjectPropertyAt(int index) { | 1268 Object* JSObject::InObjectPropertyAt(int index) { |
| 1255 // Adjust for the number of properties stored in the object. | 1269 // Adjust for the number of properties stored in the object. |
| 1256 index -= map()->inobject_properties(); | 1270 index -= map()->inobject_properties(); |
| 1257 ASSERT(index < 0); | 1271 ASSERT(index < 0); |
| 1258 int offset = map()->instance_size() + (index * kPointerSize); | 1272 int offset = map()->instance_size() + (index * kPointerSize); |
| 1259 return READ_FIELD(this, offset); | 1273 return READ_FIELD(this, offset); |
| 1260 } | 1274 } |
| 1261 | 1275 |
| 1262 | 1276 |
| 1263 Object* JSObject::InObjectPropertyAtPut(int index, | 1277 Object* JSObject::InObjectPropertyAtPut(int index, |
| (...skipping 2565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3829 #undef WRITE_INT_FIELD | 3843 #undef WRITE_INT_FIELD |
| 3830 #undef READ_SHORT_FIELD | 3844 #undef READ_SHORT_FIELD |
| 3831 #undef WRITE_SHORT_FIELD | 3845 #undef WRITE_SHORT_FIELD |
| 3832 #undef READ_BYTE_FIELD | 3846 #undef READ_BYTE_FIELD |
| 3833 #undef WRITE_BYTE_FIELD | 3847 #undef WRITE_BYTE_FIELD |
| 3834 | 3848 |
| 3835 | 3849 |
| 3836 } } // namespace v8::internal | 3850 } } // namespace v8::internal |
| 3837 | 3851 |
| 3838 #endif // V8_OBJECTS_INL_H_ | 3852 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |