| 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 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1247 // half-open range [start, end) specified as integer offsets | 1247 // half-open range [start, end) specified as integer offsets |
| 1248 inline void IteratePointers(ObjectVisitor* v, int start, int end); | 1248 inline void IteratePointers(ObjectVisitor* v, int start, int end); |
| 1249 // as above, for the single element at "offset" | 1249 // as above, for the single element at "offset" |
| 1250 inline void IteratePointer(ObjectVisitor* v, int offset); | 1250 inline void IteratePointer(ObjectVisitor* v, int offset); |
| 1251 | 1251 |
| 1252 private: | 1252 private: |
| 1253 DISALLOW_IMPLICIT_CONSTRUCTORS(HeapObject); | 1253 DISALLOW_IMPLICIT_CONSTRUCTORS(HeapObject); |
| 1254 }; | 1254 }; |
| 1255 | 1255 |
| 1256 | 1256 |
| 1257 #define SLOT_ADDR(obj, offset) \ | |
| 1258 reinterpret_cast<Object**>((obj)->address() + offset) | |
| 1259 | |
| 1260 // This class describes a body of an object of a fixed size | 1257 // This class describes a body of an object of a fixed size |
| 1261 // in which all pointer fields are located in the [start_offset, end_offset) | 1258 // in which all pointer fields are located in the [start_offset, end_offset) |
| 1262 // interval. | 1259 // interval. |
| 1263 template<int start_offset, int end_offset, int size> | 1260 template<int start_offset, int end_offset, int size> |
| 1264 class FixedBodyDescriptor { | 1261 class FixedBodyDescriptor { |
| 1265 public: | 1262 public: |
| 1266 static const int kStartOffset = start_offset; | 1263 static const int kStartOffset = start_offset; |
| 1267 static const int kEndOffset = end_offset; | 1264 static const int kEndOffset = end_offset; |
| 1268 static const int kSize = size; | 1265 static const int kSize = size; |
| 1269 | 1266 |
| 1270 static inline void IterateBody(HeapObject* obj, ObjectVisitor* v); | 1267 static inline void IterateBody(HeapObject* obj, ObjectVisitor* v); |
| 1271 | 1268 |
| 1272 template<typename StaticVisitor> | 1269 template<typename StaticVisitor> |
| 1273 static inline void IterateBody(HeapObject* obj) { | 1270 static inline void IterateBody(HeapObject* obj) { |
| 1274 StaticVisitor::VisitPointers(SLOT_ADDR(obj, start_offset), | 1271 StaticVisitor::VisitPointers(HeapObject::RawField(obj, start_offset), |
| 1275 SLOT_ADDR(obj, end_offset)); | 1272 HeapObject::RawField(obj, end_offset)); |
| 1276 } | 1273 } |
| 1277 }; | 1274 }; |
| 1278 | 1275 |
| 1279 | 1276 |
| 1280 // This class describes a body of an object of a variable size | 1277 // This class describes a body of an object of a variable size |
| 1281 // in which all pointer fields are located in the [start_offset, object_size) | 1278 // in which all pointer fields are located in the [start_offset, object_size) |
| 1282 // interval. | 1279 // interval. |
| 1283 template<int start_offset> | 1280 template<int start_offset> |
| 1284 class FlexibleBodyDescriptor { | 1281 class FlexibleBodyDescriptor { |
| 1285 public: | 1282 public: |
| 1286 static const int kStartOffset = start_offset; | 1283 static const int kStartOffset = start_offset; |
| 1287 | 1284 |
| 1288 static inline void IterateBody(HeapObject* obj, | 1285 static inline void IterateBody(HeapObject* obj, |
| 1289 int object_size, | 1286 int object_size, |
| 1290 ObjectVisitor* v); | 1287 ObjectVisitor* v); |
| 1291 | 1288 |
| 1292 template<typename StaticVisitor> | 1289 template<typename StaticVisitor> |
| 1293 static inline void IterateBody(HeapObject* obj, int object_size) { | 1290 static inline void IterateBody(HeapObject* obj, int object_size) { |
| 1294 StaticVisitor::VisitPointers(SLOT_ADDR(obj, start_offset), | 1291 StaticVisitor::VisitPointers(HeapObject::RawField(obj, start_offset), |
| 1295 SLOT_ADDR(obj, object_size)); | 1292 HeapObject::RawField(obj, object_size)); |
| 1296 } | 1293 } |
| 1297 }; | 1294 }; |
| 1298 | 1295 |
| 1299 #undef SLOT_ADDR | |
| 1300 | |
| 1301 | 1296 |
| 1302 // The HeapNumber class describes heap allocated numbers that cannot be | 1297 // The HeapNumber class describes heap allocated numbers that cannot be |
| 1303 // represented in a Smi (small integer) | 1298 // represented in a Smi (small integer) |
| 1304 class HeapNumber: public HeapObject { | 1299 class HeapNumber: public HeapObject { |
| 1305 public: | 1300 public: |
| 1306 // [value]: number value. | 1301 // [value]: number value. |
| 1307 inline double value(); | 1302 inline double value(); |
| 1308 inline void set_value(double value); | 1303 inline void set_value(double value); |
| 1309 | 1304 |
| 1310 // Casting. | 1305 // Casting. |
| (...skipping 7643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8954 } else { | 8949 } else { |
| 8955 value &= ~(1 << bit_position); | 8950 value &= ~(1 << bit_position); |
| 8956 } | 8951 } |
| 8957 return value; | 8952 return value; |
| 8958 } | 8953 } |
| 8959 }; | 8954 }; |
| 8960 | 8955 |
| 8961 } } // namespace v8::internal | 8956 } } // namespace v8::internal |
| 8962 | 8957 |
| 8963 #endif // V8_OBJECTS_H_ | 8958 #endif // V8_OBJECTS_H_ |
| OLD | NEW |