comparison src/share/vm/interpreter/bytecodeInterpreter.cpp @ 1506:2338d41fbd81

6943304: remove tagged stack interpreter Reviewed-by: coleenp, never, gbenson
author twisti
date Fri, 30 Apr 2010 08:37:24 -0700
parents f61d795ce6de
children 68d6683eaef7
comparison
equal deleted inserted replaced
1505:0c5b3cf3c1f5 1506:2338d41fbd81
1 /* 1 /*
2 * Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved. 2 * Copyright 2002-2010 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
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) {
2962 2880
2963 2881
2964 void BytecodeInterpreter::swap(intptr_t *tos) { 2882 void BytecodeInterpreter::swap(intptr_t *tos) {
2965 // swap top two elements 2883 // swap top two elements
2966 intptr_t val = tos[Interpreter::expr_index_at(1)]; 2884 intptr_t val = tos[Interpreter::expr_index_at(1)];
2967 frame::Tag t;
2968 if (TaggedStackInterpreter) {
2969 t = (frame::Tag) tos[Interpreter::expr_tag_index_at(1)];
2970 }
2971 // Copy -2 entry to -1 2885 // Copy -2 entry to -1
2972 copy_stack_slot(tos, -2, -1); 2886 copy_stack_slot(tos, -2, -1);
2973 // Store saved -1 entry into -2 2887 // Store saved -1 entry into -2
2974 if (TaggedStackInterpreter) {
2975 tos[Interpreter::expr_tag_index_at(2)] = (intptr_t)t;
2976 }
2977 tos[Interpreter::expr_index_at(2)] = val; 2888 tos[Interpreter::expr_index_at(2)] = val;
2978 } 2889 }
2979 // -------------------------------------------------------------------------------- 2890 // --------------------------------------------------------------------------------
2980 // Non-product code 2891 // Non-product code
2981 #ifndef PRODUCT 2892 #ifndef PRODUCT