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 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1265 } | 1265 } |
1266 } | 1266 } |
1267 | 1267 |
1268 PromotionQueue* promotion_queue() { return &promotion_queue_; } | 1268 PromotionQueue* promotion_queue() { return &promotion_queue_; } |
1269 | 1269 |
1270 #ifdef DEBUG | 1270 #ifdef DEBUG |
1271 // Utility used with flag gc-greedy. | 1271 // Utility used with flag gc-greedy. |
1272 void GarbageCollectionGreedyCheck(); | 1272 void GarbageCollectionGreedyCheck(); |
1273 #endif | 1273 #endif |
1274 | 1274 |
1275 void AddGCPrologueCallback(v8::Isolate::GCPrologueCallback callback, | 1275 void AddGCPrologueCallback( |
1276 GCType gc_type_filter, | 1276 GCPrologueCallback callback, GCType gc_type_filter); |
1277 bool pass_isolate = true); | 1277 void RemoveGCPrologueCallback(GCPrologueCallback callback); |
1278 void RemoveGCPrologueCallback(v8::Isolate::GCPrologueCallback callback); | |
1279 | 1278 |
1280 void AddGCEpilogueCallback(v8::Isolate::GCEpilogueCallback callback, | 1279 void AddGCEpilogueCallback( |
1281 GCType gc_type_filter, | 1280 GCEpilogueCallback callback, GCType gc_type_filter); |
1282 bool pass_isolate = true); | 1281 void RemoveGCEpilogueCallback(GCEpilogueCallback callback); |
1283 void RemoveGCEpilogueCallback(v8::Isolate::GCEpilogueCallback callback); | 1282 |
| 1283 void SetGlobalGCPrologueCallback(GCCallback callback) { |
| 1284 ASSERT((callback == NULL) ^ (global_gc_prologue_callback_ == NULL)); |
| 1285 global_gc_prologue_callback_ = callback; |
| 1286 } |
| 1287 void SetGlobalGCEpilogueCallback(GCCallback callback) { |
| 1288 ASSERT((callback == NULL) ^ (global_gc_epilogue_callback_ == NULL)); |
| 1289 global_gc_epilogue_callback_ = callback; |
| 1290 } |
1284 | 1291 |
1285 // Heap root getters. We have versions with and without type::cast() here. | 1292 // Heap root getters. We have versions with and without type::cast() here. |
1286 // You can't use type::cast during GC because the assert fails. | 1293 // You can't use type::cast during GC because the assert fails. |
1287 // TODO(1490): Try removing the unchecked accessors, now that GC marking does | 1294 // TODO(1490): Try removing the unchecked accessors, now that GC marking does |
1288 // not corrupt the map. | 1295 // not corrupt the map. |
1289 #define ROOT_ACCESSOR(type, name, camel_name) \ | 1296 #define ROOT_ACCESSOR(type, name, camel_name) \ |
1290 type* name() { \ | 1297 type* name() { \ |
1291 return type::cast(roots_[k##camel_name##RootIndex]); \ | 1298 return type::cast(roots_[k##camel_name##RootIndex]); \ |
1292 } \ | 1299 } \ |
1293 type* raw_unchecked_##name() { \ | 1300 type* raw_unchecked_##name() { \ |
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2018 static const ConstantStringTable constant_string_table[]; | 2025 static const ConstantStringTable constant_string_table[]; |
2019 static const StructTable struct_table[]; | 2026 static const StructTable struct_table[]; |
2020 | 2027 |
2021 // The special hidden string which is an empty string, but does not match | 2028 // The special hidden string which is an empty string, but does not match |
2022 // any string when looked up in properties. | 2029 // any string when looked up in properties. |
2023 String* hidden_string_; | 2030 String* hidden_string_; |
2024 | 2031 |
2025 // GC callback function, called before and after mark-compact GC. | 2032 // GC callback function, called before and after mark-compact GC. |
2026 // Allocations in the callback function are disallowed. | 2033 // Allocations in the callback function are disallowed. |
2027 struct GCPrologueCallbackPair { | 2034 struct GCPrologueCallbackPair { |
2028 GCPrologueCallbackPair(v8::Isolate::GCPrologueCallback callback, | 2035 GCPrologueCallbackPair(GCPrologueCallback callback, GCType gc_type) |
2029 GCType gc_type, | 2036 : callback(callback), gc_type(gc_type) { |
2030 bool pass_isolate) | |
2031 : callback(callback), gc_type(gc_type), pass_isolate_(pass_isolate) { | |
2032 } | 2037 } |
2033 bool operator==(const GCPrologueCallbackPair& pair) const { | 2038 bool operator==(const GCPrologueCallbackPair& pair) const { |
2034 return pair.callback == callback; | 2039 return pair.callback == callback; |
2035 } | 2040 } |
2036 v8::Isolate::GCPrologueCallback callback; | 2041 GCPrologueCallback callback; |
2037 GCType gc_type; | 2042 GCType gc_type; |
2038 // TODO(dcarney): remove variable | |
2039 bool pass_isolate_; | |
2040 }; | 2043 }; |
2041 List<GCPrologueCallbackPair> gc_prologue_callbacks_; | 2044 List<GCPrologueCallbackPair> gc_prologue_callbacks_; |
2042 | 2045 |
2043 struct GCEpilogueCallbackPair { | 2046 struct GCEpilogueCallbackPair { |
2044 GCEpilogueCallbackPair(v8::Isolate::GCPrologueCallback callback, | 2047 GCEpilogueCallbackPair(GCEpilogueCallback callback, GCType gc_type) |
2045 GCType gc_type, | 2048 : callback(callback), gc_type(gc_type) { |
2046 bool pass_isolate) | |
2047 : callback(callback), gc_type(gc_type), pass_isolate_(pass_isolate) { | |
2048 } | 2049 } |
2049 bool operator==(const GCEpilogueCallbackPair& pair) const { | 2050 bool operator==(const GCEpilogueCallbackPair& pair) const { |
2050 return pair.callback == callback; | 2051 return pair.callback == callback; |
2051 } | 2052 } |
2052 v8::Isolate::GCPrologueCallback callback; | 2053 GCEpilogueCallback callback; |
2053 GCType gc_type; | 2054 GCType gc_type; |
2054 // TODO(dcarney): remove variable | |
2055 bool pass_isolate_; | |
2056 }; | 2055 }; |
2057 List<GCEpilogueCallbackPair> gc_epilogue_callbacks_; | 2056 List<GCEpilogueCallbackPair> gc_epilogue_callbacks_; |
2058 | 2057 |
| 2058 GCCallback global_gc_prologue_callback_; |
| 2059 GCCallback global_gc_epilogue_callback_; |
| 2060 |
2059 // Support for computing object sizes during GC. | 2061 // Support for computing object sizes during GC. |
2060 HeapObjectCallback gc_safe_size_of_old_object_; | 2062 HeapObjectCallback gc_safe_size_of_old_object_; |
2061 static int GcSafeSizeOfOldObject(HeapObject* object); | 2063 static int GcSafeSizeOfOldObject(HeapObject* object); |
2062 | 2064 |
2063 // Update the GC state. Called from the mark-compact collector. | 2065 // Update the GC state. Called from the mark-compact collector. |
2064 void MarkMapPointersAsEncoded(bool encoded) { | 2066 void MarkMapPointersAsEncoded(bool encoded) { |
2065 ASSERT(!encoded); | 2067 ASSERT(!encoded); |
2066 gc_safe_size_of_old_object_ = &GcSafeSizeOfOldObject; | 2068 gc_safe_size_of_old_object_ = &GcSafeSizeOfOldObject; |
2067 } | 2069 } |
2068 | 2070 |
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3038 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 3040 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
3039 | 3041 |
3040 private: | 3042 private: |
3041 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 3043 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
3042 }; | 3044 }; |
3043 #endif // DEBUG | 3045 #endif // DEBUG |
3044 | 3046 |
3045 } } // namespace v8::internal | 3047 } } // namespace v8::internal |
3046 | 3048 |
3047 #endif // V8_HEAP_H_ | 3049 #endif // V8_HEAP_H_ |
OLD | NEW |