Skip to content
Permalink
Browse files

8235438: [JVMCI] StackTraceElement::decode should use the original Me…

…thod

Reviewed-by: coleenp, never
  • Loading branch information
Vladimir Kozlov
Vladimir Kozlov committed Dec 6, 2019
1 parent e192150 commit 41b4803cdf4f6fd1e170c0b4bfc587893303f956
@@ -2709,62 +2709,58 @@ void java_lang_StackTraceElement::fill_in(Handle element,
java_lang_StackTraceElement::set_fileName(element(), NULL);
java_lang_StackTraceElement::set_lineNumber(element(), -1);
} else {
// Fill in source file name and line number.
Symbol* source = Backtrace::get_source_file_name(holder, version);
oop source_file = java_lang_Class::source_file(java_class());
if (source != NULL) {
// Class was not redefined. We can trust its cache if set,
// else we have to initialize it.
if (source_file == NULL) {
source_file = StringTable::intern(source, CHECK);
java_lang_Class::set_source_file(java_class(), source_file);
}
} else {
// Class was redefined. Dump the cache if it was set.
if (source_file != NULL) {
source_file = NULL;
java_lang_Class::set_source_file(java_class(), source_file);
}
}
java_lang_StackTraceElement::set_fileName(element(), source_file);
Symbol* source;
oop source_file;
int line_number;
decode_file_and_line(java_class, holder, version, method, bci, source, source_file, line_number, CHECK);

int line_number = Backtrace::get_line_number(method(), bci);
java_lang_StackTraceElement::set_fileName(element(), source_file);
java_lang_StackTraceElement::set_lineNumber(element(), line_number);
}
}

#if INCLUDE_JVMCI
void java_lang_StackTraceElement::decode(Handle mirror, methodHandle method, int bci, Symbol*& methodname, Symbol*& filename, int& line_number) {
int method_id = method->orig_method_idnum();
int cpref = method->name_index();
decode(mirror, method_id, method->constants()->version(), bci, cpref, methodname, filename, line_number);
void java_lang_StackTraceElement::decode_file_and_line(Handle java_class,
InstanceKlass* holder,
int version,
const methodHandle& method,
int bci,
Symbol*& source,
oop& source_file,
int& line_number, TRAPS) {
// Fill in source file name and line number.
source = Backtrace::get_source_file_name(holder, version);
source_file = java_lang_Class::source_file(java_class());
if (source != NULL) {
// Class was not redefined. We can trust its cache if set,
// else we have to initialize it.
if (source_file == NULL) {
source_file = StringTable::intern(source, CHECK);
java_lang_Class::set_source_file(java_class(), source_file);
}
} else {
// Class was redefined. Dump the cache if it was set.
if (source_file != NULL) {
source_file = NULL;
java_lang_Class::set_source_file(java_class(), source_file);
}
}
line_number = Backtrace::get_line_number(method(), bci);
}

void java_lang_StackTraceElement::decode(Handle mirror, int method_id, int version, int bci, int cpref, Symbol*& methodname, Symbol*& filename, int& line_number) {
// Fill in class name
InstanceKlass* holder = InstanceKlass::cast(java_lang_Class::as_Klass(mirror()));
Method* method = holder->method_with_orig_idnum(method_id, version);

// The method can be NULL if the requested class version is gone
Symbol* sym = (method != NULL) ? method->name() : holder->constants()->symbol_at(cpref);
#if INCLUDE_JVMCI
void java_lang_StackTraceElement::decode(const methodHandle& method, int bci,
Symbol*& filename, int& line_number, TRAPS) {
ResourceMark rm(THREAD);
HandleMark hm(THREAD);

// Fill in method name
methodname = sym;
filename = NULL;
line_number = -1;

if (!version_matches(method, version)) {
// If the method was redefined, accurate line number information isn't available
filename = NULL;
line_number = -1;
} else {
// Fill in source file name and line number.
// Use a specific ik version as a holder since the mirror might
// refer to a version that is now obsolete and no longer accessible
// via the previous versions list.
holder = holder->get_klass_version(version);
assert(holder != NULL, "sanity check");
filename = holder->source_file_name();
line_number = Backtrace::get_line_number(method, bci);
}
oop source_file;
int version = method->constants()->version();
InstanceKlass* holder = method->method_holder();
Handle java_class(THREAD, holder->java_mirror());
decode_file_and_line(java_class, holder, version, method, bci, filename, source_file, line_number, CHECK);
}
#endif // INCLUDE_JVMCI

@@ -1401,6 +1401,10 @@ class java_lang_StackTraceElement: AllStatic {
static void set_lineNumber(oop element, int value);
static void set_declaringClassObject(oop element, oop value);

static void decode_file_and_line(Handle java_mirror, InstanceKlass* holder, int version,
const methodHandle& method, int bci,
Symbol*& source, oop& source_file, int& line_number, TRAPS);

public:
// Create an instance of StackTraceElement
static oop create(const methodHandle& method, int bci, TRAPS);
@@ -1412,8 +1416,7 @@ class java_lang_StackTraceElement: AllStatic {
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;

#if INCLUDE_JVMCI
static void decode(Handle mirror, int method, int version, int bci, int cpref, Symbol*& methodName, Symbol*& fileName, int& lineNumber);
static void decode(Handle mirror, methodHandle method, int bci, Symbol*& methodName, Symbol*& fileName, int& lineNumber);
static void decode(const methodHandle& method, int bci, Symbol*& fileName, int& lineNumber, TRAPS);
#endif

// Debugging
@@ -898,12 +898,11 @@ JVMCIObject JVMCIEnv::get_jvmci_primitive_type(BasicType type) {

JVMCIObject JVMCIEnv::new_StackTraceElement(const methodHandle& method, int bci, JVMCI_TRAPS) {
JavaThread* THREAD = JavaThread::current();
Symbol* method_name_sym;
Symbol* file_name_sym;
int line_number;
Handle mirror (THREAD, method->method_holder()->java_mirror());
java_lang_StackTraceElement::decode(mirror, method, bci, method_name_sym, file_name_sym, line_number);
java_lang_StackTraceElement::decode(method, bci, file_name_sym, line_number, CHECK_(JVMCIObject()));

Symbol* method_name_sym = method->name();
InstanceKlass* holder = method->method_holder();
const char* declaring_class_str = holder->external_name();

0 comments on commit 41b4803

Please sign in to comment.
You can’t perform that action at this time.