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 2422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2433 | 2433 |
2434 | 2434 |
2435 // ----------------------------------------------------------------------------- | 2435 // ----------------------------------------------------------------------------- |
2436 // Old space for objects of a fixed size | 2436 // Old space for objects of a fixed size |
2437 | 2437 |
2438 class FixedSpace : public PagedSpace { | 2438 class FixedSpace : public PagedSpace { |
2439 public: | 2439 public: |
2440 FixedSpace(Heap* heap, | 2440 FixedSpace(Heap* heap, |
2441 intptr_t max_capacity, | 2441 intptr_t max_capacity, |
2442 AllocationSpace id, | 2442 AllocationSpace id, |
2443 int object_size_in_bytes, | 2443 int object_size_in_bytes) |
2444 const char* name) | |
2445 : PagedSpace(heap, max_capacity, id, NOT_EXECUTABLE), | 2444 : PagedSpace(heap, max_capacity, id, NOT_EXECUTABLE), |
2446 object_size_in_bytes_(object_size_in_bytes), | 2445 object_size_in_bytes_(object_size_in_bytes) { |
2447 name_(name) { | |
2448 page_extra_ = Page::kNonCodeObjectAreaSize % object_size_in_bytes; | 2446 page_extra_ = Page::kNonCodeObjectAreaSize % object_size_in_bytes; |
2449 } | 2447 } |
2450 | 2448 |
2451 // The limit of allocation for a page in this space. | 2449 // The limit of allocation for a page in this space. |
2452 virtual Address PageAllocationLimit(Page* page) { | 2450 virtual Address PageAllocationLimit(Page* page) { |
2453 return page->area_end() - page_extra_; | 2451 return page->area_end() - page_extra_; |
2454 } | 2452 } |
2455 | 2453 |
2456 int object_size_in_bytes() { return object_size_in_bytes_; } | 2454 int object_size_in_bytes() { return object_size_in_bytes_; } |
2457 | 2455 |
2458 // Prepares for a mark-compact GC. | 2456 // Prepares for a mark-compact GC. |
2459 virtual void PrepareForMarkCompact(); | 2457 virtual void PrepareForMarkCompact(); |
2460 | 2458 |
2461 private: | 2459 private: |
2462 // The size of objects in this space. | 2460 // The size of objects in this space. |
2463 int object_size_in_bytes_; | 2461 int object_size_in_bytes_; |
2464 | |
2465 // The name of this space. | |
2466 const char* name_; | |
2467 }; | 2462 }; |
2468 | 2463 |
2469 | 2464 |
2470 // ----------------------------------------------------------------------------- | 2465 // ----------------------------------------------------------------------------- |
2471 // Old space for all map objects | 2466 // Old space for all map objects |
2472 | 2467 |
2473 class MapSpace : public FixedSpace { | 2468 class MapSpace : public FixedSpace { |
2474 public: | 2469 public: |
2475 // Creates a map space object with a maximum capacity. | 2470 // Creates a map space object with a maximum capacity. |
2476 MapSpace(Heap* heap, intptr_t max_capacity, AllocationSpace id) | 2471 MapSpace(Heap* heap, intptr_t max_capacity, AllocationSpace id) |
2477 : FixedSpace(heap, max_capacity, id, Map::kSize, "map"), | 2472 : FixedSpace(heap, max_capacity, id, Map::kSize), |
2478 max_map_space_pages_(kMaxMapPageIndex - 1) { | 2473 max_map_space_pages_(kMaxMapPageIndex - 1) { |
2479 } | 2474 } |
2480 | 2475 |
2481 // Given an index, returns the page address. | 2476 // Given an index, returns the page address. |
2482 // TODO(1600): this limit is artifical just to keep code compilable | 2477 // TODO(1600): this limit is artifical just to keep code compilable |
2483 static const int kMaxMapPageIndex = 1 << 16; | 2478 static const int kMaxMapPageIndex = 1 << 16; |
2484 | 2479 |
2485 virtual int RoundSizeDownToObjectAlignment(int size) { | 2480 virtual int RoundSizeDownToObjectAlignment(int size) { |
2486 if (IsPowerOf2(Map::kSize)) { | 2481 if (IsPowerOf2(Map::kSize)) { |
2487 return RoundDown(size, Map::kSize); | 2482 return RoundDown(size, Map::kSize); |
(...skipping 20 matching lines...) Expand all Loading... |
2508 }; | 2503 }; |
2509 | 2504 |
2510 | 2505 |
2511 // ----------------------------------------------------------------------------- | 2506 // ----------------------------------------------------------------------------- |
2512 // Old space for all global object property cell objects | 2507 // Old space for all global object property cell objects |
2513 | 2508 |
2514 class CellSpace : public FixedSpace { | 2509 class CellSpace : public FixedSpace { |
2515 public: | 2510 public: |
2516 // Creates a property cell space object with a maximum capacity. | 2511 // Creates a property cell space object with a maximum capacity. |
2517 CellSpace(Heap* heap, intptr_t max_capacity, AllocationSpace id) | 2512 CellSpace(Heap* heap, intptr_t max_capacity, AllocationSpace id) |
2518 : FixedSpace(heap, max_capacity, id, JSGlobalPropertyCell::kSize, "cell") | 2513 : FixedSpace(heap, max_capacity, id, JSGlobalPropertyCell::kSize) |
2519 {} | 2514 {} |
2520 | 2515 |
2521 virtual int RoundSizeDownToObjectAlignment(int size) { | 2516 virtual int RoundSizeDownToObjectAlignment(int size) { |
2522 if (IsPowerOf2(JSGlobalPropertyCell::kSize)) { | 2517 if (IsPowerOf2(JSGlobalPropertyCell::kSize)) { |
2523 return RoundDown(size, JSGlobalPropertyCell::kSize); | 2518 return RoundDown(size, JSGlobalPropertyCell::kSize); |
2524 } else { | 2519 } else { |
2525 return (size / JSGlobalPropertyCell::kSize) * JSGlobalPropertyCell::kSize; | 2520 return (size / JSGlobalPropertyCell::kSize) * JSGlobalPropertyCell::kSize; |
2526 } | 2521 } |
2527 } | 2522 } |
2528 | 2523 |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2728 } | 2723 } |
2729 // Must be small, since an iteration is used for lookup. | 2724 // Must be small, since an iteration is used for lookup. |
2730 static const int kMaxComments = 64; | 2725 static const int kMaxComments = 64; |
2731 }; | 2726 }; |
2732 #endif | 2727 #endif |
2733 | 2728 |
2734 | 2729 |
2735 } } // namespace v8::internal | 2730 } } // namespace v8::internal |
2736 | 2731 |
2737 #endif // V8_SPACES_H_ | 2732 #endif // V8_SPACES_H_ |
OLD | NEW |