OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 class TypeField: public BitField<PropertyType, 0, 3> {}; | 159 class TypeField: public BitField<PropertyType, 0, 3> {}; |
160 class AttributesField: public BitField<PropertyAttributes, 3, 3> {}; | 160 class AttributesField: public BitField<PropertyAttributes, 3, 3> {}; |
161 class IndexField: public BitField<uint32_t, 6, 32-6> {}; | 161 class IndexField: public BitField<uint32_t, 6, 32-6> {}; |
162 | 162 |
163 static const int kInitialIndex = 1; | 163 static const int kInitialIndex = 1; |
164 | 164 |
165 private: | 165 private: |
166 uint32_t value_; | 166 uint32_t value_; |
167 }; | 167 }; |
168 | 168 |
| 169 // Setter that skips the write barrier if mode is SKIP_WRITE_BARRIER. |
| 170 enum WriteBarrierMode { SKIP_WRITE_BARRIER, UPDATE_WRITE_BARRIER }; |
| 171 |
169 // All Maps have a field instance_type containing a InstanceType. | 172 // All Maps have a field instance_type containing a InstanceType. |
170 // It describes the type of the instances. | 173 // It describes the type of the instances. |
171 // | 174 // |
172 // As an example, a JavaScript object is a heap object and its map | 175 // As an example, a JavaScript object is a heap object and its map |
173 // instance_type is JS_OBJECT_TYPE. | 176 // instance_type is JS_OBJECT_TYPE. |
174 // | 177 // |
175 // The names of the string instance types are intended to systematically | 178 // The names of the string instance types are intended to systematically |
176 // mirror their encoding in the instance_type field of the map. The length | 179 // mirror their encoding in the instance_type field of the map. The length |
177 // (SHORT, MEDIUM, or LONG) is always mentioned. The default encoding is | 180 // (SHORT, MEDIUM, or LONG) is always mentioned. The default encoding is |
178 // considered TWO_BYTE. It is not mentioned in the name. ASCII encoding is | 181 // considered TWO_BYTE. It is not mentioned in the name. ASCII encoding is |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 | 551 |
549 NOT_EQUAL = GREATER | 552 NOT_EQUAL = GREATER |
550 }; | 553 }; |
551 | 554 |
552 | 555 |
553 #define DECL_BOOLEAN_ACCESSORS(name) \ | 556 #define DECL_BOOLEAN_ACCESSORS(name) \ |
554 inline bool name(); \ | 557 inline bool name(); \ |
555 inline void set_##name(bool value); \ | 558 inline void set_##name(bool value); \ |
556 | 559 |
557 | 560 |
558 #define DECL_ACCESSORS(name, type) \ | 561 #define DECL_ACCESSORS(name, type) \ |
559 inline type* name(); \ | 562 inline type* name(); \ |
560 inline void set_##name(type* value); | 563 inline void set_##name(type* value, \ |
| 564 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); \ |
561 | 565 |
562 | 566 |
563 class StringStream; | 567 class StringStream; |
564 class ObjectVisitor; | 568 class ObjectVisitor; |
565 | 569 |
566 struct ValueInfo : public Malloced { | 570 struct ValueInfo : public Malloced { |
567 ValueInfo() : type(FIRST_TYPE), ptr(NULL), str(NULL), number(0) { } | 571 ValueInfo() : type(FIRST_TYPE), ptr(NULL), str(NULL), number(0) { } |
568 InstanceType type; | 572 InstanceType type; |
569 Object* ptr; | 573 Object* ptr; |
570 const char* str; | 574 const char* str; |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 | 1038 |
1035 // Mutate this object's map pointer to remove the indication that the | 1039 // Mutate this object's map pointer to remove the indication that the |
1036 // object is overflowed (ie, partially restore the map pointer). | 1040 // object is overflowed (ie, partially restore the map pointer). |
1037 inline void ClearOverflow(); | 1041 inline void ClearOverflow(); |
1038 | 1042 |
1039 static inline Object* GetHeapObjectField(HeapObject* obj, int index); | 1043 static inline Object* GetHeapObjectField(HeapObject* obj, int index); |
1040 | 1044 |
1041 // Casting. | 1045 // Casting. |
1042 static inline HeapObject* cast(Object* obj); | 1046 static inline HeapObject* cast(Object* obj); |
1043 | 1047 |
| 1048 // Return the write barrier mode for this. |
| 1049 inline WriteBarrierMode GetWriteBarrierMode(); |
| 1050 |
1044 // Dispatched behavior. | 1051 // Dispatched behavior. |
1045 void HeapObjectShortPrint(StringStream* accumulator); | 1052 void HeapObjectShortPrint(StringStream* accumulator); |
1046 #ifdef DEBUG | 1053 #ifdef DEBUG |
1047 void HeapObjectPrint(); | 1054 void HeapObjectPrint(); |
1048 void HeapObjectVerify(); | 1055 void HeapObjectVerify(); |
1049 inline void VerifyObjectField(int offset); | 1056 inline void VerifyObjectField(int offset); |
1050 | 1057 |
1051 void PrintHeader(const char* id); | 1058 void PrintHeader(const char* id); |
1052 | 1059 |
1053 // Verify a pointer is a valid HeapObject pointer that points to object | 1060 // Verify a pointer is a valid HeapObject pointer that points to object |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1348 Object* NormalizeElements(); | 1355 Object* NormalizeElements(); |
1349 | 1356 |
1350 // Transform slow named properties to fast variants. | 1357 // Transform slow named properties to fast variants. |
1351 // Returns failure if allocation failed. | 1358 // Returns failure if allocation failed. |
1352 Object* TransformToFastProperties(int unused_property_fields); | 1359 Object* TransformToFastProperties(int unused_property_fields); |
1353 | 1360 |
1354 // Access fast-case object properties at index. | 1361 // Access fast-case object properties at index. |
1355 inline Object* FastPropertyAt(int index); | 1362 inline Object* FastPropertyAt(int index); |
1356 inline Object* FastPropertyAtPut(int index, Object* value); | 1363 inline Object* FastPropertyAtPut(int index, Object* value); |
1357 | 1364 |
| 1365 // Access to set in object properties. |
| 1366 inline Object* InObjectPropertyAtPut(int index, |
| 1367 Object* value, |
| 1368 WriteBarrierMode mode |
| 1369 = UPDATE_WRITE_BARRIER); |
1358 | 1370 |
1359 // initializes the body after properties slot, properties slot is | 1371 // initializes the body after properties slot, properties slot is |
1360 // initialized by set_properties | 1372 // initialized by set_properties |
1361 // Note: this call does not update write barrier, it is caller's | 1373 // Note: this call does not update write barrier, it is caller's |
1362 // reponsibility to ensure that *v* can be collected without WB here. | 1374 // reponsibility to ensure that *v* can be collected without WB here. |
1363 inline void InitializeBody(int object_size); | 1375 inline void InitializeBody(int object_size); |
1364 | 1376 |
1365 // Check whether this object references another object | 1377 // Check whether this object references another object |
1366 bool ReferencesObject(Object* obj); | 1378 bool ReferencesObject(Object* obj); |
1367 | 1379 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1472 // FixedArray describes fixed sized arrays where element | 1484 // FixedArray describes fixed sized arrays where element |
1473 // type is Object*. | 1485 // type is Object*. |
1474 | 1486 |
1475 class FixedArray: public Array { | 1487 class FixedArray: public Array { |
1476 public: | 1488 public: |
1477 | 1489 |
1478 // Setter and getter for elements. | 1490 // Setter and getter for elements. |
1479 inline Object* get(int index); | 1491 inline Object* get(int index); |
1480 inline void set(int index, Object* value); | 1492 inline void set(int index, Object* value); |
1481 | 1493 |
| 1494 // Setter with barrier mode. |
| 1495 inline void set(int index, Object* value, WriteBarrierMode mode); |
| 1496 |
1482 // Setters for frequently used oddballs located in old space. | 1497 // Setters for frequently used oddballs located in old space. |
1483 inline void set_undefined(int index); | 1498 inline void set_undefined(int index); |
1484 inline void set_null(int index); | 1499 inline void set_null(int index); |
1485 inline void set_the_hole(int index); | 1500 inline void set_the_hole(int index); |
1486 | 1501 |
1487 // Setter that skips the write barrier if mode is SKIP_WRITE_BARRIER. | |
1488 enum WriteBarrierMode { SKIP_WRITE_BARRIER, UPDATE_WRITE_BARRIER }; | |
1489 inline void set(int index, Object* value, WriteBarrierMode mode); | |
1490 // Return the write barrier mode for this. | |
1491 inline WriteBarrierMode GetWriteBarrierMode(); | |
1492 | |
1493 // Copy operations. | 1502 // Copy operations. |
1494 inline Object* Copy(); | 1503 inline Object* Copy(); |
1495 Object* CopySize(int new_length); | 1504 Object* CopySize(int new_length); |
1496 | 1505 |
1497 // Add the elements of a JSArray to this FixedArray. | 1506 // Add the elements of a JSArray to this FixedArray. |
1498 Object* AddKeysFromJSArray(JSArray* array); | 1507 Object* AddKeysFromJSArray(JSArray* array); |
1499 | 1508 |
1500 // Compute the union of this and other. | 1509 // Compute the union of this and other. |
1501 Object* UnionOfKeys(FixedArray* other); | 1510 Object* UnionOfKeys(FixedArray* other); |
1502 | 1511 |
(...skipping 2578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4081 } else { | 4090 } else { |
4082 value &= ~(1 << bit_position); | 4091 value &= ~(1 << bit_position); |
4083 } | 4092 } |
4084 return value; | 4093 return value; |
4085 } | 4094 } |
4086 }; | 4095 }; |
4087 | 4096 |
4088 } } // namespace v8::internal | 4097 } } // namespace v8::internal |
4089 | 4098 |
4090 #endif // V8_OBJECTS_H_ | 4099 #endif // V8_OBJECTS_H_ |
OLD | NEW |