(10) RFR (actually S) 8169881: Remove implicit Handle conversions oop->Handle
serguei.spitsyn at oracle.com
serguei.spitsyn at oracle.com
Wed Feb 15 20:36:24 UTC 2017
On 2/15/17 10:42, coleen.phillimore at oracle.com wrote:
> Thank you Serguei, one tiny comment below.
>
> On 2/15/17 11:50 AM, serguei.spitsyn at oracle.com wrote:
>> Coleen,
>>
>>
>> On 2/15/17 07:43, coleen.phillimore at oracle.com wrote:
>>>
>>> Hi Serguei, Thank you for reviewing this.
>>>
>>> On 2/15/17 2:18 AM, serguei.spitsyn at oracle.com wrote:
. . .
>>>>
>>>> http://cr.openjdk.java.net/~coleenp/8169881.02/webrev/src/share/vm/jvmci/jvmciCompilerToVM.cpp.udiff.html
>>>>
>>>>
>>>> Handle result;
>>>> if (!klass.is_null()) {
>>>> - result = CompilerToVM::get_jvmci_type(klass, CHECK_NULL);
>>>> + oop result_oop = CompilerToVM::get_jvmci_type(klass, CHECK_NULL);
>>>> + result = Handle(THREAD, result_oop);
>>>> } else {
>>>> result = java_lang_String::create_from_symbol(symbol,
>>>> CHECK_NULL);
>>>> }
>>>> return JNIHandles::make_local(THREAD, result());
>>>>
>>>>
>>>> Not clear, why does the result need to be a handle.
>>>>
>>>
>>> There's no reason this had to be a Handle, but
>>> java_lang_String::create_from_symbol returns a Handle. That's
>>> why. This seems better, agree?
>>>
>>> oop result_oop;
>>> if (!klass.is_null()) {
>>> oop result_oop = CompilerToVM::get_jvmci_type(klass, CHECK_NULL);
>>> } else {
>>> Handle result = java_lang_String::create_from_symbol(symbol,
>>> CHECK_NULL);
>>> result_oop = result();
>>> }
>>> return JNIHandles::make_local(THREAD, result_oop);
>>
>> Agreed.
>> Alternatively, this can be used:
>> result_oop = java_lang_String::create_from_symbol(symbol,
>> CHECK_NULL)();
>>
>
> The function create_from_symbol returns a Handle. It seems like it'd
> be better for all functions to pass Handle but return oops, but there
> are some that return Handle because the last argument is CHECK which
> becomes:
>
> THREAD); if (HAS_PENDING_EXCEPTION) {
> return NULL;
> }
>
> And if you try to Handle the result in one statement, like this:
>
> result = Handle(THREAD,
> java_lang_String::create_from_symbol(symbol, CHECK_NULL));
>
> it won't compile because of the CHECK_NULL.
> So we made many functions like this return Handle.
Ok, thanks.
Serguei
>
> Thanks,
> Coleen
More information about the hotspot-dev
mailing list