Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 858 | 858 |
| 859 #define FIELD_ADDR(p, offset) \ | 859 #define FIELD_ADDR(p, offset) \ |
| 860 (reinterpret_cast<byte*>(p) + offset - kHeapObjectTag) | 860 (reinterpret_cast<byte*>(p) + offset - kHeapObjectTag) |
| 861 | 861 |
| 862 #define READ_FIELD(p, offset) \ | 862 #define READ_FIELD(p, offset) \ |
| 863 (*reinterpret_cast<Object**>(FIELD_ADDR(p, offset))) | 863 (*reinterpret_cast<Object**>(FIELD_ADDR(p, offset))) |
| 864 | 864 |
| 865 #define WRITE_FIELD(p, offset, value) \ | 865 #define WRITE_FIELD(p, offset, value) \ |
| 866 (*reinterpret_cast<Object**>(FIELD_ADDR(p, offset)) = value) | 866 (*reinterpret_cast<Object**>(FIELD_ADDR(p, offset)) = value) |
| 867 | 867 |
| 868 #define WRITE_BARRIER(heap, object, offset, value) \ | 868 #define WRITE_BARRIER(heap, object, offset, value) \ |
| 869 heap->incremental_marking()->RecordWrite(object, value); \ | 869 heap->incremental_marking()->RecordWrite( \ |
| 870 if (HEAP->InNewSpace(value)) { \ | 870 object, HeapObject::RawField(object, offset), value); \ |
| 871 heap->RecordWrite(object->address(), offset); \ | 871 if (heap->InNewSpace(value)) { \ |
| 872 heap->RecordWrite(object->address(), offset); \ | |
| 872 } | 873 } |
| 873 // TODO(gc) !!! | |
| 874 | 874 |
| 875 #ifndef V8_TARGET_ARCH_MIPS | 875 #ifndef V8_TARGET_ARCH_MIPS |
| 876 #define READ_DOUBLE_FIELD(p, offset) \ | 876 #define READ_DOUBLE_FIELD(p, offset) \ |
| 877 (*reinterpret_cast<double*>(FIELD_ADDR(p, offset))) | 877 (*reinterpret_cast<double*>(FIELD_ADDR(p, offset))) |
| 878 #else // V8_TARGET_ARCH_MIPS | 878 #else // V8_TARGET_ARCH_MIPS |
| 879 // Prevent gcc from using load-double (mips ldc1) on (possibly) | 879 // Prevent gcc from using load-double (mips ldc1) on (possibly) |
| 880 // non-64-bit aligned HeapNumber::value. | 880 // non-64-bit aligned HeapNumber::value. |
| 881 static inline double read_double_field(HeapNumber* p, int offset) { | 881 static inline double read_double_field(HeapNumber* p, int offset) { |
| 882 union conversion { | 882 union conversion { |
| 883 double d; | 883 double d; |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1111 | 1111 |
| 1112 | 1112 |
| 1113 Map* HeapObject::map() { | 1113 Map* HeapObject::map() { |
| 1114 return map_word().ToMap(); | 1114 return map_word().ToMap(); |
| 1115 } | 1115 } |
| 1116 | 1116 |
| 1117 | 1117 |
| 1118 void HeapObject::set_map(Map* value) { | 1118 void HeapObject::set_map(Map* value) { |
| 1119 set_map_word(MapWord::FromMap(value)); | 1119 set_map_word(MapWord::FromMap(value)); |
| 1120 if (value != NULL) { | 1120 if (value != NULL) { |
| 1121 value->GetHeap()->incremental_marking()->RecordWrite(this, value); | 1121 value->GetHeap()->incremental_marking()->RecordWrite(this, NULL, value); |
|
Erik Corry
2011/07/04 11:04:11
This is because we don't compact the map space, ri
Vyacheslav Egorov (Chromium)
2011/08/05 12:50:28
Done.
| |
| 1122 } | 1122 } |
| 1123 } | 1123 } |
| 1124 | 1124 |
| 1125 | 1125 |
| 1126 MapWord HeapObject::map_word() { | 1126 MapWord HeapObject::map_word() { |
| 1127 return MapWord(reinterpret_cast<uintptr_t>(READ_FIELD(this, kMapOffset))); | 1127 return MapWord(reinterpret_cast<uintptr_t>(READ_FIELD(this, kMapOffset))); |
| 1128 } | 1128 } |
| 1129 | 1129 |
| 1130 | 1130 |
| 1131 void HeapObject::set_map_word(MapWord map_word) { | 1131 void HeapObject::set_map_word(MapWord map_word) { |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1245 | 1245 |
| 1246 Object* JSGlobalPropertyCell::value() { | 1246 Object* JSGlobalPropertyCell::value() { |
| 1247 return READ_FIELD(this, kValueOffset); | 1247 return READ_FIELD(this, kValueOffset); |
| 1248 } | 1248 } |
| 1249 | 1249 |
| 1250 | 1250 |
| 1251 void JSGlobalPropertyCell::set_value(Object* val, WriteBarrierMode ignored) { | 1251 void JSGlobalPropertyCell::set_value(Object* val, WriteBarrierMode ignored) { |
| 1252 // The write barrier is not used for global property cells. | 1252 // The write barrier is not used for global property cells. |
| 1253 ASSERT(!val->IsJSGlobalPropertyCell()); | 1253 ASSERT(!val->IsJSGlobalPropertyCell()); |
| 1254 WRITE_FIELD(this, kValueOffset, val); | 1254 WRITE_FIELD(this, kValueOffset, val); |
| 1255 // TODO(gc) ISOLATES MERGE cell should heap accessor. | 1255 GetHeap()->incremental_marking()->RecordWrite( |
| 1256 GetHeap()->incremental_marking()->RecordWrite(this, val); | 1256 this, HeapObject::RawField(this, kValueOffset), val); |
| 1257 } | 1257 } |
| 1258 | 1258 |
| 1259 | 1259 |
| 1260 int JSObject::GetHeaderSize() { | 1260 int JSObject::GetHeaderSize() { |
| 1261 InstanceType type = map()->instance_type(); | 1261 InstanceType type = map()->instance_type(); |
| 1262 // Check for the most common kind of JavaScript object before | 1262 // Check for the most common kind of JavaScript object before |
| 1263 // falling into the generic switch. This speeds up the internal | 1263 // falling into the generic switch. This speeds up the internal |
| 1264 // field operations considerably on average. | 1264 // field operations considerably on average. |
| 1265 if (type == JS_OBJECT_TYPE) return JSObject::kHeaderSize; | 1265 if (type == JS_OBJECT_TYPE) return JSObject::kHeaderSize; |
| 1266 switch (type) { | 1266 switch (type) { |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1487 WRITE_FIELD(this, offset, value); | 1487 WRITE_FIELD(this, offset, value); |
| 1488 WRITE_BARRIER(GetHeap(), this, offset, value); | 1488 WRITE_BARRIER(GetHeap(), this, offset, value); |
| 1489 } | 1489 } |
| 1490 | 1490 |
| 1491 | 1491 |
| 1492 void FixedArray::fast_set(FixedArray* array, int index, Object* value) { | 1492 void FixedArray::fast_set(FixedArray* array, int index, Object* value) { |
| 1493 ASSERT(array->map() != HEAP->raw_unchecked_fixed_cow_array_map()); | 1493 ASSERT(array->map() != HEAP->raw_unchecked_fixed_cow_array_map()); |
| 1494 ASSERT(index >= 0 && index < array->length()); | 1494 ASSERT(index >= 0 && index < array->length()); |
| 1495 ASSERT(!HEAP->InNewSpace(value)); | 1495 ASSERT(!HEAP->InNewSpace(value)); |
| 1496 WRITE_FIELD(array, kHeaderSize + index * kPointerSize, value); | 1496 WRITE_FIELD(array, kHeaderSize + index * kPointerSize, value); |
| 1497 array->GetHeap()->incremental_marking()->RecordWrite(array, value); | 1497 array->GetHeap()->incremental_marking()->RecordWrite( |
| 1498 array, | |
| 1499 HeapObject::RawField(array, kHeaderSize + index * kPointerSize), | |
| 1500 value); | |
| 1498 } | 1501 } |
| 1499 | 1502 |
| 1500 | 1503 |
| 1501 void FixedArray::set_undefined(int index) { | 1504 void FixedArray::set_undefined(int index) { |
| 1502 ASSERT(map() != HEAP->fixed_cow_array_map()); | 1505 ASSERT(map() != HEAP->fixed_cow_array_map()); |
| 1503 set_undefined(GetHeap(), index); | 1506 set_undefined(GetHeap(), index); |
| 1504 } | 1507 } |
| 1505 | 1508 |
| 1506 | 1509 |
| 1507 void FixedArray::set_undefined(Heap* heap, int index) { | 1510 void FixedArray::set_undefined(Heap* heap, int index) { |
| (...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2899 } | 2902 } |
| 2900 } | 2903 } |
| 2901 | 2904 |
| 2902 | 2905 |
| 2903 ACCESSORS(Map, code_cache, Object, kCodeCacheOffset) | 2906 ACCESSORS(Map, code_cache, Object, kCodeCacheOffset) |
| 2904 ACCESSORS(Map, prototype_transitions, FixedArray, kPrototypeTransitionsOffset) | 2907 ACCESSORS(Map, prototype_transitions, FixedArray, kPrototypeTransitionsOffset) |
| 2905 ACCESSORS(Map, constructor, Object, kConstructorOffset) | 2908 ACCESSORS(Map, constructor, Object, kConstructorOffset) |
| 2906 | 2909 |
| 2907 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset) | 2910 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset) |
| 2908 ACCESSORS(JSFunction, literals, FixedArray, kLiteralsOffset) | 2911 ACCESSORS(JSFunction, literals, FixedArray, kLiteralsOffset) |
| 2909 ACCESSORS_GCSAFE(JSFunction, | 2912 ACCESSORS(JSFunction, |
| 2910 next_function_link, | 2913 next_function_link, |
| 2911 Object, | 2914 Object, |
| 2912 kNextFunctionLinkOffset) | 2915 kNextFunctionLinkOffset) |
| 2913 | 2916 |
| 2914 ACCESSORS(GlobalObject, builtins, JSBuiltinsObject, kBuiltinsOffset) | 2917 ACCESSORS(GlobalObject, builtins, JSBuiltinsObject, kBuiltinsOffset) |
| 2915 ACCESSORS(GlobalObject, global_context, Context, kGlobalContextOffset) | 2918 ACCESSORS(GlobalObject, global_context, Context, kGlobalContextOffset) |
| 2916 ACCESSORS(GlobalObject, global_receiver, JSObject, kGlobalReceiverOffset) | 2919 ACCESSORS(GlobalObject, global_receiver, JSObject, kGlobalReceiverOffset) |
| 2917 | 2920 |
| 2918 ACCESSORS(JSGlobalProxy, context, Object, kContextOffset) | 2921 ACCESSORS(JSGlobalProxy, context, Object, kContextOffset) |
| 2919 | 2922 |
| 2920 ACCESSORS(AccessorInfo, getter, Object, kGetterOffset) | 2923 ACCESSORS(AccessorInfo, getter, Object, kGetterOffset) |
| 2921 ACCESSORS(AccessorInfo, setter, Object, kSetterOffset) | 2924 ACCESSORS(AccessorInfo, setter, Object, kSetterOffset) |
| 2922 ACCESSORS(AccessorInfo, data, Object, kDataOffset) | 2925 ACCESSORS(AccessorInfo, data, Object, kDataOffset) |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3325 return reinterpret_cast<Code*>( | 3328 return reinterpret_cast<Code*>( |
| 3326 Code::GetObjectFromEntryAddress(FIELD_ADDR(this, kCodeEntryOffset))); | 3329 Code::GetObjectFromEntryAddress(FIELD_ADDR(this, kCodeEntryOffset))); |
| 3327 } | 3330 } |
| 3328 | 3331 |
| 3329 | 3332 |
| 3330 void JSFunction::set_code(Code* value) { | 3333 void JSFunction::set_code(Code* value) { |
| 3331 // Skip the write barrier because code is never in new space. | 3334 // Skip the write barrier because code is never in new space. |
| 3332 ASSERT(!HEAP->InNewSpace(value)); | 3335 ASSERT(!HEAP->InNewSpace(value)); |
| 3333 Address entry = value->entry(); | 3336 Address entry = value->entry(); |
| 3334 WRITE_INTPTR_FIELD(this, kCodeEntryOffset, reinterpret_cast<intptr_t>(entry)); | 3337 WRITE_INTPTR_FIELD(this, kCodeEntryOffset, reinterpret_cast<intptr_t>(entry)); |
| 3335 GetHeap()->incremental_marking()->RecordWrite(this, value); | 3338 GetHeap()->incremental_marking()->RecordWrite( |
| 3339 this, | |
| 3340 HeapObject::RawField(this, kCodeEntryOffset), | |
| 3341 value); | |
| 3336 } | 3342 } |
| 3337 | 3343 |
| 3338 | 3344 |
| 3339 void JSFunction::ReplaceCode(Code* code) { | 3345 void JSFunction::ReplaceCode(Code* code) { |
| 3340 bool was_optimized = IsOptimized(); | 3346 bool was_optimized = IsOptimized(); |
| 3341 bool is_optimized = code->kind() == Code::OPTIMIZED_FUNCTION; | 3347 bool is_optimized = code->kind() == Code::OPTIMIZED_FUNCTION; |
| 3342 | 3348 |
| 3343 set_code(code); | 3349 set_code(code); |
| 3344 | 3350 |
| 3345 // Add/remove the function from the list of optimized functions for this | 3351 // Add/remove the function from the list of optimized functions for this |
| (...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4165 #undef WRITE_INT_FIELD | 4171 #undef WRITE_INT_FIELD |
| 4166 #undef READ_SHORT_FIELD | 4172 #undef READ_SHORT_FIELD |
| 4167 #undef WRITE_SHORT_FIELD | 4173 #undef WRITE_SHORT_FIELD |
| 4168 #undef READ_BYTE_FIELD | 4174 #undef READ_BYTE_FIELD |
| 4169 #undef WRITE_BYTE_FIELD | 4175 #undef WRITE_BYTE_FIELD |
| 4170 | 4176 |
| 4171 | 4177 |
| 4172 } } // namespace v8::internal | 4178 } } // namespace v8::internal |
| 4173 | 4179 |
| 4174 #endif // V8_OBJECTS_INL_H_ | 4180 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |