Merge

Fri, 20 Jan 2017 16:22:39 +0000

author
robm
date
Fri, 20 Jan 2017 16:22:39 +0000
changeset 8715
567e410935e5
parent 8711
e6d246d3fdfc
parent 8714
96a7391e620a
child 8716
619700f41f8e

Merge

     1.1 --- a/src/share/vm/code/nmethod.cpp	Tue Jan 17 09:21:05 2017 -0800
     1.2 +++ b/src/share/vm/code/nmethod.cpp	Fri Jan 20 16:22:39 2017 +0000
     1.3 @@ -1151,6 +1151,7 @@
     1.4  // Clear ICStubs of all compiled ICs
     1.5  void nmethod::clear_ic_stubs() {
     1.6    assert_locked_or_safepoint(CompiledIC_lock);
     1.7 +  ResourceMark rm;
     1.8    RelocIterator iter(this);
     1.9    while(iter.next()) {
    1.10      if (iter.type() == relocInfo::virtual_call_type) {
     2.1 --- a/src/share/vm/prims/jvmtiEnv.cpp	Tue Jan 17 09:21:05 2017 -0800
     2.2 +++ b/src/share/vm/prims/jvmtiEnv.cpp	Fri Jan 20 16:22:39 2017 +0000
     2.3 @@ -1,5 +1,5 @@
     2.4  /*
     2.5 - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
     2.6 + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
     2.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.8   *
     2.9   * This code is free software; you can redistribute it and/or modify it
    2.10 @@ -1000,8 +1000,9 @@
    2.11    GrowableArray<jvmtiMonitorStackDepthInfo*> *owned_monitors_list =
    2.12        new (ResourceObj::C_HEAP, mtInternal) GrowableArray<jvmtiMonitorStackDepthInfo*>(1, true);
    2.13  
    2.14 -  uint32_t debug_bits = 0;
    2.15 -  if (is_thread_fully_suspended(java_thread, true, &debug_bits)) {
    2.16 +  // It is only safe to perform the direct operation on the current
    2.17 +  // thread. All other usage needs to use a vm-safepoint-op for safety.
    2.18 +  if (java_thread == calling_thread) {
    2.19      err = get_owned_monitors(calling_thread, java_thread, owned_monitors_list);
    2.20    } else {
    2.21      // JVMTI get monitors info at safepoint. Do not require target thread to
    2.22 @@ -1045,8 +1046,9 @@
    2.23    GrowableArray<jvmtiMonitorStackDepthInfo*> *owned_monitors_list =
    2.24           new (ResourceObj::C_HEAP, mtInternal) GrowableArray<jvmtiMonitorStackDepthInfo*>(1, true);
    2.25  
    2.26 -  uint32_t debug_bits = 0;
    2.27 -  if (is_thread_fully_suspended(java_thread, true, &debug_bits)) {
    2.28 +  // It is only safe to perform the direct operation on the current
    2.29 +  // thread. All other usage needs to use a vm-safepoint-op for safety.
    2.30 +  if (java_thread == calling_thread) {
    2.31      err = get_owned_monitors(calling_thread, java_thread, owned_monitors_list);
    2.32    } else {
    2.33      // JVMTI get owned monitors info at safepoint. Do not require target thread to
    2.34 @@ -1087,9 +1089,11 @@
    2.35  jvmtiError
    2.36  JvmtiEnv::GetCurrentContendedMonitor(JavaThread* java_thread, jobject* monitor_ptr) {
    2.37    jvmtiError err = JVMTI_ERROR_NONE;
    2.38 -  uint32_t debug_bits = 0;
    2.39    JavaThread* calling_thread  = JavaThread::current();
    2.40 -  if (is_thread_fully_suspended(java_thread, true, &debug_bits)) {
    2.41 +
    2.42 +  // It is only safe to perform the direct operation on the current
    2.43 +  // thread. All other usage needs to use a vm-safepoint-op for safety.
    2.44 +  if (java_thread == calling_thread) {
    2.45      err = get_current_contended_monitor(calling_thread, java_thread, monitor_ptr);
    2.46    } else {
    2.47      // get contended monitor information at safepoint.
    2.48 @@ -1298,8 +1302,10 @@
    2.49  jvmtiError
    2.50  JvmtiEnv::GetStackTrace(JavaThread* java_thread, jint start_depth, jint max_frame_count, jvmtiFrameInfo* frame_buffer, jint* count_ptr) {
    2.51    jvmtiError err = JVMTI_ERROR_NONE;
    2.52 -  uint32_t debug_bits = 0;
    2.53 -  if (is_thread_fully_suspended(java_thread, true, &debug_bits)) {
    2.54 +
    2.55 +  // It is only safe to perform the direct operation on the current
    2.56 +  // thread. All other usage needs to use a vm-safepoint-op for safety.
    2.57 +  if (java_thread == JavaThread::current()) {
    2.58      err = get_stack_trace(java_thread, start_depth, max_frame_count, frame_buffer, count_ptr);
    2.59    } else {
    2.60      // JVMTI get stack trace at safepoint. Do not require target thread to
     3.1 --- a/src/share/vm/prims/jvmtiEnvBase.hpp	Tue Jan 17 09:21:05 2017 -0800
     3.2 +++ b/src/share/vm/prims/jvmtiEnvBase.hpp	Fri Jan 20 16:22:39 2017 +0000
     3.3 @@ -1,5 +1,5 @@
     3.4  /*
     3.5 - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
     3.6 + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
     3.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.8   *
     3.9   * This code is free software; you can redistribute it and/or modify it
    3.10 @@ -356,8 +356,12 @@
    3.11    }
    3.12    VMOp_Type type() const { return VMOp_GetOwnedMonitorInfo; }
    3.13    void doit() {
    3.14 -    ((JvmtiEnvBase *)_env)->get_owned_monitors(_calling_thread, _java_thread,
    3.15 -                                                         _owned_monitors_list);
    3.16 +    _result = JVMTI_ERROR_THREAD_NOT_ALIVE;
    3.17 +    if (Threads::includes(_java_thread) && !_java_thread->is_exiting()
    3.18 +                                        && _java_thread->threadObj() != NULL) {
    3.19 +      _result = ((JvmtiEnvBase *)_env)->get_owned_monitors(_calling_thread, _java_thread,
    3.20 +                                                            _owned_monitors_list);
    3.21 +    }
    3.22    }
    3.23    jvmtiError result() { return _result; }
    3.24  };
    3.25 @@ -439,9 +443,13 @@
    3.26    jvmtiError result() { return _result; }
    3.27    VMOp_Type type() const { return VMOp_GetStackTrace; }
    3.28    void doit() {
    3.29 -    _result = ((JvmtiEnvBase *)_env)->get_stack_trace(_java_thread,
    3.30 -                                                      _start_depth, _max_count,
    3.31 -                                                      _frame_buffer, _count_ptr);
    3.32 +    _result = JVMTI_ERROR_THREAD_NOT_ALIVE;
    3.33 +    if (Threads::includes(_java_thread) && !_java_thread->is_exiting()
    3.34 +                                        && _java_thread->threadObj() != NULL) {
    3.35 +      _result = ((JvmtiEnvBase *)_env)->get_stack_trace(_java_thread,
    3.36 +                                                        _start_depth, _max_count,
    3.37 +                                                        _frame_buffer, _count_ptr);
    3.38 +    }
    3.39    }
    3.40  };
    3.41  
     4.1 --- a/src/share/vm/runtime/arguments.cpp	Tue Jan 17 09:21:05 2017 -0800
     4.2 +++ b/src/share/vm/runtime/arguments.cpp	Fri Jan 20 16:22:39 2017 +0000
     4.3 @@ -1,5 +1,5 @@
     4.4  /*
     4.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
     4.6 + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     4.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.8   *
     4.9   * This code is free software; you can redistribute it and/or modify it
    4.10 @@ -1768,10 +1768,39 @@
    4.11      FLAG_SET_CMDLINE(uintx, MaxRAMFraction, DefaultMaxRAMFraction);
    4.12    }
    4.13  
    4.14 -  const julong phys_mem =
    4.15 +  julong phys_mem =
    4.16      FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
    4.17                              : (julong)MaxRAM;
    4.18  
    4.19 +  // Experimental support for CGroup memory limits
    4.20 +  if (UseCGroupMemoryLimitForHeap) {
    4.21 +    // This is a rough indicator that a CGroup limit may be in force
    4.22 +    // for this process
    4.23 +    const char* lim_file = "/sys/fs/cgroup/memory/memory.limit_in_bytes";
    4.24 +    FILE *fp = fopen(lim_file, "r");
    4.25 +    if (fp != NULL) {
    4.26 +      julong cgroup_max = 0;
    4.27 +      int ret = fscanf(fp, JULONG_FORMAT, &cgroup_max);
    4.28 +      if (ret == 1 && cgroup_max > 0) {
    4.29 +        // If unlimited, cgroup_max will be a very large, but unspecified
    4.30 +        // value, so use initial phys_mem as a limit
    4.31 +        if (PrintGCDetails && Verbose) {
    4.32 +          // Cannot use gclog_or_tty yet.
    4.33 +          tty->print_cr("Setting phys_mem to the min of cgroup limit ("
    4.34 +                        JULONG_FORMAT "MB) and initial phys_mem ("
    4.35 +                        JULONG_FORMAT "MB)", cgroup_max/M, phys_mem/M);
    4.36 +        }
    4.37 +        phys_mem = MIN2(cgroup_max, phys_mem);
    4.38 +      } else {
    4.39 +        warning("Unable to read/parse cgroup memory limit from %s: %s",
    4.40 +                lim_file, errno != 0 ? strerror(errno) : "unknown error");
    4.41 +      }
    4.42 +      fclose(fp);
    4.43 +    } else {
    4.44 +      warning("Unable to open cgroup memory limit file %s (%s)", lim_file, strerror(errno));
    4.45 +    }
    4.46 +  }
    4.47 +
    4.48    // If the maximum heap size has not been set with -Xmx,
    4.49    // then set it as fraction of the size of physical memory,
    4.50    // respecting the maximum and minimum sizes of the heap.
     5.1 --- a/src/share/vm/runtime/globals.hpp	Tue Jan 17 09:21:05 2017 -0800
     5.2 +++ b/src/share/vm/runtime/globals.hpp	Fri Jan 20 16:22:39 2017 +0000
     5.3 @@ -1,5 +1,5 @@
     5.4  /*
     5.5 - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
     5.6 + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     5.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.8   *
     5.9   * This code is free software; you can redistribute it and/or modify it
    5.10 @@ -2068,6 +2068,10 @@
    5.11            "Maximum ergonomically set heap size (in bytes); zero means use " \
    5.12            "MaxRAM / MaxRAMFraction")                                        \
    5.13                                                                              \
    5.14 +  experimental(bool, UseCGroupMemoryLimitForHeap, false,                    \
    5.15 +          "Use CGroup memory limit as physical memory limit for heap "      \
    5.16 +          "sizing")                                                         \
    5.17 +                                                                            \
    5.18    product(uintx, MaxRAMFraction, 4,                                         \
    5.19            "Maximum fraction (1/n) of real memory used for maximum heap "    \
    5.20            "size")                                                           \
     6.1 --- a/src/share/vm/runtime/sweeper.cpp	Tue Jan 17 09:21:05 2017 -0800
     6.2 +++ b/src/share/vm/runtime/sweeper.cpp	Fri Jan 20 16:22:39 2017 +0000
     6.3 @@ -319,6 +319,7 @@
     6.4  }
     6.5  
     6.6  void NMethodSweeper::sweep_code_cache() {
     6.7 +  ResourceMark rm;
     6.8    Ticks sweep_start_counter = Ticks::now();
     6.9  
    6.10    _flushed_count                = 0;
    6.11 @@ -626,6 +627,7 @@
    6.12  // state of the code cache if it's requested.
    6.13  void NMethodSweeper::log_sweep(const char* msg, const char* format, ...) {
    6.14    if (PrintMethodFlushing) {
    6.15 +    ResourceMark rm;
    6.16      stringStream s;
    6.17      // Dump code cache state into a buffer before locking the tty,
    6.18      // because log_state() will use locks causing lock conflicts.
    6.19 @@ -643,6 +645,7 @@
    6.20    }
    6.21  
    6.22    if (LogCompilation && (xtty != NULL)) {
    6.23 +    ResourceMark rm;
    6.24      stringStream s;
    6.25      // Dump code cache state into a buffer before locking the tty,
    6.26      // because log_state() will use locks causing lock conflicts.

mercurial