| 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 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1357 | 1357 |
| 1358 int JSObject::GetInternalFieldCount() { | 1358 int JSObject::GetInternalFieldCount() { |
| 1359 ASSERT(1 << kPointerSizeLog2 == kPointerSize); | 1359 ASSERT(1 << kPointerSizeLog2 == kPointerSize); |
| 1360 // Make sure to adjust for the number of in-object properties. These | 1360 // Make sure to adjust for the number of in-object properties. These |
| 1361 // properties do contribute to the size, but are not internal fields. | 1361 // properties do contribute to the size, but are not internal fields. |
| 1362 return ((Size() - GetHeaderSize()) >> kPointerSizeLog2) - | 1362 return ((Size() - GetHeaderSize()) >> kPointerSizeLog2) - |
| 1363 map()->inobject_properties(); | 1363 map()->inobject_properties(); |
| 1364 } | 1364 } |
| 1365 | 1365 |
| 1366 | 1366 |
| 1367 int JSObject::GetInternalFieldOffset(int index) { |
| 1368 ASSERT(index < GetInternalFieldCount() && index >= 0); |
| 1369 return GetHeaderSize() + (kPointerSize * index); |
| 1370 } |
| 1371 |
| 1372 |
| 1367 Object* JSObject::GetInternalField(int index) { | 1373 Object* JSObject::GetInternalField(int index) { |
| 1368 ASSERT(index < GetInternalFieldCount() && index >= 0); | 1374 ASSERT(index < GetInternalFieldCount() && index >= 0); |
| 1369 // Internal objects do follow immediately after the header, whereas in-object | 1375 // Internal objects do follow immediately after the header, whereas in-object |
| 1370 // properties are at the end of the object. Therefore there is no need | 1376 // properties are at the end of the object. Therefore there is no need |
| 1371 // to adjust the index here. | 1377 // to adjust the index here. |
| 1372 return READ_FIELD(this, GetHeaderSize() + (kPointerSize * index)); | 1378 return READ_FIELD(this, GetHeaderSize() + (kPointerSize * index)); |
| 1373 } | 1379 } |
| 1374 | 1380 |
| 1375 | 1381 |
| 1376 void JSObject::SetInternalField(int index, Object* value) { | 1382 void JSObject::SetInternalField(int index, Object* value) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1408 WRITE_FIELD(this, offset, value); | 1414 WRITE_FIELD(this, offset, value); |
| 1409 WRITE_BARRIER(this, offset); | 1415 WRITE_BARRIER(this, offset); |
| 1410 } else { | 1416 } else { |
| 1411 ASSERT(index < properties()->length()); | 1417 ASSERT(index < properties()->length()); |
| 1412 properties()->set(index, value); | 1418 properties()->set(index, value); |
| 1413 } | 1419 } |
| 1414 return value; | 1420 return value; |
| 1415 } | 1421 } |
| 1416 | 1422 |
| 1417 | 1423 |
| 1424 int JSObject::GetInObjectPropertyOffset(int index) { |
| 1425 // Adjust for the number of properties stored in the object. |
| 1426 index -= map()->inobject_properties(); |
| 1427 ASSERT(index < 0); |
| 1428 return map()->instance_size() + (index * kPointerSize); |
| 1429 } |
| 1430 |
| 1431 |
| 1418 Object* JSObject::InObjectPropertyAt(int index) { | 1432 Object* JSObject::InObjectPropertyAt(int index) { |
| 1419 // Adjust for the number of properties stored in the object. | 1433 // Adjust for the number of properties stored in the object. |
| 1420 index -= map()->inobject_properties(); | 1434 index -= map()->inobject_properties(); |
| 1421 ASSERT(index < 0); | 1435 ASSERT(index < 0); |
| 1422 int offset = map()->instance_size() + (index * kPointerSize); | 1436 int offset = map()->instance_size() + (index * kPointerSize); |
| 1423 return READ_FIELD(this, offset); | 1437 return READ_FIELD(this, offset); |
| 1424 } | 1438 } |
| 1425 | 1439 |
| 1426 | 1440 |
| 1427 Object* JSObject::InObjectPropertyAtPut(int index, | 1441 Object* JSObject::InObjectPropertyAtPut(int index, |
| (...skipping 2668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4096 #undef WRITE_INT_FIELD | 4110 #undef WRITE_INT_FIELD |
| 4097 #undef READ_SHORT_FIELD | 4111 #undef READ_SHORT_FIELD |
| 4098 #undef WRITE_SHORT_FIELD | 4112 #undef WRITE_SHORT_FIELD |
| 4099 #undef READ_BYTE_FIELD | 4113 #undef READ_BYTE_FIELD |
| 4100 #undef WRITE_BYTE_FIELD | 4114 #undef WRITE_BYTE_FIELD |
| 4101 | 4115 |
| 4102 | 4116 |
| 4103 } } // namespace v8::internal | 4117 } } // namespace v8::internal |
| 4104 | 4118 |
| 4105 #endif // V8_OBJECTS_INL_H_ | 4119 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |