571
572 // compute auxiliary field attributes
573 TosState state = as_TosState(info.field_type());
574
575 // We need to delay resolving put instructions on final fields
576 // until we actually invoke one. This is required so we throw
577 // exceptions at the correct place. If we do not resolve completely
578 // in the current pass, leaving the put_code set to zero will
579 // cause the next put instruction to reresolve.
580 Bytecodes::Code put_code = (Bytecodes::Code)0;
581
582 // We also need to delay resolving getstatic instructions until the
583 // class is intitialized. This is required so that access to the static
584 // field will call the initialization function every time until the class
585 // is completely initialized ala. in 2.17.5 in JVM Specification.
586 InstanceKlass* klass = InstanceKlass::cast(info.field_holder());
587 bool uninitialized_static = ((bytecode == Bytecodes::_getstatic || bytecode == Bytecodes::_putstatic) &&
588 !klass->is_initialized());
589 Bytecodes::Code get_code = (Bytecodes::Code)0;
590
591 if (!uninitialized_static) {
592 get_code = ((is_static) ? Bytecodes::_getstatic : Bytecodes::_getfield);
593 if (is_put || !info.access_flags().is_final()) {
594 put_code = ((is_static) ? Bytecodes::_putstatic : Bytecodes::_putfield);
595 }
596 }
597
598 cp_cache_entry->set_field(
599 get_code,
600 put_code,
601 info.field_holder(),
602 info.index(),
603 info.offset(),
604 state,
605 info.access_flags().is_final(),
606 info.access_flags().is_volatile(),
607 pool->pool_holder()
608 );
609 }
610
611
612 //------------------------------------------------------------------------------------------------------------------------
613 // Synchronization
614 //
615 // The interpreter's synchronization code is factored out so that it can
616 // be shared by method invocation and synchronized blocks.
617 //%note synchronization_3
618
619 //%note monitor_1
620 IRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* thread, BasicObjectLock* elem))
621 #ifdef ASSERT
622 thread->last_frame().interpreter_frame_verify_monitor(elem);
623 #endif
624 if (PrintBiasedLockingStatistics) {
625 Atomic::inc(BiasedLocking::slow_path_entry_count_addr());
626 }
627 Handle h_obj(thread, elem->obj());
628 assert(Universe::heap()->is_in_reserved_or_null(h_obj()),
|
571
572 // compute auxiliary field attributes
573 TosState state = as_TosState(info.field_type());
574
575 // We need to delay resolving put instructions on final fields
576 // until we actually invoke one. This is required so we throw
577 // exceptions at the correct place. If we do not resolve completely
578 // in the current pass, leaving the put_code set to zero will
579 // cause the next put instruction to reresolve.
580 Bytecodes::Code put_code = (Bytecodes::Code)0;
581
582 // We also need to delay resolving getstatic instructions until the
583 // class is intitialized. This is required so that access to the static
584 // field will call the initialization function every time until the class
585 // is completely initialized ala. in 2.17.5 in JVM Specification.
586 InstanceKlass* klass = InstanceKlass::cast(info.field_holder());
587 bool uninitialized_static = ((bytecode == Bytecodes::_getstatic || bytecode == Bytecodes::_putstatic) &&
588 !klass->is_initialized());
589 Bytecodes::Code get_code = (Bytecodes::Code)0;
590
591
592 if (info.is_accessor()) {
593 // If it is an accessor (not a real field) change bytecode
594 // semantic to be a call to the accessor-method)
595 InstanceKlass* current_klass = method(thread)->method_holder();
596 // find method based on get/put
597 Method* m = klass->method_with_idnum(is_put
598 ? info.get_put_accessor()
599 : info.get_get_accessor()
600 );
601
602 // Create a linkinfo to resolve the method
603 LinkInfo linfo(klass,m->name(),m->signature(),current_klass,true);
604
605 // Resolve static/non-static method and initialize cp_cache_entry
606 // accordingly
607 if (is_static) {
608 methodHandle mh = LinkResolver::resolve_static_call_or_null(linfo);
609 cp_cache_entry->set_direct_call(
610 Bytecodes::_invokestatic,
611 mh);
612 }else {
613 methodHandle mh = LinkResolver::resolve_virtual_call_or_null(klass,linfo);
614 cp_cache_entry->set_vtable_call(
615 Bytecodes::_invokevirtual,
616 mh,
617 m->vtable_index());
618 }
619
620 }else {
621 if (!uninitialized_static) {
622 get_code = ((is_static) ? Bytecodes::_getstatic : Bytecodes::_getfield);
623 if (is_put || !info.access_flags().is_final()) {
624 put_code = ((is_static) ? Bytecodes::_putstatic : Bytecodes::_putfield);
625 }
626 }
627
628 cp_cache_entry->set_field(
629 get_code,
630 put_code,
631 info.field_holder(),
632 info.index(),
633 info.offset(),
634 state,
635 info.access_flags().is_final(),
636 info.access_flags().is_volatile(),
637 pool->pool_holder()
638 );
639 }
640 }
641
642
643 //------------------------------------------------------------------------------------------------------------------------
644 // Synchronization
645 //
646 // The interpreter's synchronization code is factored out so that it can
647 // be shared by method invocation and synchronized blocks.
648 //%note synchronization_3
649
650 //%note monitor_1
651 IRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* thread, BasicObjectLock* elem))
652 #ifdef ASSERT
653 thread->last_frame().interpreter_frame_verify_monitor(elem);
654 #endif
655 if (PrintBiasedLockingStatistics) {
656 Atomic::inc(BiasedLocking::slow_path_entry_count_addr());
657 }
658 Handle h_obj(thread, elem->obj());
659 assert(Universe::heap()->is_in_reserved_or_null(h_obj()),
|