const char compile_name vs. HS_DTRACE_PROBE?

Vladimir Kozlov vladimir.kozlov at oracle.com
Wed May 8 12:15:56 PDT 2013


Hi, Peter

I filed bug:

https://jbs.oracle.com/bugs/browse/JDK-8014247

thanks,
Vladimir

On 5/8/13 11:26 AM, Peter B. Kessler wrote:
> I can also work around this issue by
>
>      export HOTSPOT_DISABLE_DTRACE_PROBES=1
>
> but that seems like a band-aid.
>
>              ... peter
>
> On 05/06/13 13:14, Peter B. Kessler wrote:
>> CompileBroker::compiler_name(int) is declared[1]
>>
>>        231 // Compilation
>>        232 //
>>        233 // The broker for all compilation requests.
>>        234 class CompileBroker: AllStatic {
>>        ...
>>        422   // compiler name for debugging
>>        423   static const char* compiler_name(int comp_level);
>>        424 };
>>
>> and is used from[2]
>>
>>       1731 // Compile a method.
>>       1732 //
>>       1733 void CompileBroker::invoke_compiler_on_method(CompileTask*
>> task) {
>>       ...
>>       1769     DTRACE_METHOD_COMPILE_BEGIN_PROBE(compiler(task_level),
>> method,
>>       1770
>> compiler_name(task_level));
>>       ...
>>       1850   DTRACE_METHOD_COMPILE_END_PROBE(compiler(task_level),
>> method,
>>       1851
>> compiler_name(task_level), task->is_success());
>>
>> But DTRACE_METHOD_COMPILE_BEGIN_PROBE and
>> DTRACE_METHOD_COMPILE_END_PROBE are "declared" by
>>
>>         95 #define DTRACE_METHOD_COMPILE_BEGIN_PROBE(compiler, method,
>> comp_name)   \
>>         96
>> {                                                                      \
>>        ...                            \
>>        100
>> HOTSPOT_METHOD_COMPILE_BEGIN(                                        \
>>        101       comp_name,
>> strlen(comp_name),                                      \
>>        102       (char *) klass_name->bytes(),
>> klass_name->utf8_length(),           \
>>        103       (char *) name->bytes(),
>> name->utf8_length(),                       \
>>        104       (char *) signature->bytes(),
>> signature->utf8_length());            \
>>        105   }
>>        106
>>        107 #define DTRACE_METHOD_COMPILE_END_PROBE(compiler,
>> method,                \
>>        108                                         comp_name,
>> success)              \
>>        109
>> {                                                                      \
>>        ...                            \
>>        113
>> HOTSPOT_METHOD_COMPILE_END(                                          \
>>        114       comp_name,
>> strlen(comp_name),                                      \
>>        115       (char *) klass_name->bytes(),
>> klass_name->utf8_length(),           \
>>        116       (char *) name->bytes(),
>> name->utf8_length(),                       \
>>        117       (char *) signature->bytes(),
>> signature->utf8_length(), (success)); \
>>        118   }
>>
>> where "comp_name" is passed as the first argument to
>> HOTSPOT_METHOD_COMPILE_BEGIN and HOTSPOT_METHOD_COMPILE_END.  Those
>> are "declared" by
>>
>>         63 HS_DTRACE_PROBE_DECL8(hotspot, method__compile__begin,
>>         64   char*, intptr_t, char*, intptr_t, char*, intptr_t, char*,
>> intptr_t);
>>         65 HS_DTRACE_PROBE_DECL9(hotspot, method__compile__end,
>>         66   char*, intptr_t, char*, intptr_t, char*, intptr_t, char*,
>> intptr_t, bool);
>>
>> where the first argument is a "char*", not a "const char*" (with a
>> step I'm not showing through the translation of hotspot.d to
>> hotspot.h).  I'm getting compile errors on the uses
>>
>>      ..../src/share/vm/compiler/compileBroker.cpp: In static member
>> function 'static void
>> CompileBroker::invoke_compiler_on_method(CompileTask*)':
>>
>>      ..../src/share/vm/compiler/compileBroker.cpp:1789: error: invalid
>> conversion from 'const char*' to 'char*'
>>
>>      ..../src/share/vm/compiler/compileBroker.cpp:1789: error:
>> initializing argument 1 of 'void
>> __dtrace_probe$hotspot$method__compile__begin$v1$63686172202a$75696e747074725f74$63686172202a$75696e747074725f74$63686172202a$75696e747074725f74$63686172202a$75696e747074725f74(char*,
>> uintptr_t, char*, uintptr_t, char*, uintptr_t, char*, uintptr_t)'
>>
>>      ..../src/share/vm/compiler/compileBroker.cpp:1870: error: invalid
>> conversion from 'const char*' to 'char*'
>>
>>      ..../src/share/vm/compiler/compileBroker.cpp:1870: error:
>> initializing argument 1 of 'void
>> __dtrace_probe$hotspot$method__compile__end$v1$63686172202a$75696e747074725f74$63686172202a$75696e747074725f74$63686172202a$75696e747074725f74$63686172202a$75696e747074725f74$75696e747074725f74(char*,
>> uintptr_t, char*, uintptr_t, char*, uintptr_t, char*, uintptr_t,
>> uintptr_t)'
>>
>> How is that code supposed to compile?  This is on MacOSX, and I seem
>> to have DTRACE_ENABLED and USDT2 defined.  The fix seems to be to cast
>> away the const-ness of "comp_name" in the applications of
>> HOTSPOT_METHOD_COMPILE_BEGIN and HOTSPOT_METHOD_COMPILE_END, similar
>> to the way the const-ness is cast away from the other pointer
>> arguments in that call.
>>
>>              ... peter
>>
>> [1]
>> http://hg.openjdk.java.net/jdk8/jdk8/hotspot/file/d0081bfc425c/src/share/vm/compiler/compileBroker.hpp
>>
>> [2]
>> http://hg.openjdk.java.net/jdk8/jdk8/hotspot/file/d0081bfc425c/src/share/vm/compiler/compileBroker.cpp
>>
>>


More information about the hotspot-compiler-dev mailing list