--- old/hotspot/src/share/vm/prims/jvmtiExport.cpp Thu Jan 7 14:58:21 2010 +++ new/hotspot/src/share/vm/prims/jvmtiExport.cpp Thu Jan 7 14:58:21 2010 @@ -1,5 +1,5 @@ /* - * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2010 Sun Microsystems, Inc. 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 @@ -686,11 +686,11 @@ jvmtiAddrLocationMap *_map; const void *_compile_info; public: - JvmtiCompiledMethodLoadEventMark(JavaThread *thread, nmethod *nm) + JvmtiCompiledMethodLoadEventMark(JavaThread *thread, nmethod *nm, void* compile_info_ptr = NULL) : JvmtiMethodEventMark(thread,methodHandle(thread, nm->method())) { _code_data = nm->code_begin(); _code_size = nm->code_size(); - _compile_info = NULL; /* no info for our VM. */ + _compile_info = compile_info_ptr; // Set void pointer of compiledMethodLoad Event. Default value is NULL. JvmtiCodeBlobEvents::build_jvmti_addr_location_map(nm, &_map, &_map_length); } ~JvmtiCompiledMethodLoadEventMark() { @@ -1752,6 +1752,46 @@ } } +// Returns a record containing inlining information for the given nmethod +jvmtiCompiledMethodLoadInlineRecord* create_inline_record(nmethod* nm) { + jint numstackframes = 0; + jvmtiCompiledMethodLoadInlineRecord* record = (jvmtiCompiledMethodLoadInlineRecord*)NEW_RESOURCE_OBJ(jvmtiCompiledMethodLoadInlineRecord); + record->header.kind = JVMTI_CMLR_INLINE_INFO; + record->header.next = NULL; + record->header.majorinfoversion = JVMTI_CMLR_MAJOR_VERSION_1; + record->header.minorinfoversion = JVMTI_CMLR_MINOR_VERSION_0; + record->numpcs = 0; + for(PcDesc* p = nm->scopes_pcs_begin(); p < nm->scopes_pcs_end(); p++) { + if(p->scope_decode_offset() == DebugInformationRecorder::serialized_null) continue; + record->numpcs++; + } + record->pcinfo = (PCStackInfo*)(NEW_RESOURCE_ARRAY(PCStackInfo, record->numpcs)); + int scope = 0; + for(PcDesc* p = nm->scopes_pcs_begin(); p < nm->scopes_pcs_end(); p++) { + if(p->scope_decode_offset() == DebugInformationRecorder::serialized_null) continue; + void* pc_address = (void*)p->real_pc(nm); + assert(pc_address != NULL, "pc_address must be non-null"); + record->pcinfo[scope].pc = pc_address; + numstackframes=0; + for(ScopeDesc* sd = nm->scope_desc_at(p->real_pc(nm));sd != NULL;sd = sd->sender()) { + numstackframes++; + } + assert(numstackframes != 0, "numstackframes must be nonzero."); + record->pcinfo[scope].methods = (jmethodID *)NEW_RESOURCE_ARRAY(jmethodID, numstackframes); + record->pcinfo[scope].bcis = (jint *)NEW_RESOURCE_ARRAY(jint, numstackframes); + record->pcinfo[scope].numstackframes = numstackframes; + int stackframe = 0; + for(ScopeDesc* sd = nm->scope_desc_at(p->real_pc(nm));sd != NULL;sd = sd->sender()) { + // sd->method() can be NULL for stubs but not for nmethods. To be completely robust, include an assert that we should never see a null sd->method() + assert(!sd->method().is_null(), "sd->method() cannot be null."); + record->pcinfo[scope].methods[stackframe] = sd->method()->jmethod_id(); + record->pcinfo[scope].bcis[stackframe] = sd->bci(); + stackframe++; + } + scope++; + } + return record; +} void JvmtiExport::post_compiled_method_load(nmethod *nm) { // If there are pending CompiledMethodUnload events then these are @@ -1780,7 +1820,11 @@ (nm->method() == NULL) ? "NULL" : nm->method()->name()->as_C_string())); ResourceMark rm(thread); - JvmtiCompiledMethodLoadEventMark jem(thread, nm); + + // Add inlining information + jvmtiCompiledMethodLoadInlineRecord* inlinerecord = create_inline_record(nm); + // Pass inlining information through the void pointer + JvmtiCompiledMethodLoadEventMark jem(thread, nm, inlinerecord); JvmtiJavaThreadEventTransition jet(thread); jvmtiEventCompiledMethodLoad callback = env->callbacks()->CompiledMethodLoad; if (callback != NULL) {