< prev index next >

src/hotspot/cpu/zero/zeroInterpreter_zero.cpp

Print this page

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

565   //  0:  aload_0
566   //  1:  getfield
567   //  2:    index
568   //  3:    index
569   //  4:  return
570   //
571   // NB this is not raw bytecode: index is in machine order
572 
573   assert(method->is_getter(), "Expect the particular bytecode shape");
574   u1* code = method->code_base();
575   u2 index = Bytes::get_native_u2(&code[2]);
576 
577   // Get the entry from the constant pool cache, and drop into
578   // the slow path if it has not been resolved
579   ConstantPoolCache* cache = method->constants()->cache();
580   ResolvedFieldEntry* entry = cache->resolved_field_entry_at(index);
581   if (!entry->is_resolved(Bytecodes::_getfield)) {
582     return normal_entry(method, 0, THREAD);
583   }
584 






585   ZeroStack* stack = thread->zero_stack();
586   intptr_t* topOfStack = stack->sp();
587 
588   // Load the object pointer and drop into the slow path
589   // if we have a NullPointerException
590   oop object = STACK_OBJECT(0);
591   if (object == nullptr) {
592     return normal_entry(method, 0, THREAD);
593   }
594 
595   // If needed, allocate additional slot on stack: we already have one
596   // for receiver, and double/long need another one.
597   switch (entry->tos_state()) {
598     case ltos:
599     case dtos:
600       stack->overflow_check(1, CHECK_0);
601       stack->alloc(wordSize);
602       topOfStack = stack->sp();
603       break;
604     default:

656   //  1:  *load_1
657   //  2:  putfield
658   //  3:    index
659   //  4:    index
660   //  5:  return
661   //
662   // NB this is not raw bytecode: index is in machine order
663 
664   assert(method->is_setter(), "Expect the particular bytecode shape");
665   u1* code = method->code_base();
666   u2 index = Bytes::get_native_u2(&code[3]);
667 
668   // Get the entry from the constant pool cache, and drop into
669   // the slow path if it has not been resolved
670   ConstantPoolCache* cache = method->constants()->cache();
671   ResolvedFieldEntry* entry = cache->resolved_field_entry_at(index);
672   if (!entry->is_resolved(Bytecodes::_putfield)) {
673     return normal_entry(method, 0, THREAD);
674   }
675 






676   ZeroStack* stack = thread->zero_stack();
677   intptr_t* topOfStack = stack->sp();
678 
679   // Figure out where the receiver is. If there is a long/double
680   // operand on stack top, then receiver is two slots down.
681   oop object = nullptr;
682   switch (entry->tos_state()) {
683     case ltos:
684     case dtos:
685       object = STACK_OBJECT(-2);
686       break;
687     default:
688       object = STACK_OBJECT(-1);
689       break;
690   }
691 
692   // Load the receiver pointer and drop into the slow path
693   // if we have a NullPointerException
694   if (object == nullptr) {
695     return normal_entry(method, 0, THREAD);

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

565   //  0:  aload_0
566   //  1:  getfield
567   //  2:    index
568   //  3:    index
569   //  4:  return
570   //
571   // NB this is not raw bytecode: index is in machine order
572 
573   assert(method->is_getter(), "Expect the particular bytecode shape");
574   u1* code = method->code_base();
575   u2 index = Bytes::get_native_u2(&code[2]);
576 
577   // Get the entry from the constant pool cache, and drop into
578   // the slow path if it has not been resolved
579   ConstantPoolCache* cache = method->constants()->cache();
580   ResolvedFieldEntry* entry = cache->resolved_field_entry_at(index);
581   if (!entry->is_resolved(Bytecodes::_getfield)) {
582     return normal_entry(method, 0, THREAD);
583   }
584 
585   // Flattened entries require handling beyond a direct field load.
586   // Bail to slow path.
587   if (entry->is_flat()) {
588     return normal_entry(method, 0, THREAD);
589   }
590 
591   ZeroStack* stack = thread->zero_stack();
592   intptr_t* topOfStack = stack->sp();
593 
594   // Load the object pointer and drop into the slow path
595   // if we have a NullPointerException
596   oop object = STACK_OBJECT(0);
597   if (object == nullptr) {
598     return normal_entry(method, 0, THREAD);
599   }
600 
601   // If needed, allocate additional slot on stack: we already have one
602   // for receiver, and double/long need another one.
603   switch (entry->tos_state()) {
604     case ltos:
605     case dtos:
606       stack->overflow_check(1, CHECK_0);
607       stack->alloc(wordSize);
608       topOfStack = stack->sp();
609       break;
610     default:

662   //  1:  *load_1
663   //  2:  putfield
664   //  3:    index
665   //  4:    index
666   //  5:  return
667   //
668   // NB this is not raw bytecode: index is in machine order
669 
670   assert(method->is_setter(), "Expect the particular bytecode shape");
671   u1* code = method->code_base();
672   u2 index = Bytes::get_native_u2(&code[3]);
673 
674   // Get the entry from the constant pool cache, and drop into
675   // the slow path if it has not been resolved
676   ConstantPoolCache* cache = method->constants()->cache();
677   ResolvedFieldEntry* entry = cache->resolved_field_entry_at(index);
678   if (!entry->is_resolved(Bytecodes::_putfield)) {
679     return normal_entry(method, 0, THREAD);
680   }
681 
682   // Flattened entries require handling beyond a direct field store.
683   // Bail to slow path.
684   if (entry->is_flat()) {
685     return normal_entry(method, 0, THREAD);
686   }
687 
688   ZeroStack* stack = thread->zero_stack();
689   intptr_t* topOfStack = stack->sp();
690 
691   // Figure out where the receiver is. If there is a long/double
692   // operand on stack top, then receiver is two slots down.
693   oop object = nullptr;
694   switch (entry->tos_state()) {
695     case ltos:
696     case dtos:
697       object = STACK_OBJECT(-2);
698       break;
699     default:
700       object = STACK_OBJECT(-1);
701       break;
702   }
703 
704   // Load the receiver pointer and drop into the slow path
705   // if we have a NullPointerException
706   if (object == nullptr) {
707     return normal_entry(method, 0, THREAD);
< prev index next >