2485
2486 // Complex case: two spaces adjacent to each other, both to be addressable
2487 // with narrow class pointers.
2488 // We reserve the whole range spanning both spaces, then split that range up.
2489
2490 const size_t class_space_alignment = Metaspace::reserve_alignment();
2491
2492 // To simplify matters, lets assume that metaspace alignment will always be
2493 // equal or a multiple of archive alignment.
2494 assert(is_power_of_2(class_space_alignment) &&
2495 is_power_of_2(archive_space_alignment) &&
2496 class_space_alignment >= archive_space_alignment,
2497 "Sanity");
2498
2499 const size_t class_space_size = CompressedClassSpaceSize;
2500 assert(CompressedClassSpaceSize > 0 &&
2501 is_aligned(CompressedClassSpaceSize, class_space_alignment),
2502 "CompressedClassSpaceSize malformed: "
2503 SIZE_FORMAT, CompressedClassSpaceSize);
2504
2505 const size_t ccs_begin_offset = align_up(archive_space_size,
2506 class_space_alignment);
2507 const size_t gap_size = ccs_begin_offset - archive_space_size;
2508
2509 const size_t total_range_size =
2510 align_up(archive_space_size + gap_size + class_space_size,
2511 os::vm_allocation_granularity());
2512
2513 ReservedSpace total_rs;
2514 if (base_address != NULL) {
2515 // Reserve at the given archive base address, or not at all.
2516 total_rs = ReservedSpace(total_range_size, archive_space_alignment,
2517 false /* bool large */, (char*) base_address);
2518 } else {
2519 // Reserve at any address, but leave it up to the platform to choose a good one.
2520 total_rs = Metaspace::reserve_address_space_for_compressed_classes(total_range_size);
2521 }
2522
2523 if (!total_rs.is_reserved()) {
2524 return NULL;
2525 }
2526
|
2485
2486 // Complex case: two spaces adjacent to each other, both to be addressable
2487 // with narrow class pointers.
2488 // We reserve the whole range spanning both spaces, then split that range up.
2489
2490 const size_t class_space_alignment = Metaspace::reserve_alignment();
2491
2492 // To simplify matters, lets assume that metaspace alignment will always be
2493 // equal or a multiple of archive alignment.
2494 assert(is_power_of_2(class_space_alignment) &&
2495 is_power_of_2(archive_space_alignment) &&
2496 class_space_alignment >= archive_space_alignment,
2497 "Sanity");
2498
2499 const size_t class_space_size = CompressedClassSpaceSize;
2500 assert(CompressedClassSpaceSize > 0 &&
2501 is_aligned(CompressedClassSpaceSize, class_space_alignment),
2502 "CompressedClassSpaceSize malformed: "
2503 SIZE_FORMAT, CompressedClassSpaceSize);
2504
2505 const size_t ccs_begin_offset = align_up(base_address + archive_space_size,
2506 class_space_alignment) - base_address;
2507 const size_t gap_size = ccs_begin_offset - archive_space_size;
2508
2509 const size_t total_range_size =
2510 align_up(archive_space_size + gap_size + class_space_size,
2511 os::vm_allocation_granularity());
2512
2513 ReservedSpace total_rs;
2514 if (base_address != NULL) {
2515 // Reserve at the given archive base address, or not at all.
2516 total_rs = ReservedSpace(total_range_size, archive_space_alignment,
2517 false /* bool large */, (char*) base_address);
2518 } else {
2519 // Reserve at any address, but leave it up to the platform to choose a good one.
2520 total_rs = Metaspace::reserve_address_space_for_compressed_classes(total_range_size);
2521 }
2522
2523 if (!total_rs.is_reserved()) {
2524 return NULL;
2525 }
2526
|