575
576 // compute auxiliary field attributes
577 TosState state = as_TosState(info.field_type());
578
579 // We need to delay resolving put instructions on final fields
580 // until we actually invoke one. This is required so we throw
581 // exceptions at the correct place. If we do not resolve completely
582 // in the current pass, leaving the put_code set to zero will
583 // cause the next put instruction to reresolve.
584 Bytecodes::Code put_code = (Bytecodes::Code)0;
585
586 // We also need to delay resolving getstatic instructions until the
587 // class is intitialized. This is required so that access to the static
588 // field will call the initialization function every time until the class
589 // is completely initialized ala. in 2.17.5 in JVM Specification.
590 InstanceKlass* klass = InstanceKlass::cast(info.field_holder());
591 bool uninitialized_static = ((bytecode == Bytecodes::_getstatic || bytecode == Bytecodes::_putstatic) &&
592 !klass->is_initialized());
593 Bytecodes::Code get_code = (Bytecodes::Code)0;
594
595 if (!uninitialized_static) {
596 get_code = ((is_static) ? Bytecodes::_getstatic : Bytecodes::_getfield);
597 if (is_put || !info.access_flags().is_final()) {
598 put_code = ((is_static) ? Bytecodes::_putstatic : Bytecodes::_putfield);
599 }
600 }
601
602 cp_cache_entry->set_field(
603 get_code,
604 put_code,
605 info.field_holder(),
606 info.index(),
607 info.offset(),
608 state,
609 info.access_flags().is_final(),
610 info.access_flags().is_volatile(),
611 pool->pool_holder()
612 );
613 }
614
615
616 //------------------------------------------------------------------------------------------------------------------------
617 // Synchronization
|
575
576 // compute auxiliary field attributes
577 TosState state = as_TosState(info.field_type());
578
579 // We need to delay resolving put instructions on final fields
580 // until we actually invoke one. This is required so we throw
581 // exceptions at the correct place. If we do not resolve completely
582 // in the current pass, leaving the put_code set to zero will
583 // cause the next put instruction to reresolve.
584 Bytecodes::Code put_code = (Bytecodes::Code)0;
585
586 // We also need to delay resolving getstatic instructions until the
587 // class is intitialized. This is required so that access to the static
588 // field will call the initialization function every time until the class
589 // is completely initialized ala. in 2.17.5 in JVM Specification.
590 InstanceKlass* klass = InstanceKlass::cast(info.field_holder());
591 bool uninitialized_static = ((bytecode == Bytecodes::_getstatic || bytecode == Bytecodes::_putstatic) &&
592 !klass->is_initialized());
593 Bytecodes::Code get_code = (Bytecodes::Code)0;
594
595 /* Do not cache the result of the resolution for putfield instructions
596 * to instance final fields.
597 *
598 * A putfield instruction targeting an instance final field must throw
599 * an IllegalAccessError if the instruction is not in an instance
600 * initializer method <init>. Without the check below, a putfield
601 * in an initializer method is resolved; subsequent putfield instructions
602 * to the same field then use cached information and thus do not pass
603 * through the VM (i.e., checks will not be executed for those instructions).
604 */
605 bool final_instance_update = info.field_holder()->major_version() >= 53 &&
606 info.has_initialized_final_update() &&
607 (bytecode == Bytecodes::_putfield || bytecode == Bytecodes::_nofast_putfield);
608
609
610 if (!uninitialized_static) {
611 get_code = ((is_static) ? Bytecodes::_getstatic : Bytecodes::_getfield);
612 if ((is_put && !final_instance_update) || !info.access_flags().is_final()) {
613 put_code = ((is_static) ? Bytecodes::_putstatic : Bytecodes::_putfield);
614 }
615 }
616
617 cp_cache_entry->set_field(
618 get_code,
619 put_code,
620 info.field_holder(),
621 info.index(),
622 info.offset(),
623 state,
624 info.access_flags().is_final(),
625 info.access_flags().is_volatile(),
626 pool->pool_holder()
627 );
628 }
629
630
631 //------------------------------------------------------------------------------------------------------------------------
632 // Synchronization
|