2690 // Inline static functions for Java Stack and Local manipulation |
2690 // Inline static functions for Java Stack and Local manipulation |
2691 |
2691 |
2692 // The implementations are platform dependent. We have to worry about alignment |
2692 // The implementations are platform dependent. We have to worry about alignment |
2693 // issues on some machines which can change on the same platform depending on |
2693 // issues on some machines which can change on the same platform depending on |
2694 // whether it is an LP64 machine also. |
2694 // whether it is an LP64 machine also. |
2695 #ifdef ASSERT |
|
2696 void BytecodeInterpreter::verify_stack_tag(intptr_t *tos, frame::Tag tag, int offset) { |
|
2697 if (TaggedStackInterpreter) { |
|
2698 frame::Tag t = (frame::Tag)tos[Interpreter::expr_tag_index_at(-offset)]; |
|
2699 assert(t == tag, "stack tag mismatch"); |
|
2700 } |
|
2701 } |
|
2702 #endif // ASSERT |
|
2703 |
|
2704 address BytecodeInterpreter::stack_slot(intptr_t *tos, int offset) { |
2695 address BytecodeInterpreter::stack_slot(intptr_t *tos, int offset) { |
2705 debug_only(verify_stack_tag(tos, frame::TagValue, offset)); |
|
2706 return (address) tos[Interpreter::expr_index_at(-offset)]; |
2696 return (address) tos[Interpreter::expr_index_at(-offset)]; |
2707 } |
2697 } |
2708 |
2698 |
2709 jint BytecodeInterpreter::stack_int(intptr_t *tos, int offset) { |
2699 jint BytecodeInterpreter::stack_int(intptr_t *tos, int offset) { |
2710 debug_only(verify_stack_tag(tos, frame::TagValue, offset)); |
|
2711 return *((jint*) &tos[Interpreter::expr_index_at(-offset)]); |
2700 return *((jint*) &tos[Interpreter::expr_index_at(-offset)]); |
2712 } |
2701 } |
2713 |
2702 |
2714 jfloat BytecodeInterpreter::stack_float(intptr_t *tos, int offset) { |
2703 jfloat BytecodeInterpreter::stack_float(intptr_t *tos, int offset) { |
2715 debug_only(verify_stack_tag(tos, frame::TagValue, offset)); |
|
2716 return *((jfloat *) &tos[Interpreter::expr_index_at(-offset)]); |
2704 return *((jfloat *) &tos[Interpreter::expr_index_at(-offset)]); |
2717 } |
2705 } |
2718 |
2706 |
2719 oop BytecodeInterpreter::stack_object(intptr_t *tos, int offset) { |
2707 oop BytecodeInterpreter::stack_object(intptr_t *tos, int offset) { |
2720 debug_only(verify_stack_tag(tos, frame::TagReference, offset)); |
|
2721 return (oop)tos [Interpreter::expr_index_at(-offset)]; |
2708 return (oop)tos [Interpreter::expr_index_at(-offset)]; |
2722 } |
2709 } |
2723 |
2710 |
2724 jdouble BytecodeInterpreter::stack_double(intptr_t *tos, int offset) { |
2711 jdouble BytecodeInterpreter::stack_double(intptr_t *tos, int offset) { |
2725 debug_only(verify_stack_tag(tos, frame::TagValue, offset)); |
|
2726 debug_only(verify_stack_tag(tos, frame::TagValue, offset-1)); |
|
2727 return ((VMJavaVal64*) &tos[Interpreter::expr_index_at(-offset)])->d; |
2712 return ((VMJavaVal64*) &tos[Interpreter::expr_index_at(-offset)])->d; |
2728 } |
2713 } |
2729 |
2714 |
2730 jlong BytecodeInterpreter::stack_long(intptr_t *tos, int offset) { |
2715 jlong BytecodeInterpreter::stack_long(intptr_t *tos, int offset) { |
2731 debug_only(verify_stack_tag(tos, frame::TagValue, offset)); |
|
2732 debug_only(verify_stack_tag(tos, frame::TagValue, offset-1)); |
|
2733 return ((VMJavaVal64 *) &tos[Interpreter::expr_index_at(-offset)])->l; |
2716 return ((VMJavaVal64 *) &tos[Interpreter::expr_index_at(-offset)])->l; |
2734 } |
|
2735 |
|
2736 void BytecodeInterpreter::tag_stack(intptr_t *tos, frame::Tag tag, int offset) { |
|
2737 if (TaggedStackInterpreter) |
|
2738 tos[Interpreter::expr_tag_index_at(-offset)] = (intptr_t)tag; |
|
2739 } |
2717 } |
2740 |
2718 |
2741 // only used for value types |
2719 // only used for value types |
2742 void BytecodeInterpreter::set_stack_slot(intptr_t *tos, address value, |
2720 void BytecodeInterpreter::set_stack_slot(intptr_t *tos, address value, |
2743 int offset) { |
2721 int offset) { |
2744 tag_stack(tos, frame::TagValue, offset); |
|
2745 *((address *)&tos[Interpreter::expr_index_at(-offset)]) = value; |
2722 *((address *)&tos[Interpreter::expr_index_at(-offset)]) = value; |
2746 } |
2723 } |
2747 |
2724 |
2748 void BytecodeInterpreter::set_stack_int(intptr_t *tos, int value, |
2725 void BytecodeInterpreter::set_stack_int(intptr_t *tos, int value, |
2749 int offset) { |
2726 int offset) { |
2750 tag_stack(tos, frame::TagValue, offset); |
|
2751 *((jint *)&tos[Interpreter::expr_index_at(-offset)]) = value; |
2727 *((jint *)&tos[Interpreter::expr_index_at(-offset)]) = value; |
2752 } |
2728 } |
2753 |
2729 |
2754 void BytecodeInterpreter::set_stack_float(intptr_t *tos, jfloat value, |
2730 void BytecodeInterpreter::set_stack_float(intptr_t *tos, jfloat value, |
2755 int offset) { |
2731 int offset) { |
2756 tag_stack(tos, frame::TagValue, offset); |
|
2757 *((jfloat *)&tos[Interpreter::expr_index_at(-offset)]) = value; |
2732 *((jfloat *)&tos[Interpreter::expr_index_at(-offset)]) = value; |
2758 } |
2733 } |
2759 |
2734 |
2760 void BytecodeInterpreter::set_stack_object(intptr_t *tos, oop value, |
2735 void BytecodeInterpreter::set_stack_object(intptr_t *tos, oop value, |
2761 int offset) { |
2736 int offset) { |
2762 tag_stack(tos, frame::TagReference, offset); |
|
2763 *((oop *)&tos[Interpreter::expr_index_at(-offset)]) = value; |
2737 *((oop *)&tos[Interpreter::expr_index_at(-offset)]) = value; |
2764 } |
2738 } |
2765 |
2739 |
2766 // needs to be platform dep for the 32 bit platforms. |
2740 // needs to be platform dep for the 32 bit platforms. |
2767 void BytecodeInterpreter::set_stack_double(intptr_t *tos, jdouble value, |
2741 void BytecodeInterpreter::set_stack_double(intptr_t *tos, jdouble value, |
2768 int offset) { |
2742 int offset) { |
2769 tag_stack(tos, frame::TagValue, offset); |
|
2770 tag_stack(tos, frame::TagValue, offset-1); |
|
2771 ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->d = value; |
2743 ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->d = value; |
2772 } |
2744 } |
2773 |
2745 |
2774 void BytecodeInterpreter::set_stack_double_from_addr(intptr_t *tos, |
2746 void BytecodeInterpreter::set_stack_double_from_addr(intptr_t *tos, |
2775 address addr, int offset) { |
2747 address addr, int offset) { |
2776 tag_stack(tos, frame::TagValue, offset); |
|
2777 tag_stack(tos, frame::TagValue, offset-1); |
|
2778 (((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->d = |
2748 (((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->d = |
2779 ((VMJavaVal64*)addr)->d); |
2749 ((VMJavaVal64*)addr)->d); |
2780 } |
2750 } |
2781 |
2751 |
2782 void BytecodeInterpreter::set_stack_long(intptr_t *tos, jlong value, |
2752 void BytecodeInterpreter::set_stack_long(intptr_t *tos, jlong value, |
2783 int offset) { |
2753 int offset) { |
2784 tag_stack(tos, frame::TagValue, offset); |
|
2785 ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset+1)])->l = 0xdeedbeeb; |
2754 ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset+1)])->l = 0xdeedbeeb; |
2786 tag_stack(tos, frame::TagValue, offset-1); |
|
2787 ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->l = value; |
2755 ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->l = value; |
2788 } |
2756 } |
2789 |
2757 |
2790 void BytecodeInterpreter::set_stack_long_from_addr(intptr_t *tos, |
2758 void BytecodeInterpreter::set_stack_long_from_addr(intptr_t *tos, |
2791 address addr, int offset) { |
2759 address addr, int offset) { |
2792 tag_stack(tos, frame::TagValue, offset); |
|
2793 ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset+1)])->l = 0xdeedbeeb; |
2760 ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset+1)])->l = 0xdeedbeeb; |
2794 tag_stack(tos, frame::TagValue, offset-1); |
|
2795 ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->l = |
2761 ((VMJavaVal64*)&tos[Interpreter::expr_index_at(-offset)])->l = |
2796 ((VMJavaVal64*)addr)->l; |
2762 ((VMJavaVal64*)addr)->l; |
2797 } |
2763 } |
2798 |
2764 |
2799 // Locals |
2765 // Locals |
2800 |
2766 |
2801 #ifdef ASSERT |
|
2802 void BytecodeInterpreter::verify_locals_tag(intptr_t *locals, frame::Tag tag, |
|
2803 int offset) { |
|
2804 if (TaggedStackInterpreter) { |
|
2805 frame::Tag t = (frame::Tag)locals[Interpreter::local_tag_index_at(-offset)]; |
|
2806 assert(t == tag, "locals tag mismatch"); |
|
2807 } |
|
2808 } |
|
2809 #endif // ASSERT |
|
2810 address BytecodeInterpreter::locals_slot(intptr_t* locals, int offset) { |
2767 address BytecodeInterpreter::locals_slot(intptr_t* locals, int offset) { |
2811 debug_only(verify_locals_tag(locals, frame::TagValue, offset)); |
|
2812 return (address)locals[Interpreter::local_index_at(-offset)]; |
2768 return (address)locals[Interpreter::local_index_at(-offset)]; |
2813 } |
2769 } |
2814 jint BytecodeInterpreter::locals_int(intptr_t* locals, int offset) { |
2770 jint BytecodeInterpreter::locals_int(intptr_t* locals, int offset) { |
2815 debug_only(verify_locals_tag(locals, frame::TagValue, offset)); |
|
2816 return (jint)locals[Interpreter::local_index_at(-offset)]; |
2771 return (jint)locals[Interpreter::local_index_at(-offset)]; |
2817 } |
2772 } |
2818 jfloat BytecodeInterpreter::locals_float(intptr_t* locals, int offset) { |
2773 jfloat BytecodeInterpreter::locals_float(intptr_t* locals, int offset) { |
2819 debug_only(verify_locals_tag(locals, frame::TagValue, offset)); |
|
2820 return (jfloat)locals[Interpreter::local_index_at(-offset)]; |
2774 return (jfloat)locals[Interpreter::local_index_at(-offset)]; |
2821 } |
2775 } |
2822 oop BytecodeInterpreter::locals_object(intptr_t* locals, int offset) { |
2776 oop BytecodeInterpreter::locals_object(intptr_t* locals, int offset) { |
2823 debug_only(verify_locals_tag(locals, frame::TagReference, offset)); |
|
2824 return (oop)locals[Interpreter::local_index_at(-offset)]; |
2777 return (oop)locals[Interpreter::local_index_at(-offset)]; |
2825 } |
2778 } |
2826 jdouble BytecodeInterpreter::locals_double(intptr_t* locals, int offset) { |
2779 jdouble BytecodeInterpreter::locals_double(intptr_t* locals, int offset) { |
2827 debug_only(verify_locals_tag(locals, frame::TagValue, offset)); |
|
2828 debug_only(verify_locals_tag(locals, frame::TagValue, offset)); |
|
2829 return ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->d; |
2780 return ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->d; |
2830 } |
2781 } |
2831 jlong BytecodeInterpreter::locals_long(intptr_t* locals, int offset) { |
2782 jlong BytecodeInterpreter::locals_long(intptr_t* locals, int offset) { |
2832 debug_only(verify_locals_tag(locals, frame::TagValue, offset)); |
|
2833 debug_only(verify_locals_tag(locals, frame::TagValue, offset+1)); |
|
2834 return ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->l; |
2783 return ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->l; |
2835 } |
2784 } |
2836 |
2785 |
2837 // Returns the address of locals value. |
2786 // Returns the address of locals value. |
2838 address BytecodeInterpreter::locals_long_at(intptr_t* locals, int offset) { |
2787 address BytecodeInterpreter::locals_long_at(intptr_t* locals, int offset) { |
2839 debug_only(verify_locals_tag(locals, frame::TagValue, offset)); |
|
2840 debug_only(verify_locals_tag(locals, frame::TagValue, offset+1)); |
|
2841 return ((address)&locals[Interpreter::local_index_at(-(offset+1))]); |
2788 return ((address)&locals[Interpreter::local_index_at(-(offset+1))]); |
2842 } |
2789 } |
2843 address BytecodeInterpreter::locals_double_at(intptr_t* locals, int offset) { |
2790 address BytecodeInterpreter::locals_double_at(intptr_t* locals, int offset) { |
2844 debug_only(verify_locals_tag(locals, frame::TagValue, offset)); |
|
2845 debug_only(verify_locals_tag(locals, frame::TagValue, offset+1)); |
|
2846 return ((address)&locals[Interpreter::local_index_at(-(offset+1))]); |
2791 return ((address)&locals[Interpreter::local_index_at(-(offset+1))]); |
2847 } |
|
2848 |
|
2849 void BytecodeInterpreter::tag_locals(intptr_t *locals, frame::Tag tag, int offset) { |
|
2850 if (TaggedStackInterpreter) |
|
2851 locals[Interpreter::local_tag_index_at(-offset)] = (intptr_t)tag; |
|
2852 } |
2792 } |
2853 |
2793 |
2854 // Used for local value or returnAddress |
2794 // Used for local value or returnAddress |
2855 void BytecodeInterpreter::set_locals_slot(intptr_t *locals, |
2795 void BytecodeInterpreter::set_locals_slot(intptr_t *locals, |
2856 address value, int offset) { |
2796 address value, int offset) { |
2857 tag_locals(locals, frame::TagValue, offset); |
|
2858 *((address*)&locals[Interpreter::local_index_at(-offset)]) = value; |
2797 *((address*)&locals[Interpreter::local_index_at(-offset)]) = value; |
2859 } |
2798 } |
2860 void BytecodeInterpreter::set_locals_int(intptr_t *locals, |
2799 void BytecodeInterpreter::set_locals_int(intptr_t *locals, |
2861 jint value, int offset) { |
2800 jint value, int offset) { |
2862 tag_locals(locals, frame::TagValue, offset); |
|
2863 *((jint *)&locals[Interpreter::local_index_at(-offset)]) = value; |
2801 *((jint *)&locals[Interpreter::local_index_at(-offset)]) = value; |
2864 } |
2802 } |
2865 void BytecodeInterpreter::set_locals_float(intptr_t *locals, |
2803 void BytecodeInterpreter::set_locals_float(intptr_t *locals, |
2866 jfloat value, int offset) { |
2804 jfloat value, int offset) { |
2867 tag_locals(locals, frame::TagValue, offset); |
|
2868 *((jfloat *)&locals[Interpreter::local_index_at(-offset)]) = value; |
2805 *((jfloat *)&locals[Interpreter::local_index_at(-offset)]) = value; |
2869 } |
2806 } |
2870 void BytecodeInterpreter::set_locals_object(intptr_t *locals, |
2807 void BytecodeInterpreter::set_locals_object(intptr_t *locals, |
2871 oop value, int offset) { |
2808 oop value, int offset) { |
2872 tag_locals(locals, frame::TagReference, offset); |
|
2873 *((oop *)&locals[Interpreter::local_index_at(-offset)]) = value; |
2809 *((oop *)&locals[Interpreter::local_index_at(-offset)]) = value; |
2874 } |
2810 } |
2875 void BytecodeInterpreter::set_locals_double(intptr_t *locals, |
2811 void BytecodeInterpreter::set_locals_double(intptr_t *locals, |
2876 jdouble value, int offset) { |
2812 jdouble value, int offset) { |
2877 tag_locals(locals, frame::TagValue, offset); |
|
2878 tag_locals(locals, frame::TagValue, offset+1); |
|
2879 ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->d = value; |
2813 ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->d = value; |
2880 } |
2814 } |
2881 void BytecodeInterpreter::set_locals_long(intptr_t *locals, |
2815 void BytecodeInterpreter::set_locals_long(intptr_t *locals, |
2882 jlong value, int offset) { |
2816 jlong value, int offset) { |
2883 tag_locals(locals, frame::TagValue, offset); |
|
2884 tag_locals(locals, frame::TagValue, offset+1); |
|
2885 ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->l = value; |
2817 ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->l = value; |
2886 } |
2818 } |
2887 void BytecodeInterpreter::set_locals_double_from_addr(intptr_t *locals, |
2819 void BytecodeInterpreter::set_locals_double_from_addr(intptr_t *locals, |
2888 address addr, int offset) { |
2820 address addr, int offset) { |
2889 tag_locals(locals, frame::TagValue, offset); |
|
2890 tag_locals(locals, frame::TagValue, offset+1); |
|
2891 ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->d = ((VMJavaVal64*)addr)->d; |
2821 ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->d = ((VMJavaVal64*)addr)->d; |
2892 } |
2822 } |
2893 void BytecodeInterpreter::set_locals_long_from_addr(intptr_t *locals, |
2823 void BytecodeInterpreter::set_locals_long_from_addr(intptr_t *locals, |
2894 address addr, int offset) { |
2824 address addr, int offset) { |
2895 tag_locals(locals, frame::TagValue, offset); |
|
2896 tag_locals(locals, frame::TagValue, offset+1); |
|
2897 ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->l = ((VMJavaVal64*)addr)->l; |
2825 ((VMJavaVal64*)&locals[Interpreter::local_index_at(-(offset+1))])->l = ((VMJavaVal64*)addr)->l; |
2898 } |
2826 } |
2899 |
2827 |
2900 void BytecodeInterpreter::astore(intptr_t* tos, int stack_offset, |
2828 void BytecodeInterpreter::astore(intptr_t* tos, int stack_offset, |
2901 intptr_t* locals, int locals_offset) { |
2829 intptr_t* locals, int locals_offset) { |
2902 // Copy tag from stack to locals. astore's operand can be returnAddress |
|
2903 // and may not be TagReference |
|
2904 if (TaggedStackInterpreter) { |
|
2905 frame::Tag t = (frame::Tag) tos[Interpreter::expr_tag_index_at(-stack_offset)]; |
|
2906 locals[Interpreter::local_tag_index_at(-locals_offset)] = (intptr_t)t; |
|
2907 } |
|
2908 intptr_t value = tos[Interpreter::expr_index_at(-stack_offset)]; |
2830 intptr_t value = tos[Interpreter::expr_index_at(-stack_offset)]; |
2909 locals[Interpreter::local_index_at(-locals_offset)] = value; |
2831 locals[Interpreter::local_index_at(-locals_offset)] = value; |
2910 } |
2832 } |
2911 |
2833 |
2912 |
2834 |
2913 void BytecodeInterpreter::copy_stack_slot(intptr_t *tos, int from_offset, |
2835 void BytecodeInterpreter::copy_stack_slot(intptr_t *tos, int from_offset, |
2914 int to_offset) { |
2836 int to_offset) { |
2915 if (TaggedStackInterpreter) { |
|
2916 tos[Interpreter::expr_tag_index_at(-to_offset)] = |
|
2917 (intptr_t)tos[Interpreter::expr_tag_index_at(-from_offset)]; |
|
2918 } |
|
2919 tos[Interpreter::expr_index_at(-to_offset)] = |
2837 tos[Interpreter::expr_index_at(-to_offset)] = |
2920 (intptr_t)tos[Interpreter::expr_index_at(-from_offset)]; |
2838 (intptr_t)tos[Interpreter::expr_index_at(-from_offset)]; |
2921 } |
2839 } |
2922 |
2840 |
2923 void BytecodeInterpreter::dup(intptr_t *tos) { |
2841 void BytecodeInterpreter::dup(intptr_t *tos) { |