提交 91b2821f 编写于 作者: D dcubed

Merge

...@@ -207,6 +207,9 @@ LINK_FLAGS = /manifest $(LINK_FLAGS) ...@@ -207,6 +207,9 @@ LINK_FLAGS = /manifest $(LINK_FLAGS)
# Manifest Tool - used in VS2005 and later to adjust manifests stored # Manifest Tool - used in VS2005 and later to adjust manifests stored
# as resources inside build artifacts. # as resources inside build artifacts.
MT=mt.exe MT=mt.exe
!if "$(BUILDARCH)" == "i486"
LINK_FLAGS = /SAFESEH $(LINK_FLAGS)
!endif
!endif !endif
# Compile for space above time. # Compile for space above time.
......
# #
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2010, 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
# under the terms of the GNU General Public License version 2 only, as # under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. # published by the Free Software Foundation.
# #
# This code is distributed in the hope that it will be useful, but WITHOUT # This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that # version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code). # accompanied this code).
# #
# You should have received a copy of the GNU General Public License version # You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation, # 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
# #
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any # or visit www.oracle.com if you need additional information or have any
# questions. # questions.
# #
# #
LAUNCHER_FLAGS=$(CPP_FLAGS) $(ARCHFLAG) \ LAUNCHER_FLAGS=$(CPP_FLAGS) $(ARCHFLAG) \
/D FULL_VERSION=\"$(HOTSPOT_RELEASE_VERSION)\" \ /D FULL_VERSION=\"$(HOTSPOT_RELEASE_VERSION)\" \
/D JDK_MAJOR_VERSION=\"$(JDK_MAJOR_VERSION)\" \ /D JDK_MAJOR_VERSION=\"$(JDK_MAJOR_VERSION)\" \
/D JDK_MINOR_VERSION=\"$(JDK_MINOR_VERSION)\" \ /D JDK_MINOR_VERSION=\"$(JDK_MINOR_VERSION)\" \
/D GAMMA \ /D GAMMA \
/D LAUNCHER_TYPE=\"gamma\" \ /D LAUNCHER_TYPE=\"gamma\" \
/D _CRT_SECURE_NO_WARNINGS \ /D _CRT_SECURE_NO_WARNINGS \
/D _CRT_SECURE_NO_DEPRECATE \ /D _CRT_SECURE_NO_DEPRECATE \
/D LINK_INTO_LIBJVM \ /D LINK_INTO_LIBJVM \
/I $(WorkSpace)\src\os\windows\launcher \ /I $(WorkSpace)\src\os\windows\launcher \
/I $(WorkSpace)\src\share\tools\launcher \ /I $(WorkSpace)\src\share\tools\launcher \
/I $(WorkSpace)\src\share\vm\prims \ /I $(WorkSpace)\src\share\vm\prims \
/I $(WorkSpace)\src\share\vm \ /I $(WorkSpace)\src\share\vm \
/I $(WorkSpace)\src\cpu\$(Platform_arch)\vm \ /I $(WorkSpace)\src\cpu\$(Platform_arch)\vm \
/I $(WorkSpace)\src\os\windows\vm /I $(WorkSpace)\src\os\windows\vm
LINK_FLAGS=/manifest $(HS_INTERNAL_NAME).lib kernel32.lib user32.lib /nologo /machine:$(MACHINE) /map /debug /subsystem:console LINK_FLAGS=/manifest $(HS_INTERNAL_NAME).lib kernel32.lib user32.lib /nologo /machine:$(MACHINE) /map /debug /subsystem:console
!if "$(COMPILER_NAME)" == "VS2005" !if "$(COMPILER_NAME)" == "VS2005"
# This VS2005 compiler has /GS as a default and requires bufferoverflowU.lib # This VS2005 compiler has /GS as a default and requires bufferoverflowU.lib
# on the link command line, otherwise we get missing __security_check_cookie # on the link command line, otherwise we get missing __security_check_cookie
# externals at link time. Even with /GS-, you need bufferoverflowU.lib. # externals at link time. Even with /GS-, you need bufferoverflowU.lib.
BUFFEROVERFLOWLIB = bufferoverflowU.lib BUFFEROVERFLOWLIB = bufferoverflowU.lib
LINK_FLAGS = $(LINK_FLAGS) $(BUFFEROVERFLOWLIB) LINK_FLAGS = $(LINK_FLAGS) $(BUFFEROVERFLOWLIB)
!endif !endif
LAUNCHERDIR = $(WorkSpace)/src/os/windows/launcher !if "$(COMPILER_NAME)" == "VS2010" && "$(BUILDARCH)" == "i486"
LAUNCHERDIR_SHARE = $(WorkSpace)/src/share/tools/launcher LINK_FLAGS = /SAFESEH $(LINK_FLAGS)
!endif
OUTDIR = launcher
LAUNCHERDIR = $(WorkSpace)/src/os/windows/launcher
{$(LAUNCHERDIR)}.c{$(OUTDIR)}.obj: LAUNCHERDIR_SHARE = $(WorkSpace)/src/share/tools/launcher
-mkdir $(OUTDIR) 2>NUL >NUL
$(CPP) $(LAUNCHER_FLAGS) /c /Fo$@ $< OUTDIR = launcher
{$(LAUNCHERDIR_SHARE)}.c{$(OUTDIR)}.obj: {$(LAUNCHERDIR)}.c{$(OUTDIR)}.obj:
-mkdir $(OUTDIR) 2>NUL >NUL -mkdir $(OUTDIR) 2>NUL >NUL
$(CPP) $(LAUNCHER_FLAGS) /c /Fo$@ $< $(CPP) $(LAUNCHER_FLAGS) /c /Fo$@ $<
$(OUTDIR)\*.obj: $(LAUNCHERDIR)\*.c $(LAUNCHERDIR)\*.h $(LAUNCHERDIR_SHARE)\*.c $(LAUNCHERDIR_SHARE)\*.h {$(LAUNCHERDIR_SHARE)}.c{$(OUTDIR)}.obj:
-mkdir $(OUTDIR) 2>NUL >NUL
launcher: $(OUTDIR)\java.obj $(OUTDIR)\java_md.obj $(OUTDIR)\jli_util.obj $(CPP) $(LAUNCHER_FLAGS) /c /Fo$@ $<
echo $(JAVA_HOME) > jdkpath.txt
$(LINK) $(LINK_FLAGS) /out:hotspot.exe $** $(OUTDIR)\*.obj: $(LAUNCHERDIR)\*.c $(LAUNCHERDIR)\*.h $(LAUNCHERDIR_SHARE)\*.c $(LAUNCHERDIR_SHARE)\*.h
launcher: $(OUTDIR)\java.obj $(OUTDIR)\java_md.obj $(OUTDIR)\jli_util.obj
echo $(JAVA_HOME) > jdkpath.txt
$(LINK) $(LINK_FLAGS) /out:hotspot.exe $**
...@@ -2213,7 +2213,7 @@ void os::jvm_path(char *buf, jint buflen) { ...@@ -2213,7 +2213,7 @@ void os::jvm_path(char *buf, jint buflen) {
if (rp == NULL) if (rp == NULL)
return; return;
if (strcmp(Arguments::sun_java_launcher(), "gamma") == 0) { if (Arguments::created_by_gamma_launcher()) {
// Support for the gamma launcher. Typical value for buf is // Support for the gamma launcher. Typical value for buf is
// "<JAVA_HOME>/jre/lib/<arch>/<vmtype>/libjvm.so". If "/jre/lib/" appears at // "<JAVA_HOME>/jre/lib/<arch>/<vmtype>/libjvm.so". If "/jre/lib/" appears at
// the right place in the string, then assume we are installed in a JDK and // the right place in the string, then assume we are installed in a JDK and
......
...@@ -59,3 +59,12 @@ void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* ...@@ -59,3 +59,12 @@ void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char*
VMError::report_coredump_status(buffer, success); VMError::report_coredump_status(buffer, success);
} }
bool os::is_debugger_attached() {
// not implemented
return false;
}
void os::wait_for_keypress_at_exit(void) {
// don't do anything on posix platforms
return;
}
...@@ -2511,7 +2511,7 @@ void os::jvm_path(char *buf, jint buflen) { ...@@ -2511,7 +2511,7 @@ void os::jvm_path(char *buf, jint buflen) {
assert(ret != 0, "cannot locate libjvm"); assert(ret != 0, "cannot locate libjvm");
realpath((char *)dlinfo.dli_fname, buf); realpath((char *)dlinfo.dli_fname, buf);
if (strcmp(Arguments::sun_java_launcher(), "gamma") == 0) { if (Arguments::created_by_gamma_launcher()) {
// Support for the gamma launcher. Typical value for buf is // Support for the gamma launcher. Typical value for buf is
// "<JAVA_HOME>/jre/lib/<arch>/<vmtype>/libjvm.so". If "/jre/lib/" appears at // "<JAVA_HOME>/jre/lib/<arch>/<vmtype>/libjvm.so". If "/jre/lib/" appears at
// the right place in the string, then assume we are installed in a JDK and // the right place in the string, then assume we are installed in a JDK and
......
...@@ -22,10 +22,8 @@ ...@@ -22,10 +22,8 @@
* *
*/ */
#ifdef _WIN64 // Must be at least Windows 2000 or XP to use VectoredExceptions and IsDebuggerPresent
// Must be at least Windows 2000 or XP to use VectoredExceptions
#define _WIN32_WINNT 0x500 #define _WIN32_WINNT 0x500
#endif
// no precompiled headers // no precompiled headers
#include "classfile/classLoader.hpp" #include "classfile/classLoader.hpp"
...@@ -1788,7 +1786,7 @@ void os::jvm_path(char *buf, jint buflen) { ...@@ -1788,7 +1786,7 @@ void os::jvm_path(char *buf, jint buflen) {
} }
buf[0] = '\0'; buf[0] = '\0';
if (strcmp(Arguments::sun_java_launcher(), "gamma") == 0) { if (Arguments::created_by_gamma_launcher()) {
// Support for the gamma launcher. Check for an // Support for the gamma launcher. Check for an
// JAVA_HOME environment variable // JAVA_HOME environment variable
// and fix up the path so it looks like // and fix up the path so it looks like
...@@ -3418,6 +3416,19 @@ void os::win32::setmode_streams() { ...@@ -3418,6 +3416,19 @@ void os::win32::setmode_streams() {
} }
bool os::is_debugger_attached() {
return IsDebuggerPresent() ? true : false;
}
void os::wait_for_keypress_at_exit(void) {
if (PauseAtExit) {
fprintf(stderr, "Press any key to continue...\n");
fgetc(stdin);
}
}
int os::message_box(const char* title, const char* message) { int os::message_box(const char* title, const char* message) {
int result = MessageBox(NULL, message, title, int result = MessageBox(NULL, message, title,
MB_YESNO | MB_ICONERROR | MB_SYSTEMMODAL | MB_DEFAULT_DESKTOP_ONLY); MB_YESNO | MB_ICONERROR | MB_SYSTEMMODAL | MB_DEFAULT_DESKTOP_ONLY);
......
...@@ -170,6 +170,44 @@ bool StackMapFrame::is_assignable_to( ...@@ -170,6 +170,44 @@ bool StackMapFrame::is_assignable_to(
return true; return true;
} }
bool StackMapFrame::has_flag_match_exception(
const StackMapFrame* target) const {
// We allow flags of {UninitThis} to assign to {} if-and-only-if the
// target frame does not depend upon the current type.
// This is slightly too strict, as we need only enforce that the
// slots that were initialized by the <init> (the things that were
// UninitializedThis before initialize_object() converted them) are unused.
// However we didn't save that information so we'll enforce this upon
// anything that might have been initialized. This is a rare situation
// and javac never generates code that would end up here, but some profilers
// (such as NetBeans) might, when adding exception handlers in <init>
// methods to cover the invokespecial instruction. See 7020118.
assert(max_locals() == target->max_locals() &&
stack_size() == target->stack_size(), "StackMap sizes must match");
VerificationType top = VerificationType::top_type();
VerificationType this_type = verifier()->current_type();
if (!flag_this_uninit() || target->flags() != 0) {
return false;
}
for (int i = 0; i < target->locals_size(); ++i) {
if (locals()[i] == this_type && target->locals()[i] != top) {
return false;
}
}
for (int i = 0; i < target->stack_size(); ++i) {
if (stack()[i] == this_type && target->stack()[i] != top) {
return false;
}
}
return true;
}
bool StackMapFrame::is_assignable_to(const StackMapFrame* target, TRAPS) const { bool StackMapFrame::is_assignable_to(const StackMapFrame* target, TRAPS) const {
if (_max_locals != target->max_locals() || _stack_size != target->stack_size()) { if (_max_locals != target->max_locals() || _stack_size != target->stack_size()) {
return false; return false;
...@@ -182,7 +220,9 @@ bool StackMapFrame::is_assignable_to(const StackMapFrame* target, TRAPS) const { ...@@ -182,7 +220,9 @@ bool StackMapFrame::is_assignable_to(const StackMapFrame* target, TRAPS) const {
bool match_stack = is_assignable_to( bool match_stack = is_assignable_to(
_stack, target->stack(), _stack_size, CHECK_false); _stack, target->stack(), _stack_size, CHECK_false);
bool match_flags = (_flags | target->flags()) == target->flags(); bool match_flags = (_flags | target->flags()) == target->flags();
return (match_locals && match_stack && match_flags);
return match_locals && match_stack &&
(match_flags || has_flag_match_exception(target));
} }
VerificationType StackMapFrame::pop_stack_ex(VerificationType type, TRAPS) { VerificationType StackMapFrame::pop_stack_ex(VerificationType type, TRAPS) {
......
...@@ -228,6 +228,8 @@ class StackMapFrame : public ResourceObj { ...@@ -228,6 +228,8 @@ class StackMapFrame : public ResourceObj {
bool is_assignable_to( bool is_assignable_to(
VerificationType* src, VerificationType* target, int32_t len, TRAPS) const; VerificationType* src, VerificationType* target, int32_t len, TRAPS) const;
bool has_flag_match_exception(const StackMapFrame* target) const;
// Debugging // Debugging
void print() const PRODUCT_RETURN; void print() const PRODUCT_RETURN;
}; };
......
...@@ -128,6 +128,7 @@ class VerificationType VALUE_OBJ_CLASS_SPEC { ...@@ -128,6 +128,7 @@ class VerificationType VALUE_OBJ_CLASS_SPEC {
// Create verification types // Create verification types
static VerificationType bogus_type() { return VerificationType(Bogus); } static VerificationType bogus_type() { return VerificationType(Bogus); }
static VerificationType top_type() { return bogus_type(); } // alias
static VerificationType null_type() { return VerificationType(Null); } static VerificationType null_type() { return VerificationType(Null); }
static VerificationType integer_type() { return VerificationType(Integer); } static VerificationType integer_type() { return VerificationType(Integer); }
static VerificationType float_type() { return VerificationType(Float); } static VerificationType float_type() { return VerificationType(Float); }
......
...@@ -422,6 +422,9 @@ size_t Arena::used() const { ...@@ -422,6 +422,9 @@ size_t Arena::used() const {
return sum; // Return total consumed space. return sum; // Return total consumed space.
} }
void Arena::signal_out_of_memory(size_t sz, const char* whence) const {
vm_exit_out_of_memory(sz, whence);
}
// Grow a new Chunk // Grow a new Chunk
void* Arena::grow( size_t x ) { void* Arena::grow( size_t x ) {
...@@ -431,8 +434,9 @@ void* Arena::grow( size_t x ) { ...@@ -431,8 +434,9 @@ void* Arena::grow( size_t x ) {
Chunk *k = _chunk; // Get filled-up chunk address Chunk *k = _chunk; // Get filled-up chunk address
_chunk = new (len) Chunk(len); _chunk = new (len) Chunk(len);
if (_chunk == NULL) if (_chunk == NULL) {
vm_exit_out_of_memory(len * Chunk::aligned_overhead_size(), "Arena::grow"); signal_out_of_memory(len * Chunk::aligned_overhead_size(), "Arena::grow");
}
if (k) k->set_next(_chunk); // Append new chunk to end of linked list if (k) k->set_next(_chunk); // Append new chunk to end of linked list
else _first = _chunk; else _first = _chunk;
...@@ -529,6 +533,7 @@ void* Arena::malloc(size_t size) { ...@@ -529,6 +533,7 @@ void* Arena::malloc(size_t size) {
// for debugging with UseMallocOnly // for debugging with UseMallocOnly
void* Arena::internal_malloc_4(size_t x) { void* Arena::internal_malloc_4(size_t x) {
assert( (x&(sizeof(char*)-1)) == 0, "misaligned size" ); assert( (x&(sizeof(char*)-1)) == 0, "misaligned size" );
check_for_overflow(x, "Arena::internal_malloc_4");
if (_hwm + x > _max) { if (_hwm + x > _max) {
return grow(x); return grow(x);
} else { } else {
......
...@@ -207,6 +207,15 @@ protected: ...@@ -207,6 +207,15 @@ protected:
debug_only(void* malloc(size_t size);) debug_only(void* malloc(size_t size);)
debug_only(void* internal_malloc_4(size_t x);) debug_only(void* internal_malloc_4(size_t x);)
NOT_PRODUCT(void inc_bytes_allocated(size_t x);) NOT_PRODUCT(void inc_bytes_allocated(size_t x);)
void signal_out_of_memory(size_t request, const char* whence) const;
void check_for_overflow(size_t request, const char* whence) const {
if (UINTPTR_MAX - request < (uintptr_t)_hwm) {
signal_out_of_memory(request, whence);
}
}
public: public:
Arena(); Arena();
Arena(size_t init_size); Arena(size_t init_size);
...@@ -220,6 +229,7 @@ protected: ...@@ -220,6 +229,7 @@ protected:
assert(is_power_of_2(ARENA_AMALLOC_ALIGNMENT) , "should be a power of 2"); assert(is_power_of_2(ARENA_AMALLOC_ALIGNMENT) , "should be a power of 2");
x = ARENA_ALIGN(x); x = ARENA_ALIGN(x);
debug_only(if (UseMallocOnly) return malloc(x);) debug_only(if (UseMallocOnly) return malloc(x);)
check_for_overflow(x, "Arena::Amalloc");
NOT_PRODUCT(inc_bytes_allocated(x);) NOT_PRODUCT(inc_bytes_allocated(x);)
if (_hwm + x > _max) { if (_hwm + x > _max) {
return grow(x); return grow(x);
...@@ -233,6 +243,7 @@ protected: ...@@ -233,6 +243,7 @@ protected:
void *Amalloc_4(size_t x) { void *Amalloc_4(size_t x) {
assert( (x&(sizeof(char*)-1)) == 0, "misaligned size" ); assert( (x&(sizeof(char*)-1)) == 0, "misaligned size" );
debug_only(if (UseMallocOnly) return malloc(x);) debug_only(if (UseMallocOnly) return malloc(x);)
check_for_overflow(x, "Arena::Amalloc_4");
NOT_PRODUCT(inc_bytes_allocated(x);) NOT_PRODUCT(inc_bytes_allocated(x);)
if (_hwm + x > _max) { if (_hwm + x > _max) {
return grow(x); return grow(x);
...@@ -253,6 +264,7 @@ protected: ...@@ -253,6 +264,7 @@ protected:
size_t delta = (((size_t)_hwm + DALIGN_M1) & ~DALIGN_M1) - (size_t)_hwm; size_t delta = (((size_t)_hwm + DALIGN_M1) & ~DALIGN_M1) - (size_t)_hwm;
x += delta; x += delta;
#endif #endif
check_for_overflow(x, "Arena::Amalloc_D");
NOT_PRODUCT(inc_bytes_allocated(x);) NOT_PRODUCT(inc_bytes_allocated(x);)
if (_hwm + x > _max) { if (_hwm + x > _max) {
return grow(x); // grow() returns a result aligned >= 8 bytes. return grow(x); // grow() returns a result aligned >= 8 bytes.
......
...@@ -1805,6 +1805,10 @@ void JvmtiExport::post_compiled_method_load(JvmtiEnv* env, const jmethodID metho ...@@ -1805,6 +1805,10 @@ void JvmtiExport::post_compiled_method_load(JvmtiEnv* env, const jmethodID metho
void JvmtiExport::post_dynamic_code_generated_internal(const char *name, const void *code_begin, const void *code_end) { void JvmtiExport::post_dynamic_code_generated_internal(const char *name, const void *code_begin, const void *code_end) {
JavaThread* thread = JavaThread::current(); JavaThread* thread = JavaThread::current();
// In theory everyone coming thru here is in_vm but we need to be certain
// because a callee will do a vm->native transition
ThreadInVMfromUnknown __tiv;
EVT_TRIG_TRACE(JVMTI_EVENT_DYNAMIC_CODE_GENERATED, EVT_TRIG_TRACE(JVMTI_EVENT_DYNAMIC_CODE_GENERATED,
("JVMTI [%s] method dynamic code generated event triggered", ("JVMTI [%s] method dynamic code generated event triggered",
JvmtiTrace::safe_get_thread_name(thread))); JvmtiTrace::safe_get_thread_name(thread)));
...@@ -1826,19 +1830,18 @@ void JvmtiExport::post_dynamic_code_generated_internal(const char *name, const v ...@@ -1826,19 +1830,18 @@ void JvmtiExport::post_dynamic_code_generated_internal(const char *name, const v
} }
void JvmtiExport::post_dynamic_code_generated(const char *name, const void *code_begin, const void *code_end) { void JvmtiExport::post_dynamic_code_generated(const char *name, const void *code_begin, const void *code_end) {
// In theory everyone coming thru here is in_vm but we need to be certain
// because a callee will do a vm->native transition
ThreadInVMfromUnknown __tiv;
jvmtiPhase phase = JvmtiEnv::get_phase(); jvmtiPhase phase = JvmtiEnv::get_phase();
if (phase == JVMTI_PHASE_PRIMORDIAL || phase == JVMTI_PHASE_START) { if (phase == JVMTI_PHASE_PRIMORDIAL || phase == JVMTI_PHASE_START) {
post_dynamic_code_generated_internal(name, code_begin, code_end); post_dynamic_code_generated_internal(name, code_begin, code_end);
return; } else {
// It may not be safe to post the event from this thread. Defer all
// postings to the service thread so that it can perform them in a safe
// context and in-order.
MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag);
JvmtiDeferredEvent event = JvmtiDeferredEvent::dynamic_code_generated_event(
name, code_begin, code_end);
JvmtiDeferredEventQueue::enqueue(event);
} }
// Blocks until everything now in the queue has been posted
JvmtiDeferredEventQueue::flush_queue(Thread::current());
post_dynamic_code_generated_internal(name, code_begin, code_end);
} }
......
...@@ -140,12 +140,12 @@ class JvmtiExport : public AllStatic { ...@@ -140,12 +140,12 @@ class JvmtiExport : public AllStatic {
char sig_type, jvalue *value); char sig_type, jvalue *value);
private:
// posts a DynamicCodeGenerated event (internal/private implementation). // posts a DynamicCodeGenerated event (internal/private implementation).
// The public post_dynamic_code_generated* functions make use of the // The public post_dynamic_code_generated* functions make use of the
// internal implementation. // internal implementation. Also called from JvmtiDeferredEvent::post()
static void post_dynamic_code_generated_internal(const char *name, const void *code_begin, const void *code_end) KERNEL_RETURN; static void post_dynamic_code_generated_internal(const char *name, const void *code_begin, const void *code_end) KERNEL_RETURN;
private:
// GenerateEvents support to allow posting of CompiledMethodLoad and // GenerateEvents support to allow posting of CompiledMethodLoad and
// DynamicCodeGenerated events for a given environment. // DynamicCodeGenerated events for a given environment.
......
...@@ -918,7 +918,7 @@ void JvmtiSuspendControl::print() { ...@@ -918,7 +918,7 @@ void JvmtiSuspendControl::print() {
JvmtiDeferredEvent JvmtiDeferredEvent::compiled_method_load_event( JvmtiDeferredEvent JvmtiDeferredEvent::compiled_method_load_event(
nmethod* nm) { nmethod* nm) {
JvmtiDeferredEvent event = JvmtiDeferredEvent(TYPE_COMPILED_METHOD_LOAD); JvmtiDeferredEvent event = JvmtiDeferredEvent(TYPE_COMPILED_METHOD_LOAD);
event.set_compiled_method_load(nm); event._event_data.compiled_method_load = nm;
nmethodLocker::lock_nmethod(nm); // will be unlocked when posted nmethodLocker::lock_nmethod(nm); // will be unlocked when posted
return event; return event;
} }
...@@ -926,23 +926,39 @@ JvmtiDeferredEvent JvmtiDeferredEvent::compiled_method_load_event( ...@@ -926,23 +926,39 @@ JvmtiDeferredEvent JvmtiDeferredEvent::compiled_method_load_event(
JvmtiDeferredEvent JvmtiDeferredEvent::compiled_method_unload_event( JvmtiDeferredEvent JvmtiDeferredEvent::compiled_method_unload_event(
jmethodID id, const void* code) { jmethodID id, const void* code) {
JvmtiDeferredEvent event = JvmtiDeferredEvent(TYPE_COMPILED_METHOD_UNLOAD); JvmtiDeferredEvent event = JvmtiDeferredEvent(TYPE_COMPILED_METHOD_UNLOAD);
event.set_compiled_method_unload(id, code); event._event_data.compiled_method_unload.method_id = id;
event._event_data.compiled_method_unload.code_begin = code;
return event;
}
JvmtiDeferredEvent JvmtiDeferredEvent::dynamic_code_generated_event(
const char* name, const void* code_begin, const void* code_end) {
JvmtiDeferredEvent event = JvmtiDeferredEvent(TYPE_DYNAMIC_CODE_GENERATED);
event._event_data.dynamic_code_generated.name = name;
event._event_data.dynamic_code_generated.code_begin = code_begin;
event._event_data.dynamic_code_generated.code_end = code_end;
return event; return event;
} }
void JvmtiDeferredEvent::post() { void JvmtiDeferredEvent::post() {
assert(ServiceThread::is_service_thread(Thread::current()),
"Service thread must post enqueued events");
switch(_type) { switch(_type) {
case TYPE_COMPILED_METHOD_LOAD: case TYPE_COMPILED_METHOD_LOAD: {
JvmtiExport::post_compiled_method_load(compiled_method_load()); nmethod* nm = _event_data.compiled_method_load;
nmethodLocker::unlock_nmethod(compiled_method_load()); JvmtiExport::post_compiled_method_load(nm);
nmethodLocker::unlock_nmethod(nm);
break; break;
}
case TYPE_COMPILED_METHOD_UNLOAD: case TYPE_COMPILED_METHOD_UNLOAD:
JvmtiExport::post_compiled_method_unload( JvmtiExport::post_compiled_method_unload(
compiled_method_unload_method_id(), _event_data.compiled_method_unload.method_id,
compiled_method_unload_code_begin()); _event_data.compiled_method_unload.code_begin);
break; break;
case TYPE_FLUSH: case TYPE_DYNAMIC_CODE_GENERATED:
JvmtiDeferredEventQueue::flush_complete(flush_state_addr()); JvmtiExport::post_dynamic_code_generated_internal(
_event_data.dynamic_code_generated.name,
_event_data.dynamic_code_generated.code_begin,
_event_data.dynamic_code_generated.code_end);
break; break;
default: default:
ShouldNotReachHere(); ShouldNotReachHere();
...@@ -1065,54 +1081,4 @@ void JvmtiDeferredEventQueue::process_pending_events() { ...@@ -1065,54 +1081,4 @@ void JvmtiDeferredEventQueue::process_pending_events() {
} }
} }
enum {
// Random - used for debugging
FLUSHING = 0x50403020,
FLUSHED = 0x09080706
};
void JvmtiDeferredEventQueue::flush_queue(Thread* thread) {
volatile int flush_state = FLUSHING;
JvmtiDeferredEvent flush(JvmtiDeferredEvent::TYPE_FLUSH);
flush.set_flush_state_addr((int*)&flush_state);
if (ServiceThread::is_service_thread(thread)) {
// If we are the service thread we have to post all preceding events
// Use the flush event as a token to indicate when we can stop
JvmtiDeferredEvent event;
{
MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag);
enqueue(flush);
event = dequeue();
}
while (!event.is_flush_event() ||
event.flush_state_addr() != &flush_state) {
event.post();
{
MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag);
event = dequeue();
}
}
} else {
// Wake up the service thread so it will process events. When it gets
// to the flush event it will set 'flush_complete' and notify us.
MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag);
enqueue(flush);
while (flush_state != FLUSHED) {
assert(flush_state == FLUSHING || flush_state == FLUSHED,
"only valid values for this");
Service_lock->wait(Mutex::_no_safepoint_check_flag);
}
}
}
void JvmtiDeferredEventQueue::flush_complete(int* state_addr) {
assert(state_addr != NULL && *state_addr == FLUSHING, "must be");
MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag);
*state_addr = FLUSHED;
Service_lock->notify_all();
}
#endif // ndef KERNEL #endif // ndef KERNEL
...@@ -451,7 +451,7 @@ class JvmtiDeferredEvent VALUE_OBJ_CLASS_SPEC { ...@@ -451,7 +451,7 @@ class JvmtiDeferredEvent VALUE_OBJ_CLASS_SPEC {
TYPE_NONE, TYPE_NONE,
TYPE_COMPILED_METHOD_LOAD, TYPE_COMPILED_METHOD_LOAD,
TYPE_COMPILED_METHOD_UNLOAD, TYPE_COMPILED_METHOD_UNLOAD,
TYPE_FLUSH // pseudo-event used to implement flush_queue() TYPE_DYNAMIC_CODE_GENERATED
} Type; } Type;
Type _type; Type _type;
...@@ -461,49 +461,15 @@ class JvmtiDeferredEvent VALUE_OBJ_CLASS_SPEC { ...@@ -461,49 +461,15 @@ class JvmtiDeferredEvent VALUE_OBJ_CLASS_SPEC {
jmethodID method_id; jmethodID method_id;
const void* code_begin; const void* code_begin;
} compiled_method_unload; } compiled_method_unload;
int* flush_state_addr; struct {
const char* name;
const void* code_begin;
const void* code_end;
} dynamic_code_generated;
} _event_data; } _event_data;
JvmtiDeferredEvent(Type t) : _type(t) {} JvmtiDeferredEvent(Type t) : _type(t) {}
void set_compiled_method_load(nmethod* nm) {
assert(_type == TYPE_COMPILED_METHOD_LOAD, "must be");
_event_data.compiled_method_load = nm;
}
nmethod* compiled_method_load() const {
assert(_type == TYPE_COMPILED_METHOD_LOAD, "must be");
return _event_data.compiled_method_load;
}
void set_compiled_method_unload(jmethodID id, const void* code) {
assert(_type == TYPE_COMPILED_METHOD_UNLOAD, "must be");
_event_data.compiled_method_unload.method_id = id;
_event_data.compiled_method_unload.code_begin = code;
}
jmethodID compiled_method_unload_method_id() const {
assert(_type == TYPE_COMPILED_METHOD_UNLOAD, "must be");
return _event_data.compiled_method_unload.method_id;
}
const void* compiled_method_unload_code_begin() const {
assert(_type == TYPE_COMPILED_METHOD_UNLOAD, "must be");
return _event_data.compiled_method_unload.code_begin;
}
bool is_flush_event() const { return _type == TYPE_FLUSH; }
int* flush_state_addr() const {
assert(is_flush_event(), "must be");
return _event_data.flush_state_addr;
}
void set_flush_state_addr(int* flag) {
assert(is_flush_event(), "must be");
_event_data.flush_state_addr = flag;
}
public: public:
JvmtiDeferredEvent() : _type(TYPE_NONE) {} JvmtiDeferredEvent() : _type(TYPE_NONE) {}
...@@ -513,6 +479,9 @@ class JvmtiDeferredEvent VALUE_OBJ_CLASS_SPEC { ...@@ -513,6 +479,9 @@ class JvmtiDeferredEvent VALUE_OBJ_CLASS_SPEC {
KERNEL_RETURN_(JvmtiDeferredEvent()); KERNEL_RETURN_(JvmtiDeferredEvent());
static JvmtiDeferredEvent compiled_method_unload_event( static JvmtiDeferredEvent compiled_method_unload_event(
jmethodID id, const void* code) KERNEL_RETURN_(JvmtiDeferredEvent()); jmethodID id, const void* code) KERNEL_RETURN_(JvmtiDeferredEvent());
static JvmtiDeferredEvent dynamic_code_generated_event(
const char* name, const void* begin, const void* end)
KERNEL_RETURN_(JvmtiDeferredEvent());
// Actually posts the event. // Actually posts the event.
void post() KERNEL_RETURN; void post() KERNEL_RETURN;
...@@ -548,25 +517,12 @@ class JvmtiDeferredEventQueue : AllStatic { ...@@ -548,25 +517,12 @@ class JvmtiDeferredEventQueue : AllStatic {
// Transfers events from the _pending_list to the _queue. // Transfers events from the _pending_list to the _queue.
static void process_pending_events() KERNEL_RETURN; static void process_pending_events() KERNEL_RETURN;
static void flush_complete(int* flush_state) KERNEL_RETURN;
public: public:
// Must be holding Service_lock when calling these // Must be holding Service_lock when calling these
static bool has_events() KERNEL_RETURN_(false); static bool has_events() KERNEL_RETURN_(false);
static void enqueue(const JvmtiDeferredEvent& event) KERNEL_RETURN; static void enqueue(const JvmtiDeferredEvent& event) KERNEL_RETURN;
static JvmtiDeferredEvent dequeue() KERNEL_RETURN_(JvmtiDeferredEvent()); static JvmtiDeferredEvent dequeue() KERNEL_RETURN_(JvmtiDeferredEvent());
// This call blocks until all events enqueued prior to this call
// have been posted. The Service_lock is acquired and waited upon.
//
// Implemented by creating a "flush" event and placing it in the queue.
// When the flush event is "posted" it will call flush_complete(), which
// will release the caller.
//
// Can be called by any thread (maybe even the service thread itself).
// Not necessary for the caller to be a JavaThread.
static void flush_queue(Thread* current) KERNEL_RETURN;
// Used to enqueue events without using a lock, for times (such as during // Used to enqueue events without using a lock, for times (such as during
// safepoint) when we can't or don't want to lock the Service_lock. // safepoint) when we can't or don't want to lock the Service_lock.
// //
......
...@@ -78,6 +78,7 @@ bool Arguments::_xdebug_mode = false; ...@@ -78,6 +78,7 @@ bool Arguments::_xdebug_mode = false;
const char* Arguments::_java_vendor_url_bug = DEFAULT_VENDOR_URL_BUG; const char* Arguments::_java_vendor_url_bug = DEFAULT_VENDOR_URL_BUG;
const char* Arguments::_sun_java_launcher = DEFAULT_JAVA_LAUNCHER; const char* Arguments::_sun_java_launcher = DEFAULT_JAVA_LAUNCHER;
int Arguments::_sun_java_launcher_pid = -1; int Arguments::_sun_java_launcher_pid = -1;
bool Arguments::_created_by_gamma_launcher = false;
// These parameters are reset in method parse_vm_init_args(JavaVMInitArgs*) // These parameters are reset in method parse_vm_init_args(JavaVMInitArgs*)
bool Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods; bool Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods;
...@@ -1656,6 +1657,9 @@ void Arguments::process_java_compiler_argument(char* arg) { ...@@ -1656,6 +1657,9 @@ void Arguments::process_java_compiler_argument(char* arg) {
void Arguments::process_java_launcher_argument(const char* launcher, void* extra_info) { void Arguments::process_java_launcher_argument(const char* launcher, void* extra_info) {
_sun_java_launcher = strdup(launcher); _sun_java_launcher = strdup(launcher);
if (strcmp("gamma", _sun_java_launcher) == 0) {
_created_by_gamma_launcher = true;
}
} }
bool Arguments::created_by_java_launcher() { bool Arguments::created_by_java_launcher() {
...@@ -1663,6 +1667,10 @@ bool Arguments::created_by_java_launcher() { ...@@ -1663,6 +1667,10 @@ bool Arguments::created_by_java_launcher() {
return strcmp(DEFAULT_JAVA_LAUNCHER, _sun_java_launcher) != 0; return strcmp(DEFAULT_JAVA_LAUNCHER, _sun_java_launcher) != 0;
} }
bool Arguments::created_by_gamma_launcher() {
return _created_by_gamma_launcher;
}
//=========================================================================================================== //===========================================================================================================
// Parsing of main arguments // Parsing of main arguments
...@@ -3155,6 +3163,16 @@ jint Arguments::parse(const JavaVMInitArgs* args) { ...@@ -3155,6 +3163,16 @@ jint Arguments::parse(const JavaVMInitArgs* args) {
} }
} }
// set PauseAtExit if the gamma launcher was used and a debugger is attached
// but only if not already set on the commandline
if (Arguments::created_by_gamma_launcher() && os::is_debugger_attached()) {
bool set = false;
CommandLineFlags::wasSetOnCmdline("PauseAtExit", &set);
if (!set) {
FLAG_SET_DEFAULT(PauseAtExit, true);
}
}
return JNI_OK; return JNI_OK;
} }
......
/* /*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2011, 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
...@@ -257,6 +257,9 @@ class Arguments : AllStatic { ...@@ -257,6 +257,9 @@ class Arguments : AllStatic {
// sun.java.launcher.pid, private property // sun.java.launcher.pid, private property
static int _sun_java_launcher_pid; static int _sun_java_launcher_pid;
// was this VM created by the gamma launcher
static bool _created_by_gamma_launcher;
// Option flags // Option flags
static bool _has_profile; static bool _has_profile;
static bool _has_alloc_profile; static bool _has_alloc_profile;
...@@ -444,6 +447,8 @@ class Arguments : AllStatic { ...@@ -444,6 +447,8 @@ class Arguments : AllStatic {
static const char* sun_java_launcher() { return _sun_java_launcher; } static const char* sun_java_launcher() { return _sun_java_launcher; }
// Was VM created by a Java launcher? // Was VM created by a Java launcher?
static bool created_by_java_launcher(); static bool created_by_java_launcher();
// Was VM created by the gamma Java launcher?
static bool created_by_gamma_launcher();
// -Dsun.java.launcher.pid // -Dsun.java.launcher.pid
static int sun_java_launcher_pid() { return _sun_java_launcher_pid; } static int sun_java_launcher_pid() { return _sun_java_launcher_pid; }
......
...@@ -3733,6 +3733,9 @@ class CommandLineFlags { ...@@ -3733,6 +3733,9 @@ class CommandLineFlags {
"The file to create and for whose removal to await when pausing " \ "The file to create and for whose removal to await when pausing " \
"at startup. (default: ./vm.paused.<pid>)") \ "at startup. (default: ./vm.paused.<pid>)") \
\ \
diagnostic(bool, PauseAtExit, false, \
"Pause and wait for keypress on exit if a debugger is attached") \
\
product(bool, ExtendedDTraceProbes, false, \ product(bool, ExtendedDTraceProbes, false, \
"Enable performance-impacting dtrace probes") \ "Enable performance-impacting dtrace probes") \
\ \
......
...@@ -551,6 +551,7 @@ void notify_vm_shutdown() { ...@@ -551,6 +551,7 @@ void notify_vm_shutdown() {
void vm_direct_exit(int code) { void vm_direct_exit(int code) {
notify_vm_shutdown(); notify_vm_shutdown();
os::wait_for_keypress_at_exit();
::exit(code); ::exit(code);
} }
...@@ -577,11 +578,13 @@ void vm_perform_shutdown_actions() { ...@@ -577,11 +578,13 @@ void vm_perform_shutdown_actions() {
void vm_shutdown() void vm_shutdown()
{ {
vm_perform_shutdown_actions(); vm_perform_shutdown_actions();
os::wait_for_keypress_at_exit();
os::shutdown(); os::shutdown();
} }
void vm_abort(bool dump_core) { void vm_abort(bool dump_core) {
vm_perform_shutdown_actions(); vm_perform_shutdown_actions();
os::wait_for_keypress_at_exit();
os::abort(dump_core); os::abort(dump_core);
ShouldNotReachHere(); ShouldNotReachHere();
} }
......
...@@ -492,6 +492,12 @@ class os: AllStatic { ...@@ -492,6 +492,12 @@ class os: AllStatic {
static void print_location(outputStream* st, intptr_t x, bool verbose = false); static void print_location(outputStream* st, intptr_t x, bool verbose = false);
static size_t lasterror(char *buf, size_t len); static size_t lasterror(char *buf, size_t len);
// Determines whether the calling process is being debugged by a user-mode debugger.
static bool is_debugger_attached();
// wait for a key press if PauseAtExit is set
static void wait_for_keypress_at_exit(void);
// The following two functions are used by fatal error handler to trace // The following two functions are used by fatal error handler to trace
// native (C) frames. They are not part of frame.hpp/frame.cpp because // native (C) frames. They are not part of frame.hpp/frame.cpp because
// frame.hpp/cpp assume thread is JavaThread, and also because different // frame.hpp/cpp assume thread is JavaThread, and also because different
......
...@@ -3644,6 +3644,7 @@ bool Threads::destroy_vm() { ...@@ -3644,6 +3644,7 @@ bool Threads::destroy_vm() {
if (ShowMessageBoxOnError && is_error_reported()) { if (ShowMessageBoxOnError && is_error_reported()) {
os::infinite_sleep(); os::infinite_sleep();
} }
os::wait_for_keypress_at_exit();
if (JDK_Version::is_jdk12x_version()) { if (JDK_Version::is_jdk12x_version()) {
// We are the last thread running, so check if finalizers should be run. // We are the last thread running, so check if finalizers should be run.
......
...@@ -77,6 +77,7 @@ ...@@ -77,6 +77,7 @@
# endif # endif
#ifdef LINUX #ifdef LINUX
#define __STDC_LIMIT_MACROS
#include <inttypes.h> #include <inttypes.h>
#include <signal.h> #include <signal.h>
#include <ucontext.h> #include <ucontext.h>
......
...@@ -148,6 +148,17 @@ typedef unsigned int uintptr_t; ...@@ -148,6 +148,17 @@ typedef unsigned int uintptr_t;
#endif #endif
#endif #endif
// On solaris 8, UINTPTR_MAX is defined as empty.
// Everywhere else it's an actual value.
#if UINTPTR_MAX - 1 == -1
#undef UINTPTR_MAX
#ifdef _LP64
#define UINTPTR_MAX UINT64_MAX
#else
#define UINTPTR_MAX UINT32_MAX
#endif /* ifdef _LP64 */
#endif
// Additional Java basic types // Additional Java basic types
typedef unsigned char jubyte; typedef unsigned char jubyte;
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
# include <stdio.h> // for va_list # include <stdio.h> // for va_list
# include <time.h> # include <time.h>
# include <fcntl.h> # include <fcntl.h>
# include <limits.h>
// Need this on windows to get the math constants (e.g., M_PI). // Need this on windows to get the math constants (e.g., M_PI).
#define _USE_MATH_DEFINES #define _USE_MATH_DEFINES
# include <math.h> # include <math.h>
...@@ -99,6 +100,14 @@ typedef signed int intptr_t; ...@@ -99,6 +100,14 @@ typedef signed int intptr_t;
typedef signed int ssize_t; typedef signed int ssize_t;
#endif #endif
#ifndef UINTPTR_MAX
#ifdef _WIN64
#define UINTPTR_MAX _UI64_MAX
#else
#define UINTPTR_MAX _UI32_MAX
#endif
#endif
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Additional Java basic types // Additional Java basic types
......
...@@ -802,7 +802,7 @@ void VMError::report_and_die() { ...@@ -802,7 +802,7 @@ void VMError::report_and_die() {
first_error_tid = mytid; first_error_tid = mytid;
set_error_reported(); set_error_reported();
if (ShowMessageBoxOnError) { if (ShowMessageBoxOnError || PauseAtExit) {
show_message_box(buffer, sizeof(buffer)); show_message_box(buffer, sizeof(buffer));
// User has asked JVM to abort. Reset ShowMessageBoxOnError so the // User has asked JVM to abort. Reset ShowMessageBoxOnError so the
......
#!/bin/sh
##
## @test
## @bug 6878713
## @summary Verifier heap corruption, relating to backward jsrs
## @run shell/timeout=120 Test6878713.sh
##
if [ "${TESTSRC}" = "" ]
then TESTSRC=.
fi
if [ "${TESTJAVA}" = "" ]
then
PARENT=`dirname \`which java\``
TESTJAVA=`dirname ${PARENT}`
echo "TESTJAVA not set, selecting " ${TESTJAVA}
echo "If this is incorrect, try setting the variable manually."
fi
if [ "${TESTCLASSES}" = "" ]
then
echo "TESTCLASSES not set. Test cannot execute. Failed."
exit 1
fi
BIT_FLAG=""
# set platform-dependent variables
OS=`uname -s`
case "$OS" in
SunOS | Linux )
NULL=/dev/null
PS=":"
FS="/"
## for solaris, linux it's HOME
FILE_LOCATION=$HOME
if [ -f ${FILE_LOCATION}${FS}JDK64BIT -a ${OS} = "SunOS" ]
then
BIT_FLAG=`cat ${FILE_LOCATION}${FS}JDK64BIT | grep -v '^#'`
fi
;;
Windows_* )
NULL=NUL
PS=";"
FS="\\"
;;
* )
echo "Unrecognized system!"
exit 1;
;;
esac
JEMMYPATH=${CPAPPEND}
CLASSPATH=.${PS}${TESTCLASSES}${PS}${JEMMYPATH} ; export CLASSPATH
THIS_DIR=`pwd`
${TESTJAVA}${FS}bin${FS}java ${BIT_FLAG} -version
${TESTJAVA}${FS}bin${FS}jar xvf ${TESTSRC}${FS}testcase.jar
${TESTJAVA}${FS}bin${FS}java ${BIT_FLAG} OOMCrashClass1960_2 > test.out 2>&1
if [ -s core -o -s "hs_*.log" ]
then
cat hs*.log
echo "Test Failed"
exit 1
else
echo "Test Passed"
exit 0
fi
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册