1 /*
2 * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
365 public:
366 virtual bool do_allocation_site(const ReservedMemoryRegion* rgn) { return false; }
367 };
368
369 // Main class called from MemTracker to track virtual memory allocations, commits and releases.
370 class VirtualMemoryTracker : AllStatic {
371 friend class VirtualMemoryTrackerTest;
372 friend class CommittedVirtualMemoryTest;
373
374 public:
375 static bool initialize(NMT_TrackingLevel level);
376
377 // Late phase initialization
378 static bool late_initialize(NMT_TrackingLevel level);
379
380 static bool add_reserved_region (address base_addr, size_t size, const NativeCallStack& stack, MEMFLAGS flag = mtNone);
381
382 static bool add_committed_region (address base_addr, size_t size, const NativeCallStack& stack);
383 static bool remove_uncommitted_region (address base_addr, size_t size);
384 static bool remove_released_region (address base_addr, size_t size);
385 static void set_reserved_region_type (address addr, MEMFLAGS flag);
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
392 // Walk virtual memory data structure for creating baseline, etc.
393 static bool walk_virtual_memory(VirtualMemoryWalker* walker);
394
395 static bool transition(NMT_TrackingLevel from, NMT_TrackingLevel to);
396
397 // Snapshot current thread stacks
398 static void snapshot_thread_stacks();
399
400 private:
401 static SortedLinkedList<ReservedMemoryRegion, compare_reserved_region_base>* _reserved_regions;
402 };
403
404
|
1 /*
2 * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
365 public:
366 virtual bool do_allocation_site(const ReservedMemoryRegion* rgn) { return false; }
367 };
368
369 // Main class called from MemTracker to track virtual memory allocations, commits and releases.
370 class VirtualMemoryTracker : AllStatic {
371 friend class VirtualMemoryTrackerTest;
372 friend class CommittedVirtualMemoryTest;
373
374 public:
375 static bool initialize(NMT_TrackingLevel level);
376
377 // Late phase initialization
378 static bool late_initialize(NMT_TrackingLevel level);
379
380 static bool add_reserved_region (address base_addr, size_t size, const NativeCallStack& stack, MEMFLAGS flag = mtNone);
381
382 static bool add_committed_region (address base_addr, size_t size, const NativeCallStack& stack);
383 static bool remove_uncommitted_region (address base_addr, size_t size);
384 static bool remove_released_region (address base_addr, size_t size);
385 static bool remove_released_region (ReservedMemoryRegion* rgn);
386 static void set_reserved_region_type (address addr, MEMFLAGS flag);
387
388 // Given an existing memory mapping registered with NMT, split the mapping in
389 // two. The newly created two mappings will be registered under the call
390 // stack and the memory flags of the original section.
391 static bool split_reserved_region(address addr, size_t size, size_t split);
392
393 // Walk virtual memory data structure for creating baseline, etc.
394 static bool walk_virtual_memory(VirtualMemoryWalker* walker);
395
396 static bool transition(NMT_TrackingLevel from, NMT_TrackingLevel to);
397
398 // Snapshot current thread stacks
399 static void snapshot_thread_stacks();
400
401 private:
402 static SortedLinkedList<ReservedMemoryRegion, compare_reserved_region_base>* _reserved_regions;
403 };
404
405
|