Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(316)

Side by Side Diff: src/heap.h

Issue 23477061: Make objects embedded in optimized code weak. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix arm Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/handles.cc ('k') | src/heap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 array_buffers_list_ = object; 1301 array_buffers_list_ = object;
1302 } 1302 }
1303 Object* array_buffers_list() { return array_buffers_list_; } 1303 Object* array_buffers_list() { return array_buffers_list_; }
1304 1304
1305 void set_allocation_sites_list(Object* object) { 1305 void set_allocation_sites_list(Object* object) {
1306 allocation_sites_list_ = object; 1306 allocation_sites_list_ = object;
1307 } 1307 }
1308 Object* allocation_sites_list() { return allocation_sites_list_; } 1308 Object* allocation_sites_list() { return allocation_sites_list_; }
1309 Object** allocation_sites_list_address() { return &allocation_sites_list_; } 1309 Object** allocation_sites_list_address() { return &allocation_sites_list_; }
1310 1310
1311 Object* weak_object_to_code_table() { return weak_object_to_code_table_; }
1312
1311 // Number of mark-sweeps. 1313 // Number of mark-sweeps.
1312 unsigned int ms_count() { return ms_count_; } 1314 unsigned int ms_count() { return ms_count_; }
1313 1315
1314 // Iterates over all roots in the heap. 1316 // Iterates over all roots in the heap.
1315 void IterateRoots(ObjectVisitor* v, VisitMode mode); 1317 void IterateRoots(ObjectVisitor* v, VisitMode mode);
1316 // Iterates over all strong roots in the heap. 1318 // Iterates over all strong roots in the heap.
1317 void IterateStrongRoots(ObjectVisitor* v, VisitMode mode); 1319 void IterateStrongRoots(ObjectVisitor* v, VisitMode mode);
1318 // Iterates over all the other roots in the heap. 1320 // Iterates over all the other roots in the heap.
1319 void IterateWeakRoots(ObjectVisitor* v, VisitMode mode); 1321 void IterateWeakRoots(ObjectVisitor* v, VisitMode mode);
1320 1322
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1392 // Get address of native contexts list for serialization support. 1394 // Get address of native contexts list for serialization support.
1393 Object** native_contexts_list_address() { 1395 Object** native_contexts_list_address() {
1394 return &native_contexts_list_; 1396 return &native_contexts_list_;
1395 } 1397 }
1396 1398
1397 #ifdef VERIFY_HEAP 1399 #ifdef VERIFY_HEAP
1398 // Verify the heap is in its normal state before or after a GC. 1400 // Verify the heap is in its normal state before or after a GC.
1399 void Verify(); 1401 void Verify();
1400 1402
1401 1403
1402 bool weak_embedded_maps_verification_enabled() { 1404 bool weak_embedded_objects_verification_enabled() {
1403 return no_weak_embedded_maps_verification_scope_depth_ == 0; 1405 return no_weak_object_verification_scope_depth_ == 0;
1404 } 1406 }
1405 #endif 1407 #endif
1406 1408
1407 #ifdef DEBUG 1409 #ifdef DEBUG
1408 void Print(); 1410 void Print();
1409 void PrintHandles(); 1411 void PrintHandles();
1410 1412
1411 void OldPointerSpaceCheckStoreBuffer(); 1413 void OldPointerSpaceCheckStoreBuffer();
1412 void MapSpaceCheckStoreBuffer(); 1414 void MapSpaceCheckStoreBuffer();
1413 void LargeObjectSpaceCheckStoreBuffer(); 1415 void LargeObjectSpaceCheckStoreBuffer();
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1846 #ifdef DEBUG 1848 #ifdef DEBUG
1847 static bool IsLockedByOptimizerThread(Heap* heap) { 1849 static bool IsLockedByOptimizerThread(Heap* heap) {
1848 return heap->relocation_mutex_locked_by_optimizer_thread_; 1850 return heap->relocation_mutex_locked_by_optimizer_thread_;
1849 } 1851 }
1850 #endif // DEBUG 1852 #endif // DEBUG
1851 1853
1852 private: 1854 private:
1853 Heap* heap_; 1855 Heap* heap_;
1854 }; 1856 };
1855 1857
1858 MaybeObject* AddWeakObjectToCodeDependency(Object* obj, DependentCode* dep);
1859
1860 DependentCode* LookupWeakObjectToCodeDependency(Object* obj);
1861
1862 void InitializeWeakObjectToCodeTable() {
1863 set_weak_object_to_code_table(undefined_value());
1864 }
1865
1866 void EnsureWeakObjectToCodeTable();
1867
1856 private: 1868 private:
1857 Heap(); 1869 Heap();
1858 1870
1859 // This can be calculated directly from a pointer to the heap; however, it is 1871 // This can be calculated directly from a pointer to the heap; however, it is
1860 // more expedient to get at the isolate directly from within Heap methods. 1872 // more expedient to get at the isolate directly from within Heap methods.
1861 Isolate* isolate_; 1873 Isolate* isolate_;
1862 1874
1863 Object* roots_[kRootListLength]; 1875 Object* roots_[kRootListLength];
1864 1876
1865 intptr_t code_range_size_; 1877 intptr_t code_range_size_;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1960 intptr_t amount_of_external_allocated_memory_; 1972 intptr_t amount_of_external_allocated_memory_;
1961 1973
1962 // Caches the amount of external memory registered at the last global gc. 1974 // Caches the amount of external memory registered at the last global gc.
1963 intptr_t amount_of_external_allocated_memory_at_last_global_gc_; 1975 intptr_t amount_of_external_allocated_memory_at_last_global_gc_;
1964 1976
1965 // Indicates that an allocation has failed in the old generation since the 1977 // Indicates that an allocation has failed in the old generation since the
1966 // last GC. 1978 // last GC.
1967 bool old_gen_exhausted_; 1979 bool old_gen_exhausted_;
1968 1980
1969 // Weak list heads, threaded through the objects. 1981 // Weak list heads, threaded through the objects.
1982 // List heads are initilized lazily and contain the undefined_value at start.
1970 Object* native_contexts_list_; 1983 Object* native_contexts_list_;
1971 Object* array_buffers_list_; 1984 Object* array_buffers_list_;
1972 Object* allocation_sites_list_; 1985 Object* allocation_sites_list_;
1973 1986
1987 // WeakHashTable that maps objects embedded in optimized code to dependent
1988 // code list. It is initilized lazily and contains the undefined_value at
1989 // start.
1990 Object* weak_object_to_code_table_;
1991
1974 StoreBufferRebuilder store_buffer_rebuilder_; 1992 StoreBufferRebuilder store_buffer_rebuilder_;
1975 1993
1976 struct StringTypeTable { 1994 struct StringTypeTable {
1977 InstanceType type; 1995 InstanceType type;
1978 int size; 1996 int size;
1979 RootListIndex index; 1997 RootListIndex index;
1980 }; 1998 };
1981 1999
1982 struct ConstantStringTable { 2000 struct ConstantStringTable {
1983 const char* contents; 2001 const char* contents;
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
2272 return heap_size_mb / kMbPerMs; 2290 return heap_size_mb / kMbPerMs;
2273 } 2291 }
2274 2292
2275 // Returns true if no more GC work is left. 2293 // Returns true if no more GC work is left.
2276 bool IdleGlobalGC(); 2294 bool IdleGlobalGC();
2277 2295
2278 void AdvanceIdleIncrementalMarking(intptr_t step_size); 2296 void AdvanceIdleIncrementalMarking(intptr_t step_size);
2279 2297
2280 void ClearObjectStats(bool clear_last_time_stats = false); 2298 void ClearObjectStats(bool clear_last_time_stats = false);
2281 2299
2300 void set_weak_object_to_code_table(Object* value) {
2301 ASSERT(!InNewSpace(value));
2302 weak_object_to_code_table_ = value;
2303 }
2304
2305 Object** weak_object_to_code_table_address() {
2306 return &weak_object_to_code_table_;
2307 }
2308
2282 static const int kInitialStringTableSize = 2048; 2309 static const int kInitialStringTableSize = 2048;
2283 static const int kInitialEvalCacheSize = 64; 2310 static const int kInitialEvalCacheSize = 64;
2284 static const int kInitialNumberStringCacheSize = 256; 2311 static const int kInitialNumberStringCacheSize = 256;
2285 2312
2286 // Object counts and used memory by InstanceType 2313 // Object counts and used memory by InstanceType
2287 size_t object_counts_[OBJECT_STATS_COUNT]; 2314 size_t object_counts_[OBJECT_STATS_COUNT];
2288 size_t object_counts_last_time_[OBJECT_STATS_COUNT]; 2315 size_t object_counts_last_time_[OBJECT_STATS_COUNT];
2289 size_t object_sizes_[OBJECT_STATS_COUNT]; 2316 size_t object_sizes_[OBJECT_STATS_COUNT];
2290 size_t object_sizes_last_time_[OBJECT_STATS_COUNT]; 2317 size_t object_sizes_last_time_[OBJECT_STATS_COUNT];
2291 2318
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2327 int mark_sweeps_since_idle_round_started_; 2354 int mark_sweeps_since_idle_round_started_;
2328 unsigned int gc_count_at_last_idle_gc_; 2355 unsigned int gc_count_at_last_idle_gc_;
2329 int scavenges_since_last_idle_round_; 2356 int scavenges_since_last_idle_round_;
2330 2357
2331 // If the --deopt_every_n_garbage_collections flag is set to a positive value, 2358 // If the --deopt_every_n_garbage_collections flag is set to a positive value,
2332 // this variable holds the number of garbage collections since the last 2359 // this variable holds the number of garbage collections since the last
2333 // deoptimization triggered by garbage collection. 2360 // deoptimization triggered by garbage collection.
2334 int gcs_since_last_deopt_; 2361 int gcs_since_last_deopt_;
2335 2362
2336 #ifdef VERIFY_HEAP 2363 #ifdef VERIFY_HEAP
2337 int no_weak_embedded_maps_verification_scope_depth_; 2364 int no_weak_object_verification_scope_depth_;
2338 #endif 2365 #endif
2339 2366
2340 static const int kMaxMarkSweepsInIdleRound = 7; 2367 static const int kMaxMarkSweepsInIdleRound = 7;
2341 static const int kIdleScavengeThreshold = 5; 2368 static const int kIdleScavengeThreshold = 5;
2342 2369
2343 // Shared state read by the scavenge collector and set by ScavengeObject. 2370 // Shared state read by the scavenge collector and set by ScavengeObject.
2344 PromotionQueue promotion_queue_; 2371 PromotionQueue promotion_queue_;
2345 2372
2346 // Flag is set when the heap has been configured. The heap can be repeatedly 2373 // Flag is set when the heap has been configured. The heap can be repeatedly
2347 // configured through the API until it is set up. 2374 // configured through the API until it is set up.
(...skipping 13 matching lines...) Expand all
2361 friend class Factory; 2388 friend class Factory;
2362 friend class GCTracer; 2389 friend class GCTracer;
2363 friend class DisallowAllocationFailure; 2390 friend class DisallowAllocationFailure;
2364 friend class AlwaysAllocateScope; 2391 friend class AlwaysAllocateScope;
2365 friend class Page; 2392 friend class Page;
2366 friend class Isolate; 2393 friend class Isolate;
2367 friend class MarkCompactCollector; 2394 friend class MarkCompactCollector;
2368 friend class MarkCompactMarkingVisitor; 2395 friend class MarkCompactMarkingVisitor;
2369 friend class MapCompact; 2396 friend class MapCompact;
2370 #ifdef VERIFY_HEAP 2397 #ifdef VERIFY_HEAP
2371 friend class NoWeakEmbeddedMapsVerificationScope; 2398 friend class NoWeakObjectVerificationScope;
2372 #endif 2399 #endif
2373 2400
2374 DISALLOW_COPY_AND_ASSIGN(Heap); 2401 DISALLOW_COPY_AND_ASSIGN(Heap);
2375 }; 2402 };
2376 2403
2377 2404
2378 class HeapStats { 2405 class HeapStats {
2379 public: 2406 public:
2380 static const int kStartMarker = 0xDECADE00; 2407 static const int kStartMarker = 0xDECADE00;
2381 static const int kEndMarker = 0xDECADE01; 2408 static const int kEndMarker = 0xDECADE01;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2426 public: 2453 public:
2427 inline AlwaysAllocateScope(); 2454 inline AlwaysAllocateScope();
2428 inline ~AlwaysAllocateScope(); 2455 inline ~AlwaysAllocateScope();
2429 2456
2430 private: 2457 private:
2431 // Implicitly disable artificial allocation failures. 2458 // Implicitly disable artificial allocation failures.
2432 DisallowAllocationFailure disallow_allocation_failure_; 2459 DisallowAllocationFailure disallow_allocation_failure_;
2433 }; 2460 };
2434 2461
2435 #ifdef VERIFY_HEAP 2462 #ifdef VERIFY_HEAP
2436 class NoWeakEmbeddedMapsVerificationScope { 2463 class NoWeakObjectVerificationScope {
2437 public: 2464 public:
2438 inline NoWeakEmbeddedMapsVerificationScope(); 2465 inline NoWeakObjectVerificationScope();
2439 inline ~NoWeakEmbeddedMapsVerificationScope(); 2466 inline ~NoWeakObjectVerificationScope();
2440 }; 2467 };
2441 #endif 2468 #endif
2442 2469
2443 2470
2444 // Visitor class to verify interior pointers in spaces that do not contain 2471 // Visitor class to verify interior pointers in spaces that do not contain
2445 // or care about intergenerational references. All heap object pointers have to 2472 // or care about intergenerational references. All heap object pointers have to
2446 // point into the heap to a location that has a map pointer at its first word. 2473 // point into the heap to a location that has a map pointer at its first word.
2447 // Caveat: Heap::Contains is an approximation because it can return true for 2474 // Caveat: Heap::Contains is an approximation because it can return true for
2448 // objects in a heap space but above the allocation pointer. 2475 // objects in a heap space but above the allocation pointer.
2449 class VerifyPointersVisitor: public ObjectVisitor { 2476 class VerifyPointersVisitor: public ObjectVisitor {
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
3033 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. 3060 DisallowHeapAllocation no_allocation; // i.e. no gc allowed.
3034 3061
3035 private: 3062 private:
3036 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); 3063 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer);
3037 }; 3064 };
3038 #endif // DEBUG 3065 #endif // DEBUG
3039 3066
3040 } } // namespace v8::internal 3067 } } // namespace v8::internal
3041 3068
3042 #endif // V8_HEAP_H_ 3069 #endif // V8_HEAP_H_
OLDNEW
« no previous file with comments | « src/handles.cc ('k') | src/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698