提交 140c62f9 编写于 作者: C coleenp

7174978: NPG: Fix bactrace builder for class redefinition

Summary: Remove Method* from backtrace but save version so redefine classes doesn't give inaccurate line numbers.  Removed old Merlin API with duplicate code.
Reviewed-by: dholmes, sspitsyn
上级 d9bb8b80
......@@ -3,7 +3,7 @@
#
#
# Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
......@@ -205,7 +205,6 @@ SUNWprivate_1.1 {
JVM_NewMultiArray;
JVM_OnExit;
JVM_Open;
JVM_PrintStackTrace;
JVM_RaiseSignal;
JVM_RawMonitorCreate;
JVM_RawMonitorDestroy;
......
......@@ -3,7 +3,7 @@
#
#
# Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
......@@ -205,7 +205,6 @@ SUNWprivate_1.1 {
JVM_NewMultiArray;
JVM_OnExit;
JVM_Open;
JVM_PrintStackTrace;
JVM_RaiseSignal;
JVM_RawMonitorCreate;
JVM_RawMonitorDestroy;
......
#
# Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
......@@ -201,7 +201,6 @@ SUNWprivate_1.1 {
JVM_NewMultiArray;
JVM_OnExit;
JVM_Open;
JVM_PrintStackTrace;
JVM_RaiseSignal;
JVM_RawMonitorCreate;
JVM_RawMonitorDestroy;
......
#
# Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
......@@ -201,7 +201,6 @@ SUNWprivate_1.1 {
JVM_NewMultiArray;
JVM_OnExit;
JVM_Open;
JVM_PrintStackTrace;
JVM_RaiseSignal;
JVM_RawMonitorCreate;
JVM_RawMonitorDestroy;
......
#
# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
......@@ -201,7 +201,6 @@ SUNWprivate_1.1 {
JVM_NewMultiArray;
JVM_OnExit;
JVM_Open;
JVM_PrintStackTrace;
JVM_RaiseSignal;
JVM_RawMonitorCreate;
JVM_RawMonitorDestroy;
......
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -469,8 +469,7 @@ class java_lang_Throwable: AllStatic {
static int static_unassigned_stacktrace_offset;
// Printing
static char* print_stack_element_to_buffer(Method* method, int bci);
static void print_to_stream(Handle stream, const char* str);
static char* print_stack_element_to_buffer(Handle mirror, int method, int version, int bci);
// StackTrace (programmatic access, new since 1.4)
static void clear_stacktrace(oop throwable);
// No stack trace available
......@@ -490,12 +489,9 @@ class java_lang_Throwable: AllStatic {
static oop message(oop throwable);
static oop message(Handle throwable);
static void set_message(oop throwable, oop value);
// Print stack trace stored in exception by call-back to Java
// Note: this is no longer used in Merlin, but we still suppport
// it for compatibility.
static void print_stack_trace(oop throwable, oop print_stream);
static void print_stack_element(Handle stream, Method* method, int bci);
static void print_stack_element(outputStream *st, Method* method, int bci);
static void print_stack_element(outputStream *st, Handle mirror, int method,
int version, int bci);
static void print_stack_element(outputStream *st, methodHandle method, int bci);
static void print_stack_usage(Handle stream);
// Allocate space for backtrace (created but stack trace not filled in)
......@@ -1263,7 +1259,8 @@ class java_lang_StackTraceElement: AllStatic {
static void set_lineNumber(oop element, int value);
// Create an instance of StackTraceElement
static oop create(methodHandle m, int bci, TRAPS);
static oop create(Handle mirror, int method, int version, int bci, TRAPS);
static oop create(methodHandle method, int bci, TRAPS);
// Debugging
friend class JavaClasses;
......
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -66,7 +66,7 @@ ConstantPool::ConstantPool(Array<u1>* tags) {
set_pool_holder(NULL);
set_flags(0);
// only set to non-zero if constant pool is merged by RedefineClasses
set_orig_length(0);
set_version(0);
set_lock(new Monitor(Monitor::nonleaf + 2, "A constant pool lock"));
// all fields are initialized; needed for GC
set_on_stack(false);
......
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -103,8 +103,8 @@ class ConstantPool : public Metadata {
union {
// set for CDS to restore resolved references
int _resolved_reference_length;
// only set to non-zero if constant pool is merged by RedefineClasses
int _orig_length;
// keeps version number for redefined classes (used in backtrace)
int _version;
} _saved;
Monitor* _lock;
......@@ -784,8 +784,11 @@ class ConstantPool : public Metadata {
static void copy_cp_to_impl(constantPoolHandle from_cp, int start_i, int end_i, constantPoolHandle to_cp, int to_i, TRAPS);
static void copy_entry_to(constantPoolHandle from_cp, int from_i, constantPoolHandle to_cp, int to_i, TRAPS);
int find_matching_entry(int pattern_i, constantPoolHandle search_cp, TRAPS);
int orig_length() const { return _saved._orig_length; }
void set_orig_length(int orig_length) { _saved._orig_length = orig_length; }
int version() const { return _saved._version; }
void set_version(int version) { _saved._version = version; }
void increment_and_save_version(int version) {
_saved._version = version >= 0 ? version++ : version; // keep overflow
}
void set_resolved_reference_length(int length) { _saved._resolved_reference_length = length; }
int resolved_reference_length() const { return _saved._resolved_reference_length; }
......
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -484,15 +484,6 @@ JVM_ENTRY(void, JVM_FillInStackTrace(JNIEnv *env, jobject receiver))
JVM_END
JVM_ENTRY(void, JVM_PrintStackTrace(JNIEnv *env, jobject receiver, jobject printable))
JVMWrapper("JVM_PrintStackTrace");
// Note: This is no longer used in Merlin, but we still support it for compatibility.
oop exception = JNIHandles::resolve_non_null(receiver);
oop stream = JNIHandles::resolve_non_null(printable);
java_lang_Throwable::print_stack_trace(exception, stream);
JVM_END
JVM_ENTRY(jint, JVM_GetStackTraceDepth(JNIEnv *env, jobject throwable))
JVMWrapper("JVM_GetStackTraceDepth");
oop exception = JNIHandles::resolve(throwable);
......
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -212,9 +212,6 @@ JVM_IsNaN(jdouble d);
JNIEXPORT void JNICALL
JVM_FillInStackTrace(JNIEnv *env, jobject throwable);
JNIEXPORT void JNICALL
JVM_PrintStackTrace(JNIEnv *env, jobject throwable, jobject printable);
JNIEXPORT jint JNICALL
JVM_GetStackTraceDepth(JNIEnv *env, jobject throwable);
......
/*
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -1334,20 +1334,8 @@ jvmtiError VM_RedefineClasses::merge_cp_and_rewrite(
return JVMTI_ERROR_INTERNAL;
}
int orig_length = old_cp->orig_length();
if (orig_length == 0) {
// This old_cp is an actual original constant pool. We save
// the original length in the merged constant pool so that
// merge_constant_pools() can be more efficient. If a constant
// pool has a non-zero orig_length() value, then that constant
// pool was created by a merge operation in RedefineClasses.
merge_cp->set_orig_length(old_cp->length());
} else {
// This old_cp is a merged constant pool from a previous
// RedefineClasses() calls so just copy the orig_length()
// value.
merge_cp->set_orig_length(old_cp->orig_length());
}
// Update the version number of the constant pool
merge_cp->increment_and_save_version(old_cp->version());
ResourceMark rm(THREAD);
_index_map_count = 0;
......@@ -2417,18 +2405,19 @@ void VM_RedefineClasses::set_new_constant_pool(
int scratch_cp_length, TRAPS) {
assert(scratch_cp->length() >= scratch_cp_length, "sanity check");
// scratch_cp is a merged constant pool and has enough space for a
// worst case merge situation. We want to associate the minimum
// sized constant pool with the klass to save space.
constantPoolHandle smaller_cp(THREAD,
ConstantPool::allocate(loader_data, scratch_cp_length,
THREAD));
// preserve orig_length() value in the smaller copy
int orig_length = scratch_cp->orig_length();
assert(orig_length != 0, "sanity check");
smaller_cp->set_orig_length(orig_length);
scratch_cp->copy_cp_to(1, scratch_cp_length - 1, smaller_cp, 1, THREAD);
scratch_cp = smaller_cp;
// scratch_cp is a merged constant pool and has enough space for a
// worst case merge situation. We want to associate the minimum
// sized constant pool with the klass to save space.
constantPoolHandle smaller_cp(THREAD,
ConstantPool::allocate(loader_data, scratch_cp_length, THREAD));
// preserve version() value in the smaller copy
int version = scratch_cp->version();
assert(version != 0, "sanity check");
smaller_cp->set_version(version);
scratch_cp->copy_cp_to(1, scratch_cp_length - 1, smaller_cp, 1, THREAD);
scratch_cp = smaller_cp;
// attach new constant pool to klass
scratch_cp->set_pool_holder(scratch_class());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册