intrinsic that makes runtime choice whether to revert to java

Deneau, Tom tom.deneau at
Fri Jul 6 14:01:19 PDT 2012

Vladimir --

Having gotten past the gen_instanceof problem, I am now hitting
the following which I don't understand:

I have copied the template you provided in your webrev shown below, but when
I call generate_guard, I am hitting the following exit condition.  Any suggestions?

  // Build an if node and its projections.
  // If test is true we take the slow path, which we assume is uncommon.
  if (_gvn.type(test) == TypeInt::ZERO) {
    // The slow branch is never taken.  No need to build this guard.
    return NULL;

-- Tom

+   _sp += nargs;          // gen_instanceof might do an uncommon trap
+   Node* inst = gen_instanceof(val, makecon(TypeKlassPtr::make(klass)));
+   _sp -= nargs;
+   Node* cmp  = _gvn.transform(new (C, 3) CmpINode(inst, intcon(1)));
+   Node* bol  = _gvn.transform(new (C, 2) BoolNode(cmp, BoolTest::ne));
+   Node* inst_false = generate_guard(bol, NULL, PROB_MIN);
+   //instanceOf == true, fallthrough
+   return inst_false;

a SEGV when PredictedIntrinsicGenerator::generate() has called 
  Node* slow_ctl = _intrinsic->generate_predicate(kit.sync_jvms());

-----Original Message-----
From: Vladimir Kozlov [mailto:vladimir.kozlov at] 
Sent: Monday, July 02, 2012 9:57 PM
To: Deneau, Tom
Cc: hotspot-compiler-dev at
Subject: Re: intrinsic that makes runtime choice whether to revert to java

I finally had time today to look on this. Here is code:

But I did not test or optimize it (part of new code in callGenerator.cpp should 
be shared with PredictedCallGenerator from which it was cloned).


Deneau, Tom wrote:
> Hi all --
> I am writing a hotspot intrinsic but I want it to make a runtime
> choice whether to execute the intrinsic code or to execute the regular
> java code.
> I got the suggestion below from Vladimir but I am not experienced
> enough with the graphkit functionality to see how to do this.  Would
> someone be able to provide the code skeleton for this?  I can generate
> the region to actually do my intrinsic and I believe I can generate the
> BoolNode which determines which path to take.
> The other choice would be to modify the actual JDK library routine to
> do the runtime tests and call a new routine which the intrinsic would
> hook into.  I have done this for testing but I am assuming this is more
> intrusive since on some architectures the intrinsic will not even be generated.
> -- Tom Deneau
>> We don't have such mechanism currently. But it is not difficult to implement. 
>> Look on the code in doCall.cpp and callGenerator files. Instead of calling 
>> find_intrinsic() you need to do something special for your case. Like code for 
>> CallGenerator::for_method_handle_call() where you will generate class check and 
>> on one path you will get intrinsic (by calling find_intrinsic()) and on other 
>> path is regular CallGenerator::for_inline().

More information about the hotspot-compiler-dev mailing list