Print this page


Split Split Close
Expand all
Collapse all
          --- old/src/share/vm/memory/universe.cpp
          +++ new/src/share/vm/memory/universe.cpp
   1    1  /*
   2      - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
        2 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
   3    3   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4    4   *
   5    5   * This code is free software; you can redistribute it and/or modify it
   6    6   * under the terms of the GNU General Public License version 2 only, as
   7    7   * published by the Free Software Foundation.
   8    8   *
   9    9   * This code is distributed in the hope that it will be useful, but WITHOUT
  10   10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11   11   * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12   12   * version 2 for more details (a copy is included in the LICENSE file that
↓ open down ↓ 104 lines elided ↑ open up ↑
 117  117  LatestMethodCache* Universe::_throw_illegal_access_error_cache = NULL;
 118  118  oop Universe::_out_of_memory_error_java_heap          = NULL;
 119  119  oop Universe::_out_of_memory_error_metaspace          = NULL;
 120  120  oop Universe::_out_of_memory_error_class_metaspace    = NULL;
 121  121  oop Universe::_out_of_memory_error_array_size         = NULL;
 122  122  oop Universe::_out_of_memory_error_gc_overhead_limit  = NULL;
 123  123  oop Universe::_out_of_memory_error_realloc_objects    = NULL;
 124  124  objArrayOop Universe::_preallocated_out_of_memory_error_array = NULL;
 125  125  volatile jint Universe::_preallocated_out_of_memory_error_avail_count = 0;
 126  126  bool Universe::_verify_in_progress                    = false;
      127 +long Universe::verify_flags                           = Universe::Verify_All;
 127  128  oop Universe::_null_ptr_exception_instance            = NULL;
 128  129  oop Universe::_arithmetic_exception_instance          = NULL;
 129  130  oop Universe::_virtual_machine_error_instance         = NULL;
 130  131  oop Universe::_vm_exception                           = NULL;
 131  132  oop Universe::_allocation_context_notification_obj    = NULL;
 132  133  
 133  134  Array<int>* Universe::_the_empty_int_array            = NULL;
 134  135  Array<u2>* Universe::_the_empty_short_array           = NULL;
 135  136  Array<Klass*>* Universe::_the_empty_klass_array     = NULL;
 136  137  Array<Method*>* Universe::_the_empty_method_array   = NULL;
↓ open down ↓ 539 lines elided ↑ open up ↑
 676  677      StringTable::create_table();
 677  678    } else {
 678  679      SymbolTable::create_table();
 679  680      StringTable::create_table();
 680  681      ClassLoader::create_package_info_table();
 681  682  
 682  683      if (DumpSharedSpaces) {
 683  684        MetaspaceShared::prepare_for_dumping();
 684  685      }
 685  686    }
      687 +  if (strlen(VerifySubSet) > 0) {
      688 +    Universe::initialize_verify_flags();
      689 +  }
 686  690  
 687  691    return JNI_OK;
 688  692  }
 689  693  
 690  694  // Choose the heap base address and oop encoding mode
 691  695  // when compressed oops are used:
 692  696  // Unscaled  - Use 32-bits oops without encoding when
 693  697  //     NarrowOopHeapBaseMin + heap_size < 4Gb
 694  698  // ZeroBased - Use zero based compressed oops with encoding when
 695  699  //     NarrowOopHeapBaseMin + heap_size < 32Gb
↓ open down ↓ 658 lines elided ↑ open up ↑
1354 1358                 heap()->total_collections(),
1355 1359                 heap()->total_full_collections());
1356 1360    if (!PrintHeapAtGCExtended || ignore_extended) {
1357 1361      heap()->print_on(st);
1358 1362    } else {
1359 1363      heap()->print_extended_on(st);
1360 1364    }
1361 1365    st->print_cr("}");
1362 1366  }
1363 1367  
     1368 +void Universe::initialize_verify_flags() {
     1369 +  verify_flags = 0;
     1370 +  const char delimiter[] = " ,";
     1371 +
     1372 +  size_t length = strlen(VerifySubSet);
     1373 +  char* subset_list = NEW_C_HEAP_ARRAY(char, length + 1, mtInternal);
     1374 +  strncpy(subset_list, VerifySubSet, length + 1);
     1375 +
     1376 +  char* token = strtok(subset_list, delimiter);
     1377 +  while (token != NULL) {
     1378 +    if (strcmp(token, "threads") == 0) {
     1379 +      verify_flags |= Verify_Threads;
     1380 +    } else if (strcmp(token, "heap") == 0) {
     1381 +      verify_flags |= Verify_Heap;
     1382 +    } else if (strcmp(token, "symbol_table") == 0) {
     1383 +      verify_flags |= Verify_SymbolTable;
     1384 +    } else if (strcmp(token, "string_table") == 0) {
     1385 +      verify_flags |= Verify_StringTable;
     1386 +    } else if (strcmp(token, "codecache") == 0) {
     1387 +      verify_flags |= Verify_CodeCache;
     1388 +    } else if (strcmp(token, "dictionary") == 0) {
     1389 +      verify_flags |= Verify_SystemDictionary;
     1390 +    } else if (strcmp(token, "classloader_data_graph") == 0) {
     1391 +      verify_flags |= Verify_ClassLoaderDataGraph;
     1392 +    } else if (strcmp(token, "metaspace") == 0) {
     1393 +      verify_flags |= Verify_MetaspaceAux;
     1394 +    } else if (strcmp(token, "jni_handles") == 0) {
     1395 +      verify_flags |= Verify_JNIHandles;
     1396 +    } else if (strcmp(token, "c-heap") == 0) {
     1397 +      verify_flags |= Verify_CHeap;
     1398 +    } else if (strcmp(token, "codecache_oops") == 0) {
     1399 +      verify_flags |= Verify_CodeCacheOops;
     1400 +    } else {
     1401 +      vm_exit_during_initialization(err_msg("VerifySubSet: \'%s\' memory sub-system is unknown, please correct it", token));
     1402 +    }
     1403 +    token = strtok(NULL, delimiter);
     1404 +  }
     1405 +  FREE_C_HEAP_ARRAY(char, subset_list, mtInternal);
     1406 +}
     1407 +
     1408 +bool Universe::should_verify_subset(uint subset) {
     1409 +  if (verify_flags & subset) {
     1410 +    return true;
     1411 +  }
     1412 +  return false;
     1413 +}
     1414 +
1364 1415  void Universe::verify(VerifyOption option, const char* prefix, bool silent) {
1365 1416    // The use of _verify_in_progress is a temporary work around for
1366 1417    // 6320749.  Don't bother with a creating a class to set and clear
1367 1418    // it since it is only used in this method and the control flow is
1368 1419    // straight forward.
1369 1420    _verify_in_progress = true;
1370 1421  
1371 1422    COMPILER2_PRESENT(
1372 1423      assert(!DerivedPointerTable::is_active(),
1373 1424           "DPT should not be active during verification "
1374 1425           "(of thread stacks below)");
1375 1426    )
1376 1427  
1377 1428    ResourceMark rm;
1378 1429    HandleMark hm;  // Handles created during verification can be zapped
1379 1430    _verify_count++;
1380 1431  
1381 1432    if (!silent) gclog_or_tty->print("%s", prefix);
1382 1433    if (!silent) gclog_or_tty->print("[Verifying ");
1383      -  if (!silent) gclog_or_tty->print("threads ");
1384      -  Threads::verify();
1385      -  if (!silent) gclog_or_tty->print("heap ");
1386      -  heap()->verify(silent, option);
1387      -  if (!silent) gclog_or_tty->print("syms ");
1388      -  SymbolTable::verify();
1389      -  if (!silent) gclog_or_tty->print("strs ");
1390      -  StringTable::verify();
     1434 +  if (should_verify_subset(Verify_Threads)) {
     1435 +    if (!silent) gclog_or_tty->print("Threads ");
     1436 +    Threads::verify();
     1437 +  }
     1438 +  if (should_verify_subset(Verify_Heap)) {
     1439 +    if (!silent) gclog_or_tty->print("Heap ");
     1440 +    heap()->verify(silent, option);
     1441 +  }
     1442 +  if (should_verify_subset(Verify_SymbolTable)) {
     1443 +    if (!silent) gclog_or_tty->print("SymbolTable ");
     1444 +    SymbolTable::verify();
     1445 +  }
     1446 +  if (should_verify_subset(Verify_StringTable)) {
     1447 +    if (!silent) gclog_or_tty->print("StringTable ");
     1448 +    StringTable::verify();
     1449 +  }
     1450 +  if (should_verify_subset(Verify_CodeCache)) {
1391 1451    {
1392 1452      MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1393      -    if (!silent) gclog_or_tty->print("zone ");
     1453 +    if (!silent) gclog_or_tty->print("CodeCache ");
1394 1454      CodeCache::verify();
1395 1455    }
1396      -  if (!silent) gclog_or_tty->print("dict ");
1397      -  SystemDictionary::verify();
     1456 +  }
     1457 +  if (should_verify_subset(Verify_SystemDictionary)) {
     1458 +    if (!silent) gclog_or_tty->print("SystemDictionary ");
     1459 +    SystemDictionary::verify();
     1460 +  }
1398 1461  #ifndef PRODUCT
1399      -  if (!silent) gclog_or_tty->print("cldg ");
1400      -  ClassLoaderDataGraph::verify();
     1462 +  if (should_verify_subset(Verify_ClassLoaderDataGraph)) {
     1463 +    if (!silent) gclog_or_tty->print("ClassLoaderDataGraph ");
     1464 +    ClassLoaderDataGraph::verify();
     1465 +  }
1401 1466  #endif
1402      -  if (!silent) gclog_or_tty->print("metaspace chunks ");
1403      -  MetaspaceAux::verify_free_chunks();
1404      -  if (!silent) gclog_or_tty->print("hand ");
1405      -  JNIHandles::verify();
1406      -  if (!silent) gclog_or_tty->print("C-heap ");
1407      -  os::check_heap();
1408      -  if (!silent) gclog_or_tty->print("code cache ");
1409      -  CodeCache::verify_oops();
     1467 +  if (should_verify_subset(Verify_MetaspaceAux)) {
     1468 +    if (!silent) gclog_or_tty->print("MetaspaceAux ");
     1469 +    MetaspaceAux::verify_free_chunks();
     1470 +  }
     1471 +  if (should_verify_subset(Verify_JNIHandles)) {
     1472 +    if (!silent) gclog_or_tty->print("JNIHandles ");
     1473 +    JNIHandles::verify();
     1474 +  }
     1475 +  if (should_verify_subset(Verify_CHeap)) {
     1476 +    if (!silent) gclog_or_tty->print("C-heap ");
     1477 +    os::check_heap();
     1478 +  }
     1479 +  if (should_verify_subset(Verify_CodeCacheOops)) {
     1480 +    if (!silent) gclog_or_tty->print("CodeCache Oops ");
     1481 +    CodeCache::verify_oops();
     1482 +  }
1410 1483    if (!silent) gclog_or_tty->print_cr("]");
1411 1484  
1412 1485    _verify_in_progress = false;
1413 1486  }
1414 1487  
1415 1488  // Oop verification (see MacroAssembler::verify_oop)
1416 1489  
1417 1490  static uintptr_t _verify_oop_data[2]   = {0, (uintptr_t)-1};
1418 1491  static uintptr_t _verify_klass_data[2] = {0, (uintptr_t)-1};
1419 1492  
↓ open down ↓ 121 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX