@@ -210,11 +210,8 @@ class VirtualMemoryRegion {
210
210
inline bool overlap_region (address addr, size_t sz) const {
211
211
assert (sz > 0 , " Invalid size" );
212
212
assert (size () > 0 , " Invalid size" );
213
- VirtualMemoryRegion rgn (addr, sz);
214
213
return contain_address (addr) ||
215
- contain_address (addr + sz - 1 ) ||
216
- rgn.contain_address (base ()) ||
217
- rgn.contain_address (end () - 1 );
214
+ contain_address (addr + sz - 1 );
218
215
}
219
216
220
217
inline bool adjacent_to (address addr, size_t sz) const {
@@ -240,6 +237,24 @@ class VirtualMemoryRegion {
240
237
set_size (size () + sz);
241
238
}
242
239
240
+ // Returns 0 if regions overlap; 1 if this region follows rgn;
241
+ // -1 if this region precedes rgn.
242
+ inline int compare (const VirtualMemoryRegion& rgn) const {
243
+ if (overlap_region (rgn.base (), rgn.size ())) {
244
+ return 0 ;
245
+ } else if (base () >= rgn.end ()) {
246
+ return 1 ;
247
+ } else {
248
+ assert (rgn.base () >= end (), " Sanity" );
249
+ return -1 ;
250
+ }
251
+ }
252
+
253
+ // Returns true if regions overlap, false otherwise.
254
+ inline bool equals (const VirtualMemoryRegion& rgn) const {
255
+ return compare (rgn) == 0 ;
256
+ }
257
+
243
258
protected:
244
259
void set_base (address base) {
245
260
assert (base != NULL , " Sanity check" );
@@ -261,24 +276,6 @@ class CommittedMemoryRegion : public VirtualMemoryRegion {
261
276
CommittedMemoryRegion (address addr, size_t size, const NativeCallStack& stack) :
262
277
VirtualMemoryRegion (addr, size), _stack(stack) { }
263
278
264
- inline int compare (const CommittedMemoryRegion& rgn) const {
265
- if (overlap_region (rgn.base (), rgn.size ())) {
266
- return 0 ;
267
- } else {
268
- if (base () == rgn.base ()) {
269
- return 0 ;
270
- } else if (base () > rgn.base ()) {
271
- return 1 ;
272
- } else {
273
- return -1 ;
274
- }
275
- }
276
- }
277
-
278
- inline bool equals (const CommittedMemoryRegion& rgn) const {
279
- return compare (rgn) == 0 ;
280
- }
281
-
282
279
inline void set_call_stack (const NativeCallStack& stack) { _stack = stack; }
283
280
inline const NativeCallStack* call_stack () const { return &_stack; }
284
281
};
@@ -316,24 +313,6 @@ class ReservedMemoryRegion : public VirtualMemoryRegion {
316
313
void set_flag (MEMFLAGS flag);
317
314
inline MEMFLAGS flag () const { return _flag; }
318
315
319
- inline int compare (const ReservedMemoryRegion& rgn) const {
320
- if (overlap_region (rgn.base (), rgn.size ())) {
321
- return 0 ;
322
- } else {
323
- if (base () == rgn.base ()) {
324
- return 0 ;
325
- } else if (base () > rgn.base ()) {
326
- return 1 ;
327
- } else {
328
- return -1 ;
329
- }
330
- }
331
- }
332
-
333
- inline bool equals (const ReservedMemoryRegion& rgn) const {
334
- return compare (rgn) == 0 ;
335
- }
336
-
337
316
// uncommitted thread stack bottom, above guard pages if there is any.
338
317
address thread_stack_uncommitted_bottom () const ;
339
318
@@ -405,6 +384,11 @@ class VirtualMemoryTracker : AllStatic {
405
384
static bool remove_released_region (address base_addr, size_t size);
406
385
static void set_reserved_region_type (address addr, MEMFLAGS flag);
407
386
387
+ // Given an existing memory mapping registered with NMT, split the mapping in
388
+ // two. The newly created two mappings will be registered under the call
389
+ // stack and the memory flags of the original section.
390
+ static bool split_reserved_region (address addr, size_t size, size_t split);
391
+
408
392
// Walk virtual memory data structure for creating baseline, etc.
409
393
static bool walk_virtual_memory (VirtualMemoryWalker* walker);
410
394
0 commit comments