Insert Special Code Sequence After Object allocation
Krystal Mok
rednaxelafx at gmail.com
Wed Nov 28 22:09:39 PST 2012
Simply specify -XX:-UseTLAB on the command line, or change its default
value in runtime/globals.hpp will do.
- Kris
On Wed, Nov 28, 2012 at 3:20 PM, Xin Tong <xerox.time.tech at gmail.com> wrote:
> Is there a way to turn off UseTLAB BTW ? it is turned on by default here.
> void PhaseMacroExpand::expand_allocate_common(
> AllocateNode* alloc, // allocation node to be expanded
> Node* length, // array length for an array allocation
> const TypeFunc* slow_call_type, // Type of slow call
> address slow_call_address // Address of slow call
> )
>
> {
> ...
> printf("UseTLAB is %d\n", UseTLAB);
> if (C->env()->dtrace_alloc_probes() ||
> !UseTLAB && (!Universe::heap()->supports_inline_contig_alloc() ||
> (UseConcMarkSweepGC && CMSIncrementalMode))) {
> // Force slow-path allocation
> printf("Force slow-path allocation\n");
> always_slow = true;
> initial_slow_test = NULL;
> }
> ...
> }
>
>
>
> Xin
>
> On Wed, Nov 28, 2012 at 1:51 AM, Xin Tong <xerox.time.tech at gmail.com> wrote:
>> On Wed, Nov 28, 2012 at 1:35 AM, Krystal Mo <krystal.mo at oracle.com> wrote:
>>> On 11/28/2012 02:02 PM, Xin Tong wrote:
>>>>
>>>> On Wed, Nov 28, 2012 at 12:58 AM, Xin Tong <xerox.time.tech at gmail.com>
>>>> wrote:
>>>>>
>>>>> On Tue, Nov 27, 2012 at 11:23 PM, Krystal Mo <krystal.mo at oracle.com>
>>>>> wrote:
>>>>>>
>>>>>> Hi Xin,
>>>>>>
>>>>>> Depends on what the code sequence is and what it does.
>>>>>>
>>>>>> If the code sequence you're inserting can be represented in C2's IR
>>>>>> nodes,
>>>>>> then you can try to add those nodes in either
>>>>>> PhaseMacroExpand::expand_allocate_common() or
>>>>>> PhaseMacroExpand::initialize_object(), or somewhere else around.
>>>>>>
>>>>> It is a few assembly instructions. can i wrap the assemblies in a
>>>>> function that hasa prologue and epilogue to save everything. and does
>>>>> the IR has any way of calling a function ?
>>>>>
>>>>> Xin
>>>>
>>>> Or another thing i am willing to do is to force the JIT to always fail
>>>> on the inlined allocation and force it to the out-of-line ( VM
>>>> managed) allocation. I just do not want to turn the JIT completely off
>>>> as that have an big impact on the behaviours of the program. Is this
>>>> doable ?
>>>
>>> Sure, if you're willing take the performance hit.
>>>
>>> It's easy: in PhaseMacroExpand::expand_allocate_common(), just make sure the
>>> local variables initial_slow_test and always_slow are assigned NULL and true
>>> respectively, and there you go. It'll call into
>>> OptoRuntime::new_instance_C().
>>>
>>
>> I change the bool always_slow = true; it runs ok. but when i change
>> Node* initial_slow_test = NULL ;
>> //alloc->in(AllocateNode::InitialTest);
>> the VM crashes. Is it necessary to make initial_slow_test to NULL ? is
>> not initial_slow_test used to initialize allocattion from slow path ?
>>
>> # A fatal error has been detected by the Java Runtime Environment:
>> #
>> # SIGSEGV (0xb) at pc=0x00007fd6d0e58572, pid=18333, tid=140560399947520
>> #
>> # JRE version: 7.0
>> # Java VM: OpenJDK 64-Bit Server VM (23.2-b09 mixed mode linux-amd64
>> compressed oops)
>> # Problematic frame:
>> # V [libjvm.so+0x7b6572] BoolNode::make_predicate(Node*, PhaseGVN*)+0x22
>> #
>> # Failed to write core dump. Core dumps have been disabled. To enable
>> core dumping, try "ulimit -c unlimited" before starting Java again
>> #
>> # An error report file with more information is saved as:
>> # /home/xtong/fastcache/benchmarks/SPECJBB2005/hs_err_pid18333.log
>> #
>> # If you would like to submit a bug report, please visit:
>> # http://bugreport.sun.com/bugreport/crash.jsp
>> #
>> ./run.sh: line 13: 18333 Aborted (core dumped) java
>> -Xms1024m -Xmx2048m spec.jbb.JBBmain -propfile SPECjbb.props
>>
>>
>> Xin
>>
>>
>>
>>> - Kris
>>>
>>>
>>>> Xin
>>>>
>>>>>> If your code sequence cannot be represented in C2's IR, well, that will
>>>>>> take
>>>>>> some effort. The AllocateNode is lost after PhaseMacroExpand, so you
>>>>>> can't
>>>>>> use it as a mark to insert your code. You might want to use
>>>>>> prefetchAlloc in
>>>>>> the AD files as a place to insert code, if that works for your purpose.
>>>>>>
>>>>>> That said, though, if the code sequence could be written in Java
>>>>>> bytecode,
>>>>>> that'll be the easiest solution: don't have to touch the VM, just do
>>>>>> bytecode instrumentation.
>>>>>>
>>>>>> - Kris
>>>>>>
>>>>>>
>>>>>> On 2012/11/28 10:36, Xin Tong wrote:
>>>>>>>
>>>>>>> I would like to insert a special binary code sequence after the
>>>>>>> allocation of a java object in the opto JIT code. can anyone tell me
>>>>>>> how to do that ?
>>>>>>>
>>>>>>> Xin
>>>
>>>
More information about the hotspot-compiler-dev
mailing list