50 chklvl_t get_next_chunk_level(int num_allocated) const { |
50 chklvl_t get_next_chunk_level(int num_allocated) const { |
51 if (num_allocated >= _num_entries) { |
51 if (num_allocated >= _num_entries) { |
52 // Caller shall repeat last allocation |
52 // Caller shall repeat last allocation |
53 return _entries[_num_entries - 1]; |
53 return _entries[_num_entries - 1]; |
54 } |
54 } |
55 return _entries[_num_entries]; |
55 return _entries[num_allocated]; |
56 } |
56 } |
57 |
57 |
58 }; |
58 }; |
59 |
59 |
60 // hard-coded chunk allocation sequences for various space types |
60 // hard-coded chunk allocation sequences for various space types |
61 |
61 |
62 /////////////////////////// |
62 /////////////////////////// |
63 // chunk allocation sequences for normal loaders: |
63 // chunk allocation sequences for normal loaders: |
64 static const chklvl_t g_sequ_standard_nonclass[] = { |
64 static const chklvl_t g_sequ_standard_non_class[] = { |
65 chklvl::CHUNK_LEVEL_4K, |
65 chklvl::CHUNK_LEVEL_4K, |
66 chklvl::CHUNK_LEVEL_4K, |
66 chklvl::CHUNK_LEVEL_4K, |
67 chklvl::CHUNK_LEVEL_4K, |
67 chklvl::CHUNK_LEVEL_4K, |
68 chklvl::CHUNK_LEVEL_4K, |
68 chklvl::CHUNK_LEVEL_4K, |
69 chklvl::CHUNK_LEVEL_64K |
69 chklvl::CHUNK_LEVEL_64K |
70 -1 // .. repeat last |
70 // .. repeat last |
71 }; |
71 }; |
72 |
72 |
73 static const chklvl_t g_sequ_standard_class[] = { |
73 static const chklvl_t g_sequ_standard_class[] = { |
74 chklvl::CHUNK_LEVEL_2K, |
74 chklvl::CHUNK_LEVEL_2K, |
75 chklvl::CHUNK_LEVEL_2K, |
75 chklvl::CHUNK_LEVEL_2K, |
76 chklvl::CHUNK_LEVEL_2K, |
76 chklvl::CHUNK_LEVEL_2K, |
77 chklvl::CHUNK_LEVEL_2K, |
77 chklvl::CHUNK_LEVEL_2K, |
78 chklvl::CHUNK_LEVEL_32K, |
78 chklvl::CHUNK_LEVEL_32K |
79 -1 // .. repeat last |
79 // .. repeat last |
80 }; |
80 }; |
81 |
81 |
82 /////////////////////////// |
82 /////////////////////////// |
83 // chunk allocation sequences for reflection/anonymous loaders: |
83 // chunk allocation sequences for reflection/anonymous loaders: |
84 // We allocate four smallish chunks before progressing to bigger chunks. |
84 // We allocate four smallish chunks before progressing to bigger chunks. |
85 static const chklvl_t g_sequ_anon_nonclass[] = { |
85 static const chklvl_t g_sequ_anon_non_class[] = { |
86 chklvl::CHUNK_LEVEL_1K, |
86 chklvl::CHUNK_LEVEL_1K, |
87 chklvl::CHUNK_LEVEL_1K, |
87 chklvl::CHUNK_LEVEL_1K, |
88 chklvl::CHUNK_LEVEL_1K, |
88 chklvl::CHUNK_LEVEL_1K, |
89 chklvl::CHUNK_LEVEL_1K, |
89 chklvl::CHUNK_LEVEL_1K, |
90 chklvl::CHUNK_LEVEL_4K, |
90 chklvl::CHUNK_LEVEL_2K |
91 -1 // .. repeat last |
91 // .. repeat last |
92 }; |
92 }; |
93 |
93 |
94 static const chklvl_t g_sequ_anon_class[] = { |
94 static const chklvl_t g_sequ_anon_class[] = { |
95 chklvl::CHUNK_LEVEL_1K, |
95 chklvl::CHUNK_LEVEL_1K, |
96 chklvl::CHUNK_LEVEL_1K, |
96 chklvl::CHUNK_LEVEL_1K, |
97 chklvl::CHUNK_LEVEL_1K, |
97 chklvl::CHUNK_LEVEL_1K, |
98 chklvl::CHUNK_LEVEL_1K, |
98 chklvl::CHUNK_LEVEL_1K, |
99 chklvl::CHUNK_LEVEL_4K, |
99 chklvl::CHUNK_LEVEL_2K |
100 -1 // .. repeat last |
100 // .. repeat last |
101 }; |
101 }; |
102 |
102 |
103 #define DEFINE_CLASS_FOR_ARRAY(what) \ |
103 #define DEFINE_CLASS_FOR_ARRAY(what) \ |
104 static ConstantChunkAllocSequence g_chunk_alloc_sequence_##what (g_sequ_##what, sizeof(g_sequ_##what)/sizeof(int)); |
104 static ConstantChunkAllocSequence g_chunk_alloc_sequence_##what (g_sequ_##what, sizeof(g_sequ_##what)/sizeof(chklvl_t)); |
105 |
105 |
106 DEFINE_CLASS_FOR_ARRAY(standard_nonclass) |
106 DEFINE_CLASS_FOR_ARRAY(standard_non_class) |
107 DEFINE_CLASS_FOR_ARRAY(standard_class) |
107 DEFINE_CLASS_FOR_ARRAY(standard_class) |
108 DEFINE_CLASS_FOR_ARRAY(anon_nonclass) |
108 DEFINE_CLASS_FOR_ARRAY(anon_non_class) |
109 DEFINE_CLASS_FOR_ARRAY(anon_class) |
109 DEFINE_CLASS_FOR_ARRAY(anon_class) |
110 |
110 |
111 |
111 |
112 class BootLoaderChunkAllocSequence : public ChunkAllocSequence { |
112 class BootLoaderChunkAllocSequence : public ChunkAllocSequence { |
113 |
113 |