src/hotspot/share/runtime/javaCalls.cpp
changeset 55734 51f5b4c29626
parent 54669 ad45b3802d4e
child 58273 08a5148e7c4e
equal deleted inserted replaced
55733:9cfb9387a9e8 55734:51f5b4c29626
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   344   assert(thread->is_Java_thread(), "must be called by a java thread");
   344   assert(thread->is_Java_thread(), "must be called by a java thread");
   345   assert(method.not_null(), "must have a method to call");
   345   assert(method.not_null(), "must have a method to call");
   346   assert(!SafepointSynchronize::is_at_safepoint(), "call to Java code during VM operation");
   346   assert(!SafepointSynchronize::is_at_safepoint(), "call to Java code during VM operation");
   347   assert(!thread->handle_area()->no_handle_mark_active(), "cannot call out to Java here");
   347   assert(!thread->handle_area()->no_handle_mark_active(), "cannot call out to Java here");
   348 
   348 
   349 
       
   350   CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops();)
       
   351 
       
   352 #if INCLUDE_JVMCI
   349 #if INCLUDE_JVMCI
   353   // Gets the nmethod (if any) that should be called instead of normal target
   350   // Gets the nmethod (if any) that should be called instead of normal target
   354   nmethod* alternative_target = args->alternative_target();
   351   nmethod* alternative_target = args->alternative_target();
   355   if (alternative_target == NULL) {
   352   if (alternative_target == NULL) {
   356 #endif
   353 #endif
   392 
   389 
   393   // Figure out if the result value is an oop or not (Note: This is a different value
   390   // Figure out if the result value is an oop or not (Note: This is a different value
   394   // than result_type. result_type will be T_INT of oops. (it is about size)
   391   // than result_type. result_type will be T_INT of oops. (it is about size)
   395   BasicType result_type = runtime_type_from(result);
   392   BasicType result_type = runtime_type_from(result);
   396   bool oop_result_flag = (result->get_type() == T_OBJECT || result->get_type() == T_ARRAY);
   393   bool oop_result_flag = (result->get_type() == T_OBJECT || result->get_type() == T_ARRAY);
   397 
       
   398   // NOTE: if we move the computation of the result_val_address inside
       
   399   // the call to call_stub, the optimizer produces wrong code.
       
   400   intptr_t* result_val_address = (intptr_t*)(result->get_value_addr());
       
   401 
   394 
   402   // Find receiver
   395   // Find receiver
   403   Handle receiver = (!method->is_static()) ? args->receiver() : Handle();
   396   Handle receiver = (!method->is_static()) ? args->receiver() : Handle();
   404 
   397 
   405   // When we reenter Java, we need to reenable the reserved/yellow zone which
   398   // When we reenter Java, we need to reenable the reserved/yellow zone which
   434 
   427 
   435   // do call
   428   // do call
   436   { JavaCallWrapper link(method, receiver, result, CHECK);
   429   { JavaCallWrapper link(method, receiver, result, CHECK);
   437     { HandleMark hm(thread);  // HandleMark used by HandleMarkCleaner
   430     { HandleMark hm(thread);  // HandleMark used by HandleMarkCleaner
   438 
   431 
       
   432       // NOTE: if we move the computation of the result_val_address inside
       
   433       // the call to call_stub, the optimizer produces wrong code.
       
   434       intptr_t* result_val_address = (intptr_t*)(result->get_value_addr());
       
   435       intptr_t* parameter_address = args->parameters();
       
   436 
   439       StubRoutines::call_stub()(
   437       StubRoutines::call_stub()(
   440         (address)&link,
   438         (address)&link,
   441         // (intptr_t*)&(result->_value), // see NOTE above (compiler problem)
   439         // (intptr_t*)&(result->_value), // see NOTE above (compiler problem)
   442         result_val_address,          // see NOTE above (compiler problem)
   440         result_val_address,          // see NOTE above (compiler problem)
   443         result_type,
   441         result_type,
   444         method(),
   442         method(),
   445         entry_point,
   443         entry_point,
   446         args->parameters(),
   444         parameter_address,
   447         args->size_of_parameters(),
   445         args->size_of_parameters(),
   448         CHECK
   446         CHECK
   449       );
   447       );
   450 
   448 
   451       result = link.result();  // circumvent MS C++ 5.0 compiler bug (result is clobbered across call)
   449       result = link.result();  // circumvent MS C++ 5.0 compiler bug (result is clobbered across call)