Mercurial > hg > truffle
comparison src/share/vm/memory/filemap.cpp @ 7460:6c3f47d964f3
8003705: CDS failed on Windows: can not map in the CDS.
Summary: Map memory only once to prevent 'already mapped' failures.
Reviewed-by: acorn, zgu
author | hseigel |
---|---|
date | Mon, 07 Jan 2013 15:32:51 -0500 |
parents | fe81517cfb77 |
children | 561148896559 |
comparison
equal
deleted
inserted
replaced
7459:cc6a617fffd2 | 7460:6c3f47d964f3 |
---|---|
209 tty->print_cr(" %s", _full_path); | 209 tty->print_cr(" %s", _full_path); |
210 } | 210 } |
211 | 211 |
212 // Remove the existing file in case another process has it open. | 212 // Remove the existing file in case another process has it open. |
213 remove(_full_path); | 213 remove(_full_path); |
214 #ifdef _WINDOWS // if 0444 is used on Windows, then remove() will fail. | |
215 int fd = open(_full_path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0744); | |
216 #else | |
214 int fd = open(_full_path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0444); | 217 int fd = open(_full_path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0444); |
218 #endif | |
215 if (fd < 0) { | 219 if (fd < 0) { |
216 fail_stop("Unable to create shared archive file %s.", _full_path); | 220 fail_stop("Unable to create shared archive file %s.", _full_path); |
217 } | 221 } |
218 _fd = fd; | 222 _fd = fd; |
219 _file_offset = 0; | 223 _file_offset = 0; |
368 if (!rs.is_reserved()) { | 372 if (!rs.is_reserved()) { |
369 fail_continue(err_msg("Unable to reserved shared space at required address " INTPTR_FORMAT, requested_addr)); | 373 fail_continue(err_msg("Unable to reserved shared space at required address " INTPTR_FORMAT, requested_addr)); |
370 return rs; | 374 return rs; |
371 } | 375 } |
372 // the reserved virtual memory is for mapping class data sharing archive | 376 // the reserved virtual memory is for mapping class data sharing archive |
373 if (MemTracker::is_on()) { | 377 MemTracker::record_virtual_memory_type((address)rs.base(), mtClassShared); |
374 MemTracker::record_virtual_memory_type((address)rs.base(), mtClassShared); | 378 |
375 } | |
376 return rs; | 379 return rs; |
377 } | 380 } |
378 | 381 |
379 // Memory map a region in the address space. | 382 // Memory map a region in the address space. |
380 static const char* shared_region_name[] = { "ReadOnly", "ReadWrite", "MiscData", "MiscCode"}; | 383 static const char* shared_region_name[] = { "ReadOnly", "ReadWrite", "MiscData", "MiscCode"}; |
392 si->_allow_exec); | 395 si->_allow_exec); |
393 if (base == NULL || base != si->_base) { | 396 if (base == NULL || base != si->_base) { |
394 fail_continue(err_msg("Unable to map %s shared space at required address.", shared_region_name[i])); | 397 fail_continue(err_msg("Unable to map %s shared space at required address.", shared_region_name[i])); |
395 return NULL; | 398 return NULL; |
396 } | 399 } |
400 #ifdef _WINDOWS | |
401 // This call is Windows-only because the memory_type gets recorded for the other platforms | |
402 // in method FileMapInfo::reserve_shared_memory(), which is not called on Windows. | |
403 MemTracker::record_virtual_memory_type((address)base, mtClassShared); | |
404 #endif | |
397 return base; | 405 return base; |
398 } | 406 } |
399 | 407 |
400 | 408 |
401 // Unmap a memory region in the address space. | 409 // Unmap a memory region in the address space. |