< prev index next >

src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp

Print this page

   1 /*
   2  * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved.
   4  * Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved.
   5  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   6  *
   7  * This code is free software; you can redistribute it and/or modify it
   8  * under the terms of the GNU General Public License version 2 only, as
   9  * published by the Free Software Foundation.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any

1406 
1407   JFR_ONLY(__ leave_jfr_critical_section();)
1408 
1409   // restore sender sp
1410   __ mv(sp, esp);
1411 
1412   __ ret();
1413 
1414   if (inc_counter) {
1415     // Handle overflow of counter and compile method
1416     __ bind(invocation_counter_overflow);
1417     generate_counter_overflow(continue_after_compile);
1418   }
1419 
1420   return entry_point;
1421 }
1422 
1423 //
1424 // Generic interpreted method entry to (asm) interpreter
1425 //
1426 address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) {
1427 
1428   // determine code generation flags
1429   const bool inc_counter  = UseCompiler || CountCompiledCalls;
1430 
1431   // t0: sender sp
1432   address entry_point = __ pc();
1433 
1434   const Address constMethod(xmethod, Method::const_offset());
1435   const Address access_flags(xmethod, Method::access_flags_offset());
1436   const Address size_of_parameters(x13,
1437                                    ConstMethod::size_of_parameters_offset());
1438   const Address size_of_locals(x13, ConstMethod::size_of_locals_offset());
1439 
1440   // get parameter size (always needed)
1441   // need to load the const method first
1442   __ ld(x13, constMethod);
1443   __ load_unsigned_short(x12, size_of_parameters);
1444 
1445   // x12: size of parameters
1446 

1519 
1520   bang_stack_shadow_pages(false);
1521 
1522   // reset the _do_not_unlock_if_synchronized flag
1523   __ sb(zr, do_not_unlock_if_synchronized);
1524 
1525   // check for synchronized methods
1526   // Must happen AFTER invocation_counter check and stack overflow check,
1527   // so method is not locked if overflows.
1528   if (synchronized) {
1529     // Allocate monitor and lock method
1530     lock_method();
1531   } else {
1532     // no synchronization necessary
1533 #ifdef ASSERT
1534     __ load_unsigned_short(x10, access_flags);
1535     __ verify_access_flags(x10, JVM_ACC_SYNCHRONIZED, "method needs synchronization");
1536 #endif
1537   }
1538 






1539   // start execution
1540   __ verify_frame_setup();
1541 
1542   // jvmti support
1543   __ notify_method_entry();
1544 
1545   __ dispatch_next(vtos);
1546 
1547   // invocation counter overflow
1548   if (inc_counter) {
1549     // Handle overflow of counter and compile method
1550     __ bind(invocation_counter_overflow);
1551     generate_counter_overflow(continue_after_compile);
1552   }
1553 
1554   return entry_point;
1555 }
1556 
1557 // Method entry for java.lang.Thread.currentThread
1558 address TemplateInterpreterGenerator::generate_currentThread() {

   1 /*
   2  * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved.
   4  * Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved.
   5  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   6  *
   7  * This code is free software; you can redistribute it and/or modify it
   8  * under the terms of the GNU General Public License version 2 only, as
   9  * published by the Free Software Foundation.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any

1406 
1407   JFR_ONLY(__ leave_jfr_critical_section();)
1408 
1409   // restore sender sp
1410   __ mv(sp, esp);
1411 
1412   __ ret();
1413 
1414   if (inc_counter) {
1415     // Handle overflow of counter and compile method
1416     __ bind(invocation_counter_overflow);
1417     generate_counter_overflow(continue_after_compile);
1418   }
1419 
1420   return entry_point;
1421 }
1422 
1423 //
1424 // Generic interpreted method entry to (asm) interpreter
1425 //
1426 address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized, bool object_init) {
1427 
1428   // determine code generation flags
1429   const bool inc_counter  = UseCompiler || CountCompiledCalls;
1430 
1431   // t0: sender sp
1432   address entry_point = __ pc();
1433 
1434   const Address constMethod(xmethod, Method::const_offset());
1435   const Address access_flags(xmethod, Method::access_flags_offset());
1436   const Address size_of_parameters(x13,
1437                                    ConstMethod::size_of_parameters_offset());
1438   const Address size_of_locals(x13, ConstMethod::size_of_locals_offset());
1439 
1440   // get parameter size (always needed)
1441   // need to load the const method first
1442   __ ld(x13, constMethod);
1443   __ load_unsigned_short(x12, size_of_parameters);
1444 
1445   // x12: size of parameters
1446 

1519 
1520   bang_stack_shadow_pages(false);
1521 
1522   // reset the _do_not_unlock_if_synchronized flag
1523   __ sb(zr, do_not_unlock_if_synchronized);
1524 
1525   // check for synchronized methods
1526   // Must happen AFTER invocation_counter check and stack overflow check,
1527   // so method is not locked if overflows.
1528   if (synchronized) {
1529     // Allocate monitor and lock method
1530     lock_method();
1531   } else {
1532     // no synchronization necessary
1533 #ifdef ASSERT
1534     __ load_unsigned_short(x10, access_flags);
1535     __ verify_access_flags(x10, JVM_ACC_SYNCHRONIZED, "method needs synchronization");
1536 #endif
1537   }
1538 
1539   // Issue a StoreStore barrier on entry to Object_init if the
1540   // class has strict field fields.  Be lazy, always do it.
1541   if (object_init) {
1542     __ membar(MacroAssembler::StoreStore);
1543   }
1544 
1545   // start execution
1546   __ verify_frame_setup();
1547 
1548   // jvmti support
1549   __ notify_method_entry();
1550 
1551   __ dispatch_next(vtos);
1552 
1553   // invocation counter overflow
1554   if (inc_counter) {
1555     // Handle overflow of counter and compile method
1556     __ bind(invocation_counter_overflow);
1557     generate_counter_overflow(continue_after_compile);
1558   }
1559 
1560   return entry_point;
1561 }
1562 
1563 // Method entry for java.lang.Thread.currentThread
1564 address TemplateInterpreterGenerator::generate_currentThread() {
< prev index next >