63 if (rgn->same_region(addr, size)) { |
63 if (rgn->same_region(addr, size)) { |
64 return true; |
64 return true; |
65 } |
65 } |
66 |
66 |
67 if (rgn->adjacent_to(addr, size)) { |
67 if (rgn->adjacent_to(addr, size)) { |
68 if (rgn->call_stack()->equals(stack)) { |
68 // special case to expand prior region if there is no next region |
|
69 LinkedListNode<CommittedMemoryRegion>* next = node->next(); |
|
70 if (next == NULL && rgn->call_stack()->equals(stack)) { |
|
71 VirtualMemorySummary::record_uncommitted_memory(rgn->size(), flag()); |
69 // the two adjacent regions have the same call stack, merge them |
72 // the two adjacent regions have the same call stack, merge them |
70 rgn->expand_region(addr, size); |
73 rgn->expand_region(addr, size); |
71 VirtualMemorySummary::record_committed_memory(size, flag()); |
74 VirtualMemorySummary::record_committed_memory(rgn->size(), flag()); |
72 |
|
73 // maybe merge with the next region |
|
74 LinkedListNode<CommittedMemoryRegion>* next_node = node->next(); |
|
75 if (next_node != NULL) { |
|
76 CommittedMemoryRegion* next = next_node->data(); |
|
77 if (next->call_stack()->equals(stack) && rgn->adjacent_to(next->base(), next->size())) { |
|
78 // the two adjacent regions have the same call stack, merge them |
|
79 rgn->expand_region(next->base(), next->size()); |
|
80 |
|
81 // the merge next_node needs to be removed from the list |
|
82 _committed_regions.remove(next_node); |
|
83 } |
|
84 } |
|
85 return true; |
75 return true; |
86 } |
76 } |
87 } |
77 } |
88 |
78 |
89 if (rgn->overlap_region(addr, size)) { |
79 if (rgn->overlap_region(addr, size)) { |
90 // Clear a space for this region in the case it overlaps with any regions. |
80 // Clear a space for this region in the case it overlaps with any regions. |
91 remove_uncommitted_region(addr, size); |
81 remove_uncommitted_region(addr, size); |
92 break; // commit below |
82 break; // commit below |
95 break; |
85 break; |
96 } |
86 } |
97 node = node->next(); |
87 node = node->next(); |
98 } |
88 } |
99 |
89 |
100 // New committed region |
90 // New committed region |
101 VirtualMemorySummary::record_committed_memory(size, flag()); |
91 VirtualMemorySummary::record_committed_memory(size, flag()); |
102 return add_committed_region(committed_rgn); |
92 return add_committed_region(committed_rgn); |
103 } |
93 } |
104 |
94 |
105 void ReservedMemoryRegion::set_all_committed(bool b) { |
95 void ReservedMemoryRegion::set_all_committed(bool b) { |
106 if (all_committed() != b) { |
96 if (all_committed() != b) { |
107 _all_committed = b; |
97 _all_committed = b; |
108 if (b) { |
98 if (b) { |