< prev index next >

src/hotspot/share/gc/parallel/psFileBackedVirtualspace.cpp

8221260: Initialize more class members on construction, remove some unused ones
Reviewed-by:

0 /*                                                                                                                         
1  * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.                                                  
2  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.                                                           
3  *                                                                                                                         
4  * This code is free software; you can redistribute it and/or modify it                                                    
5  * under the terms of the GNU General Public License version 2 only, as                                                    
6  * published by the Free Software Foundation.                                                                              
7  *                                                                                                                         
8  * This code is distributed in the hope that it will be useful, but WITHOUT                                                
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or                                                   
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License                                                   
11  * version 2 for more details (a copy is included in the LICENSE file that                                                 
12  * accompanied this code).                                                                                                 
13  *                                                                                                                         
14  * You should have received a copy of the GNU General Public License version                                               
15  * 2 along with this work; if not, write to the Free Software Foundation,                                                  
16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.                                                           
17  *                                                                                                                         
18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA                                                 
19  * or visit www.oracle.com if you need additional information or have any                                                  
20  * questions.                                                                                                              

0 /*
1  * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3  *
4  * This code is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 2 only, as
6  * published by the Free Software Foundation.
7  *
8  * This code is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
11  * version 2 for more details (a copy is included in the LICENSE file that
12  * accompanied this code).
13  *
14  * You should have received a copy of the GNU General Public License version
15  * 2 along with this work; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17  *
18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19  * or visit www.oracle.com if you need additional information or have any
20  * questions.

31   assert(!rs.special(), "ReservedSpace passed to PSFileBackedVirtualSpace cannot be special");                             
32 }                                                                                                                          
33 
34 bool PSFileBackedVirtualSpace::initialize() {                                                                              
35   _fd = os::create_file_for_heap(_file_path);                                                                              
36   if (_fd == -1) {                                                                                                         
37     return false;                                                                                                          
38   }                                                                                                                        
39   // We map the reserved space to a file at initialization.                                                                
40   char* ret = os::replace_existing_mapping_with_file_mapping(reserved_low_addr(), reserved_size(), _fd);                   
41   if (ret != reserved_low_addr()) {                                                                                        
42     os::close(_fd);                                                                                                        
43     return false;                                                                                                          
44   }                                                                                                                        
45   // _mapping_succeeded is false if we return before this point.                                                           
46   // expand calls later check value of this flag and return error if it is false.                                          
47   _mapping_succeeded = true;                                                                                               
48   _special = true;                                                                                                         
49   os::close(_fd);                                                                                                          
50   return true;                                                                                                             
51 }                                                                                                                          
52                                                                                                                            
53 PSFileBackedVirtualSpace::PSFileBackedVirtualSpace(ReservedSpace rs, const char* path) {                                   
54   PSFileBackedVirtualSpace(rs, os::vm_page_size(), path);                                                                  
55 }                                                                                                                          
56 
57 bool PSFileBackedVirtualSpace::expand_by(size_t bytes) {                                                                   
58   assert(special(), "Since entire space is committed at initialization, _special should always be true for PSFileBackedVirt
59 
60   // if mapping did not succeed during intialization return false                                                          
61   if (!_mapping_succeeded) {                                                                                               
62     return false;                                                                                                          
63   }                                                                                                                        
64   return PSVirtualSpace::expand_by(bytes);                                                                                 
65 
66 }                                                                                                                          
67 
68 bool PSFileBackedVirtualSpace::shrink_by(size_t bytes) {                                                                   
69   assert(special(), "Since entire space is committed at initialization, _special should always be true for PSFileBackedVirt
70   return PSVirtualSpace::shrink_by(bytes);                                                                                 
71 }                                                                                                                          
72 
73 size_t PSFileBackedVirtualSpace::expand_into(PSVirtualSpace* space, size_t bytes) {                                        

31   assert(!rs.special(), "ReservedSpace passed to PSFileBackedVirtualSpace cannot be special");
32 }
33 
34 bool PSFileBackedVirtualSpace::initialize() {
35   _fd = os::create_file_for_heap(_file_path);
36   if (_fd == -1) {
37     return false;
38   }
39   // We map the reserved space to a file at initialization.
40   char* ret = os::replace_existing_mapping_with_file_mapping(reserved_low_addr(), reserved_size(), _fd);
41   if (ret != reserved_low_addr()) {
42     os::close(_fd);
43     return false;
44   }
45   // _mapping_succeeded is false if we return before this point.
46   // expand calls later check value of this flag and return error if it is false.
47   _mapping_succeeded = true;
48   _special = true;
49   os::close(_fd);
50   return true;




51 }
52 
53 bool PSFileBackedVirtualSpace::expand_by(size_t bytes) {
54   assert(special(), "Since entire space is committed at initialization, _special should always be true for PSFileBackedVirt
55 
56   // if mapping did not succeed during intialization return false
57   if (!_mapping_succeeded) {
58     return false;
59   }
60   return PSVirtualSpace::expand_by(bytes);
61 
62 }
63 
64 bool PSFileBackedVirtualSpace::shrink_by(size_t bytes) {
65   assert(special(), "Since entire space is committed at initialization, _special should always be true for PSFileBackedVirt
66   return PSVirtualSpace::shrink_by(bytes);
67 }
68 
69 size_t PSFileBackedVirtualSpace::expand_into(PSVirtualSpace* space, size_t bytes) {
< prev index next >