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 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1306 | 1306 |
1307 int JSObject::GetInternalFieldCount() { | 1307 int JSObject::GetInternalFieldCount() { |
1308 ASSERT(1 << kPointerSizeLog2 == kPointerSize); | 1308 ASSERT(1 << kPointerSizeLog2 == kPointerSize); |
1309 // Make sure to adjust for the number of in-object properties. These | 1309 // Make sure to adjust for the number of in-object properties. These |
1310 // properties do contribute to the size, but are not internal fields. | 1310 // properties do contribute to the size, but are not internal fields. |
1311 return ((Size() - GetHeaderSize()) >> kPointerSizeLog2) - | 1311 return ((Size() - GetHeaderSize()) >> kPointerSizeLog2) - |
1312 map()->inobject_properties(); | 1312 map()->inobject_properties(); |
1313 } | 1313 } |
1314 | 1314 |
1315 | 1315 |
1316 int JSObject::GetInternalFieldOffset(int index) { | |
1317 ASSERT(index < GetInternalFieldCount() && index >= 0); | |
1318 return GetHeaderSize() + (kPointerSize * index); | |
1319 } | |
1320 | |
1321 | |
1316 Object* JSObject::GetInternalField(int index) { | 1322 Object* JSObject::GetInternalField(int index) { |
1317 ASSERT(index < GetInternalFieldCount() && index >= 0); | 1323 ASSERT(index < GetInternalFieldCount() && index >= 0); |
1318 // Internal objects do follow immediately after the header, whereas in-object | 1324 // Internal objects do follow immediately after the header, whereas in-object |
1319 // properties are at the end of the object. Therefore there is no need | 1325 // properties are at the end of the object. Therefore there is no need |
1320 // to adjust the index here. | 1326 // to adjust the index here. |
1321 return READ_FIELD(this, GetHeaderSize() + (kPointerSize * index)); | 1327 return READ_FIELD(this, GetHeaderSize() + (kPointerSize * index)); |
1322 } | 1328 } |
1323 | 1329 |
1324 | 1330 |
1325 void JSObject::SetInternalField(int index, Object* value) { | 1331 void JSObject::SetInternalField(int index, Object* value) { |
1326 ASSERT(index < GetInternalFieldCount() && index >= 0); | 1332 ASSERT(index < GetInternalFieldCount() && index >= 0); |
1327 // Internal objects do follow immediately after the header, whereas in-object | 1333 // Internal objects do follow immediately after the header, whereas in-object |
1328 // properties are at the end of the object. Therefore there is no need | 1334 // properties are at the end of the object. Therefore there is no need |
1329 // to adjust the index here. | 1335 // to adjust the index here. |
1330 int offset = GetHeaderSize() + (kPointerSize * index); | 1336 int offset = GetHeaderSize() + (kPointerSize * index); |
1331 WRITE_FIELD(this, offset, value); | 1337 WRITE_FIELD(this, offset, value); |
1332 WRITE_BARRIER(this, offset); | 1338 WRITE_BARRIER(this, offset); |
1333 } | 1339 } |
1334 | 1340 |
1335 | 1341 |
1336 // Access fast-case object properties at index. The use of these routines | 1342 // Access fast-case object properties at index. The use of these routines |
1337 // is needed to correctly distinguish between properties stored in-object and | 1343 // is needed to correctly distinguish between properties stored in-object and |
1338 // properties stored in the properties array. | 1344 // properties stored in the properties array. |
1345 int JSObject::GetFastPropertyOffset(int index) { | |
Vitaly Repeshko
2011/03/18 12:16:36
This should be called "GetInObjectPropertyOffset".
mnaganov (inactive)
2011/03/18 12:31:01
Done.
| |
1346 // Adjust for the number of properties stored in the object. | |
1347 index -= map()->inobject_properties(); | |
1348 return index < 0 ? map()->instance_size() + (index * kPointerSize) : -1; | |
1349 } | |
1350 | |
1351 | |
1339 Object* JSObject::FastPropertyAt(int index) { | 1352 Object* JSObject::FastPropertyAt(int index) { |
1340 // Adjust for the number of properties stored in the object. | 1353 // Adjust for the number of properties stored in the object. |
1341 index -= map()->inobject_properties(); | 1354 index -= map()->inobject_properties(); |
1342 if (index < 0) { | 1355 if (index < 0) { |
1343 int offset = map()->instance_size() + (index * kPointerSize); | 1356 int offset = map()->instance_size() + (index * kPointerSize); |
1344 return READ_FIELD(this, offset); | 1357 return READ_FIELD(this, offset); |
1345 } else { | 1358 } else { |
1346 ASSERT(index < properties()->length()); | 1359 ASSERT(index < properties()->length()); |
1347 return properties()->get(index); | 1360 return properties()->get(index); |
1348 } | 1361 } |
(...skipping 2587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3936 #undef WRITE_INT_FIELD | 3949 #undef WRITE_INT_FIELD |
3937 #undef READ_SHORT_FIELD | 3950 #undef READ_SHORT_FIELD |
3938 #undef WRITE_SHORT_FIELD | 3951 #undef WRITE_SHORT_FIELD |
3939 #undef READ_BYTE_FIELD | 3952 #undef READ_BYTE_FIELD |
3940 #undef WRITE_BYTE_FIELD | 3953 #undef WRITE_BYTE_FIELD |
3941 | 3954 |
3942 | 3955 |
3943 } } // namespace v8::internal | 3956 } } // namespace v8::internal |
3944 | 3957 |
3945 #endif // V8_OBJECTS_INL_H_ | 3958 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |