提交 6caaeb4b 编写于 作者: R robm

Merge

...@@ -1151,6 +1151,7 @@ void nmethod::clear_inline_caches() { ...@@ -1151,6 +1151,7 @@ void nmethod::clear_inline_caches() {
// Clear ICStubs of all compiled ICs // Clear ICStubs of all compiled ICs
void nmethod::clear_ic_stubs() { void nmethod::clear_ic_stubs() {
assert_locked_or_safepoint(CompiledIC_lock); assert_locked_or_safepoint(CompiledIC_lock);
ResourceMark rm;
RelocIterator iter(this); RelocIterator iter(this);
while(iter.next()) { while(iter.next()) {
if (iter.type() == relocInfo::virtual_call_type) { if (iter.type() == relocInfo::virtual_call_type) {
......
/* /*
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -1000,8 +1000,9 @@ JvmtiEnv::GetOwnedMonitorInfo(JavaThread* java_thread, jint* owned_monitor_count ...@@ -1000,8 +1000,9 @@ JvmtiEnv::GetOwnedMonitorInfo(JavaThread* java_thread, jint* owned_monitor_count
GrowableArray<jvmtiMonitorStackDepthInfo*> *owned_monitors_list = GrowableArray<jvmtiMonitorStackDepthInfo*> *owned_monitors_list =
new (ResourceObj::C_HEAP, mtInternal) GrowableArray<jvmtiMonitorStackDepthInfo*>(1, true); new (ResourceObj::C_HEAP, mtInternal) GrowableArray<jvmtiMonitorStackDepthInfo*>(1, true);
uint32_t debug_bits = 0; // It is only safe to perform the direct operation on the current
if (is_thread_fully_suspended(java_thread, true, &debug_bits)) { // thread. All other usage needs to use a vm-safepoint-op for safety.
if (java_thread == calling_thread) {
err = get_owned_monitors(calling_thread, java_thread, owned_monitors_list); err = get_owned_monitors(calling_thread, java_thread, owned_monitors_list);
} else { } else {
// JVMTI get monitors info at safepoint. Do not require target thread to // JVMTI get monitors info at safepoint. Do not require target thread to
...@@ -1045,8 +1046,9 @@ JvmtiEnv::GetOwnedMonitorStackDepthInfo(JavaThread* java_thread, jint* monitor_i ...@@ -1045,8 +1046,9 @@ JvmtiEnv::GetOwnedMonitorStackDepthInfo(JavaThread* java_thread, jint* monitor_i
GrowableArray<jvmtiMonitorStackDepthInfo*> *owned_monitors_list = GrowableArray<jvmtiMonitorStackDepthInfo*> *owned_monitors_list =
new (ResourceObj::C_HEAP, mtInternal) GrowableArray<jvmtiMonitorStackDepthInfo*>(1, true); new (ResourceObj::C_HEAP, mtInternal) GrowableArray<jvmtiMonitorStackDepthInfo*>(1, true);
uint32_t debug_bits = 0; // It is only safe to perform the direct operation on the current
if (is_thread_fully_suspended(java_thread, true, &debug_bits)) { // thread. All other usage needs to use a vm-safepoint-op for safety.
if (java_thread == calling_thread) {
err = get_owned_monitors(calling_thread, java_thread, owned_monitors_list); err = get_owned_monitors(calling_thread, java_thread, owned_monitors_list);
} else { } else {
// JVMTI get owned monitors info at safepoint. Do not require target thread to // JVMTI get owned monitors info at safepoint. Do not require target thread to
...@@ -1087,9 +1089,11 @@ JvmtiEnv::GetOwnedMonitorStackDepthInfo(JavaThread* java_thread, jint* monitor_i ...@@ -1087,9 +1089,11 @@ JvmtiEnv::GetOwnedMonitorStackDepthInfo(JavaThread* java_thread, jint* monitor_i
jvmtiError jvmtiError
JvmtiEnv::GetCurrentContendedMonitor(JavaThread* java_thread, jobject* monitor_ptr) { JvmtiEnv::GetCurrentContendedMonitor(JavaThread* java_thread, jobject* monitor_ptr) {
jvmtiError err = JVMTI_ERROR_NONE; jvmtiError err = JVMTI_ERROR_NONE;
uint32_t debug_bits = 0;
JavaThread* calling_thread = JavaThread::current(); JavaThread* calling_thread = JavaThread::current();
if (is_thread_fully_suspended(java_thread, true, &debug_bits)) {
// It is only safe to perform the direct operation on the current
// thread. All other usage needs to use a vm-safepoint-op for safety.
if (java_thread == calling_thread) {
err = get_current_contended_monitor(calling_thread, java_thread, monitor_ptr); err = get_current_contended_monitor(calling_thread, java_thread, monitor_ptr);
} else { } else {
// get contended monitor information at safepoint. // get contended monitor information at safepoint.
...@@ -1298,8 +1302,10 @@ JvmtiEnv::GetThreadGroupChildren(jthreadGroup group, jint* thread_count_ptr, jth ...@@ -1298,8 +1302,10 @@ JvmtiEnv::GetThreadGroupChildren(jthreadGroup group, jint* thread_count_ptr, jth
jvmtiError jvmtiError
JvmtiEnv::GetStackTrace(JavaThread* java_thread, jint start_depth, jint max_frame_count, jvmtiFrameInfo* frame_buffer, jint* count_ptr) { JvmtiEnv::GetStackTrace(JavaThread* java_thread, jint start_depth, jint max_frame_count, jvmtiFrameInfo* frame_buffer, jint* count_ptr) {
jvmtiError err = JVMTI_ERROR_NONE; jvmtiError err = JVMTI_ERROR_NONE;
uint32_t debug_bits = 0;
if (is_thread_fully_suspended(java_thread, true, &debug_bits)) { // It is only safe to perform the direct operation on the current
// thread. All other usage needs to use a vm-safepoint-op for safety.
if (java_thread == JavaThread::current()) {
err = get_stack_trace(java_thread, start_depth, max_frame_count, frame_buffer, count_ptr); err = get_stack_trace(java_thread, start_depth, max_frame_count, frame_buffer, count_ptr);
} else { } else {
// JVMTI get stack trace at safepoint. Do not require target thread to // JVMTI get stack trace at safepoint. Do not require target thread to
......
/* /*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -356,8 +356,12 @@ public: ...@@ -356,8 +356,12 @@ public:
} }
VMOp_Type type() const { return VMOp_GetOwnedMonitorInfo; } VMOp_Type type() const { return VMOp_GetOwnedMonitorInfo; }
void doit() { void doit() {
((JvmtiEnvBase *)_env)->get_owned_monitors(_calling_thread, _java_thread, _result = JVMTI_ERROR_THREAD_NOT_ALIVE;
_owned_monitors_list); if (Threads::includes(_java_thread) && !_java_thread->is_exiting()
&& _java_thread->threadObj() != NULL) {
_result = ((JvmtiEnvBase *)_env)->get_owned_monitors(_calling_thread, _java_thread,
_owned_monitors_list);
}
} }
jvmtiError result() { return _result; } jvmtiError result() { return _result; }
}; };
...@@ -439,9 +443,13 @@ public: ...@@ -439,9 +443,13 @@ public:
jvmtiError result() { return _result; } jvmtiError result() { return _result; }
VMOp_Type type() const { return VMOp_GetStackTrace; } VMOp_Type type() const { return VMOp_GetStackTrace; }
void doit() { void doit() {
_result = ((JvmtiEnvBase *)_env)->get_stack_trace(_java_thread, _result = JVMTI_ERROR_THREAD_NOT_ALIVE;
_start_depth, _max_count, if (Threads::includes(_java_thread) && !_java_thread->is_exiting()
_frame_buffer, _count_ptr); && _java_thread->threadObj() != NULL) {
_result = ((JvmtiEnvBase *)_env)->get_stack_trace(_java_thread,
_start_depth, _max_count,
_frame_buffer, _count_ptr);
}
} }
}; };
......
/* /*
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -1768,10 +1768,39 @@ void Arguments::set_heap_size() { ...@@ -1768,10 +1768,39 @@ void Arguments::set_heap_size() {
FLAG_SET_CMDLINE(uintx, MaxRAMFraction, DefaultMaxRAMFraction); FLAG_SET_CMDLINE(uintx, MaxRAMFraction, DefaultMaxRAMFraction);
} }
const julong phys_mem = julong phys_mem =
FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM) FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
: (julong)MaxRAM; : (julong)MaxRAM;
// Experimental support for CGroup memory limits
if (UseCGroupMemoryLimitForHeap) {
// This is a rough indicator that a CGroup limit may be in force
// for this process
const char* lim_file = "/sys/fs/cgroup/memory/memory.limit_in_bytes";
FILE *fp = fopen(lim_file, "r");
if (fp != NULL) {
julong cgroup_max = 0;
int ret = fscanf(fp, JULONG_FORMAT, &cgroup_max);
if (ret == 1 && cgroup_max > 0) {
// If unlimited, cgroup_max will be a very large, but unspecified
// value, so use initial phys_mem as a limit
if (PrintGCDetails && Verbose) {
// Cannot use gclog_or_tty yet.
tty->print_cr("Setting phys_mem to the min of cgroup limit ("
JULONG_FORMAT "MB) and initial phys_mem ("
JULONG_FORMAT "MB)", cgroup_max/M, phys_mem/M);
}
phys_mem = MIN2(cgroup_max, phys_mem);
} else {
warning("Unable to read/parse cgroup memory limit from %s: %s",
lim_file, errno != 0 ? strerror(errno) : "unknown error");
}
fclose(fp);
} else {
warning("Unable to open cgroup memory limit file %s (%s)", lim_file, strerror(errno));
}
}
// If the maximum heap size has not been set with -Xmx, // If the maximum heap size has not been set with -Xmx,
// then set it as fraction of the size of physical memory, // then set it as fraction of the size of physical memory,
// respecting the maximum and minimum sizes of the heap. // respecting the maximum and minimum sizes of the heap.
......
/* /*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -2068,6 +2068,10 @@ class CommandLineFlags { ...@@ -2068,6 +2068,10 @@ class CommandLineFlags {
"Maximum ergonomically set heap size (in bytes); zero means use " \ "Maximum ergonomically set heap size (in bytes); zero means use " \
"MaxRAM / MaxRAMFraction") \ "MaxRAM / MaxRAMFraction") \
\ \
experimental(bool, UseCGroupMemoryLimitForHeap, false, \
"Use CGroup memory limit as physical memory limit for heap " \
"sizing") \
\
product(uintx, MaxRAMFraction, 4, \ product(uintx, MaxRAMFraction, 4, \
"Maximum fraction (1/n) of real memory used for maximum heap " \ "Maximum fraction (1/n) of real memory used for maximum heap " \
"size") \ "size") \
......
...@@ -319,6 +319,7 @@ void NMethodSweeper::possibly_sweep() { ...@@ -319,6 +319,7 @@ void NMethodSweeper::possibly_sweep() {
} }
void NMethodSweeper::sweep_code_cache() { void NMethodSweeper::sweep_code_cache() {
ResourceMark rm;
Ticks sweep_start_counter = Ticks::now(); Ticks sweep_start_counter = Ticks::now();
_flushed_count = 0; _flushed_count = 0;
...@@ -626,6 +627,7 @@ int NMethodSweeper::process_nmethod(nmethod *nm) { ...@@ -626,6 +627,7 @@ int NMethodSweeper::process_nmethod(nmethod *nm) {
// state of the code cache if it's requested. // state of the code cache if it's requested.
void NMethodSweeper::log_sweep(const char* msg, const char* format, ...) { void NMethodSweeper::log_sweep(const char* msg, const char* format, ...) {
if (PrintMethodFlushing) { if (PrintMethodFlushing) {
ResourceMark rm;
stringStream s; stringStream s;
// Dump code cache state into a buffer before locking the tty, // Dump code cache state into a buffer before locking the tty,
// because log_state() will use locks causing lock conflicts. // because log_state() will use locks causing lock conflicts.
...@@ -643,6 +645,7 @@ void NMethodSweeper::log_sweep(const char* msg, const char* format, ...) { ...@@ -643,6 +645,7 @@ void NMethodSweeper::log_sweep(const char* msg, const char* format, ...) {
} }
if (LogCompilation && (xtty != NULL)) { if (LogCompilation && (xtty != NULL)) {
ResourceMark rm;
stringStream s; stringStream s;
// Dump code cache state into a buffer before locking the tty, // Dump code cache state into a buffer before locking the tty,
// because log_state() will use locks causing lock conflicts. // because log_state() will use locks causing lock conflicts.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册