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

Side by Side Diff: src/spaces.h

Issue 7324051: Remove heap protection support. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 5 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/platform-win32.cc ('k') | src/spaces.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 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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 // Identity used in error reporting. 373 // Identity used in error reporting.
374 AllocationSpace identity() { return id_; } 374 AllocationSpace identity() { return id_; }
375 375
376 // Returns allocated size. 376 // Returns allocated size.
377 virtual intptr_t Size() = 0; 377 virtual intptr_t Size() = 0;
378 378
379 // Returns size of objects. Can differ from the allocated size 379 // Returns size of objects. Can differ from the allocated size
380 // (e.g. see LargeObjectSpace). 380 // (e.g. see LargeObjectSpace).
381 virtual intptr_t SizeOfObjects() { return Size(); } 381 virtual intptr_t SizeOfObjects() { return Size(); }
382 382
383 #ifdef ENABLE_HEAP_PROTECTION
384 // Protect/unprotect the space by marking it read-only/writable.
385 virtual void Protect() = 0;
386 virtual void Unprotect() = 0;
387 #endif
388
389 #ifdef DEBUG 383 #ifdef DEBUG
390 virtual void Print() = 0; 384 virtual void Print() = 0;
391 #endif 385 #endif
392 386
393 // After calling this we can allocate a certain number of bytes using only 387 // After calling this we can allocate a certain number of bytes using only
394 // linear allocation (with a LinearAllocationScope and an AlwaysAllocateScope) 388 // linear allocation (with a LinearAllocationScope and an AlwaysAllocateScope)
395 // without using freelists or causing a GC. This is used by partial 389 // without using freelists or causing a GC. This is used by partial
396 // snapshots. It returns true of space was reserved or false if a GC is 390 // snapshots. It returns true of space was reserved or false if a GC is
397 // needed. For paged spaces the space requested must include the space wasted 391 // needed. For paged spaces the space requested must include the space wasted
398 // at the end of each when allocating linearly. 392 // at the end of each when allocating linearly.
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 628
635 // Relinks list of pages owned by space to make it chunk-ordered. 629 // Relinks list of pages owned by space to make it chunk-ordered.
636 // Returns new first and last pages of space. 630 // Returns new first and last pages of space.
637 // Also returns last page in relinked list which has WasInUsedBeforeMC 631 // Also returns last page in relinked list which has WasInUsedBeforeMC
638 // flag set. 632 // flag set.
639 void RelinkPageListInChunkOrder(PagedSpace* space, 633 void RelinkPageListInChunkOrder(PagedSpace* space,
640 Page** first_page, 634 Page** first_page,
641 Page** last_page, 635 Page** last_page,
642 Page** last_page_in_use); 636 Page** last_page_in_use);
643 637
644 #ifdef ENABLE_HEAP_PROTECTION
645 // Protect/unprotect a block of memory by marking it read-only/writable.
646 inline void Protect(Address start, size_t size);
647 inline void Unprotect(Address start, size_t size,
648 Executability executable);
649
650 // Protect/unprotect a chunk given a page in the chunk.
651 inline void ProtectChunkFromPage(Page* page);
652 inline void UnprotectChunkFromPage(Page* page);
653 #endif
654
655 #ifdef DEBUG 638 #ifdef DEBUG
656 // Reports statistic info of the space. 639 // Reports statistic info of the space.
657 void ReportStatistics(); 640 void ReportStatistics();
658 #endif 641 #endif
659 642
660 // Due to encoding limitation, we can only have 8K chunks. 643 // Due to encoding limitation, we can only have 8K chunks.
661 static const int kMaxNofChunks = 1 << kPageSizeBits; 644 static const int kMaxNofChunks = 1 << kPageSizeBits;
662 // If a chunk has at least 16 pages, the maximum heap size is about 645 // If a chunk has at least 16 pages, the maximum heap size is about
663 // 8K * 8K * 16 = 1G bytes. 646 // 8K * 8K * 16 = 1G bytes.
664 #ifdef V8_TARGET_ARCH_X64 647 #ifdef V8_TARGET_ARCH_X64
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 // Updates the allocation pointer to the relocation top after a mark-compact 1133 // Updates the allocation pointer to the relocation top after a mark-compact
1151 // collection. 1134 // collection.
1152 virtual void MCCommitRelocationInfo() = 0; 1135 virtual void MCCommitRelocationInfo() = 0;
1153 1136
1154 // Releases half of unused pages. 1137 // Releases half of unused pages.
1155 void Shrink(); 1138 void Shrink();
1156 1139
1157 // Ensures that the capacity is at least 'capacity'. Returns false on failure. 1140 // Ensures that the capacity is at least 'capacity'. Returns false on failure.
1158 bool EnsureCapacity(int capacity); 1141 bool EnsureCapacity(int capacity);
1159 1142
1160 #ifdef ENABLE_HEAP_PROTECTION
1161 // Protect/unprotect the space by marking it read-only/writable.
1162 void Protect();
1163 void Unprotect();
1164 #endif
1165
1166 #ifdef DEBUG 1143 #ifdef DEBUG
1167 // Print meta info and objects in this space. 1144 // Print meta info and objects in this space.
1168 virtual void Print(); 1145 virtual void Print();
1169 1146
1170 // Verify integrity of this space. 1147 // Verify integrity of this space.
1171 virtual void Verify(ObjectVisitor* visitor); 1148 virtual void Verify(ObjectVisitor* visitor);
1172 1149
1173 // Overridden by subclasses to verify space-specific object 1150 // Overridden by subclasses to verify space-specific object
1174 // properties (e.g., only maps or free-list nodes are in map space). 1151 // properties (e.g., only maps or free-list nodes are in map space).
1175 virtual void VerifyObject(HeapObject* obj) {} 1152 virtual void VerifyObject(HeapObject* obj) {}
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1385 1362
1386 virtual bool ReserveSpace(int bytes) { 1363 virtual bool ReserveSpace(int bytes) {
1387 UNREACHABLE(); 1364 UNREACHABLE();
1388 return false; 1365 return false;
1389 } 1366 }
1390 1367
1391 bool is_committed() { return committed_; } 1368 bool is_committed() { return committed_; }
1392 bool Commit(); 1369 bool Commit();
1393 bool Uncommit(); 1370 bool Uncommit();
1394 1371
1395 #ifdef ENABLE_HEAP_PROTECTION
1396 // Protect/unprotect the space by marking it read-only/writable.
1397 virtual void Protect() {}
1398 virtual void Unprotect() {}
1399 #endif
1400
1401 #ifdef DEBUG 1372 #ifdef DEBUG
1402 virtual void Print(); 1373 virtual void Print();
1403 virtual void Verify(); 1374 virtual void Verify();
1404 #endif 1375 #endif
1405 1376
1406 // Returns the current capacity of the semi space. 1377 // Returns the current capacity of the semi space.
1407 int Capacity() { return capacity_; } 1378 int Capacity() { return capacity_; }
1408 1379
1409 // Returns the maximum capacity of the semi space. 1380 // Returns the maximum capacity of the semi space.
1410 int MaximumCapacity() { return maximum_capacity_; } 1381 int MaximumCapacity() { return maximum_capacity_; }
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1621 bool ToSpaceContains(Address a) { return to_space_.Contains(a); } 1592 bool ToSpaceContains(Address a) { return to_space_.Contains(a); }
1622 bool FromSpaceContains(Address a) { return from_space_.Contains(a); } 1593 bool FromSpaceContains(Address a) { return from_space_.Contains(a); }
1623 1594
1624 virtual bool ReserveSpace(int bytes); 1595 virtual bool ReserveSpace(int bytes);
1625 1596
1626 // Resizes a sequential string which must be the most recent thing that was 1597 // Resizes a sequential string which must be the most recent thing that was
1627 // allocated in new space. 1598 // allocated in new space.
1628 template <typename StringType> 1599 template <typename StringType>
1629 inline void ShrinkStringAtAllocationBoundary(String* string, int len); 1600 inline void ShrinkStringAtAllocationBoundary(String* string, int len);
1630 1601
1631 #ifdef ENABLE_HEAP_PROTECTION
1632 // Protect/unprotect the space by marking it read-only/writable.
1633 virtual void Protect();
1634 virtual void Unprotect();
1635 #endif
1636
1637 #ifdef DEBUG 1602 #ifdef DEBUG
1638 // Verify the active semispace. 1603 // Verify the active semispace.
1639 virtual void Verify(); 1604 virtual void Verify();
1640 // Print the active semispace. 1605 // Print the active semispace.
1641 virtual void Print() { to_space_.Print(); } 1606 virtual void Print() { to_space_.Print(); }
1642 #endif 1607 #endif
1643 1608
1644 #if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING) 1609 #if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING)
1645 // Iterates the active semispace to collect statistics. 1610 // Iterates the active semispace to collect statistics.
1646 void CollectStatistics(); 1611 void CollectStatistics();
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
2289 bool Contains(HeapObject* obj); 2254 bool Contains(HeapObject* obj);
2290 2255
2291 // Checks whether the space is empty. 2256 // Checks whether the space is empty.
2292 bool IsEmpty() { return first_chunk_ == NULL; } 2257 bool IsEmpty() { return first_chunk_ == NULL; }
2293 2258
2294 // See the comments for ReserveSpace in the Space class. This has to be 2259 // See the comments for ReserveSpace in the Space class. This has to be
2295 // called after ReserveSpace has been called on the paged spaces, since they 2260 // called after ReserveSpace has been called on the paged spaces, since they
2296 // may use some memory, leaving less for large objects. 2261 // may use some memory, leaving less for large objects.
2297 virtual bool ReserveSpace(int bytes); 2262 virtual bool ReserveSpace(int bytes);
2298 2263
2299 #ifdef ENABLE_HEAP_PROTECTION
2300 // Protect/unprotect the space by marking it read-only/writable.
2301 void Protect();
2302 void Unprotect();
2303 #endif
2304
2305 #ifdef DEBUG 2264 #ifdef DEBUG
2306 virtual void Verify(); 2265 virtual void Verify();
2307 virtual void Print(); 2266 virtual void Print();
2308 void ReportStatistics(); 2267 void ReportStatistics();
2309 void CollectCodeStatistics(); 2268 void CollectCodeStatistics();
2310 #endif 2269 #endif
2311 // Checks whether an address is in the object area in this space. It 2270 // Checks whether an address is in the object area in this space. It
2312 // iterates all objects in the space. May be slow. 2271 // iterates all objects in the space. May be slow.
2313 bool SlowContains(Address addr) { return !FindObject(addr)->IsFailure(); } 2272 bool SlowContains(Address addr) { return !FindObject(addr)->IsFailure(); }
2314 2273
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2360 } 2319 }
2361 // Must be small, since an iteration is used for lookup. 2320 // Must be small, since an iteration is used for lookup.
2362 static const int kMaxComments = 64; 2321 static const int kMaxComments = 64;
2363 }; 2322 };
2364 #endif 2323 #endif
2365 2324
2366 2325
2367 } } // namespace v8::internal 2326 } } // namespace v8::internal
2368 2327
2369 #endif // V8_SPACES_H_ 2328 #endif // V8_SPACES_H_
OLDNEW
« no previous file with comments | « src/platform-win32.cc ('k') | src/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698