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) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1357 WRITE_FIELD(this, offset, value); | 1363 WRITE_FIELD(this, offset, value); |
1358 WRITE_BARRIER(this, offset); | 1364 WRITE_BARRIER(this, offset); |
1359 } else { | 1365 } else { |
1360 ASSERT(index < properties()->length()); | 1366 ASSERT(index < properties()->length()); |
1361 properties()->set(index, value); | 1367 properties()->set(index, value); |
1362 } | 1368 } |
1363 return value; | 1369 return value; |
1364 } | 1370 } |
1365 | 1371 |
1366 | 1372 |
| 1373 int JSObject::GetInObjectPropertyOffset(int index) { |
| 1374 // Adjust for the number of properties stored in the object. |
| 1375 index -= map()->inobject_properties(); |
| 1376 ASSERT(index < 0); |
| 1377 return map()->instance_size() + (index * kPointerSize); |
| 1378 } |
| 1379 |
| 1380 |
1367 Object* JSObject::InObjectPropertyAt(int index) { | 1381 Object* JSObject::InObjectPropertyAt(int index) { |
1368 // Adjust for the number of properties stored in the object. | 1382 // Adjust for the number of properties stored in the object. |
1369 index -= map()->inobject_properties(); | 1383 index -= map()->inobject_properties(); |
1370 ASSERT(index < 0); | 1384 ASSERT(index < 0); |
1371 int offset = map()->instance_size() + (index * kPointerSize); | 1385 int offset = map()->instance_size() + (index * kPointerSize); |
1372 return READ_FIELD(this, offset); | 1386 return READ_FIELD(this, offset); |
1373 } | 1387 } |
1374 | 1388 |
1375 | 1389 |
1376 Object* JSObject::InObjectPropertyAtPut(int index, | 1390 Object* JSObject::InObjectPropertyAtPut(int index, |
(...skipping 2559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3936 #undef WRITE_INT_FIELD | 3950 #undef WRITE_INT_FIELD |
3937 #undef READ_SHORT_FIELD | 3951 #undef READ_SHORT_FIELD |
3938 #undef WRITE_SHORT_FIELD | 3952 #undef WRITE_SHORT_FIELD |
3939 #undef READ_BYTE_FIELD | 3953 #undef READ_BYTE_FIELD |
3940 #undef WRITE_BYTE_FIELD | 3954 #undef WRITE_BYTE_FIELD |
3941 | 3955 |
3942 | 3956 |
3943 } } // namespace v8::internal | 3957 } } // namespace v8::internal |
3944 | 3958 |
3945 #endif // V8_OBJECTS_INL_H_ | 3959 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |