Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: src/x64/stub-cache-x64.cc

Issue 12094082: Merge KeyedLoad and NamedLoad stub compiler code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/stub-cache.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2772 matching lines...) Expand 10 before | Expand all | Expand 10 after
2783 __ bind(&miss); 2783 __ bind(&miss);
2784 Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss(); 2784 Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss();
2785 __ jmp(ic, RelocInfo::CODE_TARGET); 2785 __ jmp(ic, RelocInfo::CODE_TARGET);
2786 2786
2787 // Return the generated code. 2787 // Return the generated code.
2788 return GetCode(Code::NORMAL, factory()->empty_string(), POLYMORPHIC); 2788 return GetCode(Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
2789 } 2789 }
2790 2790
2791 2791
2792 Handle<Code> LoadStubCompiler::CompileLoadNonexistent( 2792 Handle<Code> LoadStubCompiler::CompileLoadNonexistent(
2793 Handle<String> name,
2794 Handle<JSObject> object, 2793 Handle<JSObject> object,
2795 Handle<JSObject> last, 2794 Handle<JSObject> last,
2795 Handle<String> name,
2796 Handle<GlobalObject> global) { 2796 Handle<GlobalObject> global) {
2797 // ----------- S t a t e ------------- 2797 // ----------- S t a t e -------------
2798 // -- rax : receiver 2798 // -- rax : receiver
2799 // -- rcx : name 2799 // -- rcx : name
2800 // -- rsp[0] : return address 2800 // -- rsp[0] : return address
2801 // ----------------------------------- 2801 // -----------------------------------
2802 Label miss; 2802 Label miss;
2803 2803
2804 // Check that receiver is not a smi. 2804 // Check that receiver is not a smi.
2805 __ JumpIfSmi(rax, &miss); 2805 __ JumpIfSmi(rax, &miss);
(...skipping 24 matching lines...) Expand all
2830 __ ret(0); 2830 __ ret(0);
2831 2831
2832 __ bind(&miss); 2832 __ bind(&miss);
2833 GenerateLoadMiss(masm(), Code::LOAD_IC); 2833 GenerateLoadMiss(masm(), Code::LOAD_IC);
2834 2834
2835 // Return the generated code. 2835 // Return the generated code.
2836 return GetCode(Code::NONEXISTENT, factory()->empty_string()); 2836 return GetCode(Code::NONEXISTENT, factory()->empty_string());
2837 } 2837 }
2838 2838
2839 2839
2840 Handle<Code> LoadStubCompiler::CompileLoadField(Handle<JSObject> object, 2840 Register* LoadStubCompiler::registers() {
2841 Handle<JSObject> holder, 2841 // receiver, name, scratch1, scratch2, scratch3, scratch4.
2842 PropertyIndex index, 2842 static Register registers[] = { rax, rcx, rbx, rdx, rdi, r8 };
2843 Handle<String> name) { 2843 return registers;
2844 // ----------- S t a t e -------------
2845 // -- rax : receiver
2846 // -- rcx : name
2847 // -- rsp[0] : return address
2848 // -----------------------------------
2849 Label miss;
2850
2851 GenerateLoadField(object, holder, rax, rbx, rdx, rdi, index, name, &miss);
2852 __ bind(&miss);
2853 GenerateLoadMiss(masm(), Code::LOAD_IC);
2854
2855 // Return the generated code.
2856 return GetCode(Code::FIELD, name);
2857 } 2844 }
2858 2845
2859 2846
2860 Handle<Code> LoadStubCompiler::CompileLoadCallback( 2847 Register* KeyedLoadStubCompiler::registers() {
2861 Handle<String> name, 2848 // receiver, name, scratch1, scratch2, scratch3, scratch4.
2862 Handle<JSObject> object, 2849 static Register registers[] = { rdx, rax, rbx, rcx, rdi, r8 };
2863 Handle<JSObject> holder, 2850 return registers;
2864 Handle<AccessorInfo> callback) {
2865 // ----------- S t a t e -------------
2866 // -- rax : receiver
2867 // -- rcx : name
2868 // -- rsp[0] : return address
2869 // -----------------------------------
2870 Label miss;
2871 GenerateLoadCallback(object, holder, rax, rcx, rdx, rbx, rdi, r8, callback,
2872 name, &miss);
2873 __ bind(&miss);
2874 GenerateLoadMiss(masm(), Code::LOAD_IC);
2875
2876 // Return the generated code.
2877 return GetCode(Code::CALLBACKS, name);
2878 } 2851 }
2879 2852
2880 2853
2854 void KeyedLoadStubCompiler::GenerateNameCheck(Handle<String> name,
2855 Register name_reg,
2856 Label* miss) {
2857 __ Cmp(name_reg, name);
2858 __ j(not_equal, miss);
2859 }
2860
2861
2881 #undef __ 2862 #undef __
2882 #define __ ACCESS_MASM(masm) 2863 #define __ ACCESS_MASM(masm)
2883 2864
2884 2865
2885 void LoadStubCompiler::GenerateLoadViaGetter(MacroAssembler* masm, 2866 void LoadStubCompiler::GenerateLoadViaGetter(MacroAssembler* masm,
2886 Handle<JSFunction> getter) { 2867 Handle<JSFunction> getter) {
2887 // ----------- S t a t e ------------- 2868 // ----------- S t a t e -------------
2888 // -- rax : receiver 2869 // -- rax : receiver
2889 // -- rcx : name 2870 // -- rcx : name
2890 // -- rsp[0] : return address 2871 // -- rsp[0] : return address
(...skipping 18 matching lines...) Expand all
2909 } 2890 }
2910 __ ret(0); 2891 __ ret(0);
2911 } 2892 }
2912 2893
2913 2894
2914 #undef __ 2895 #undef __
2915 #define __ ACCESS_MASM(masm()) 2896 #define __ ACCESS_MASM(masm())
2916 2897
2917 2898
2918 Handle<Code> LoadStubCompiler::CompileLoadViaGetter( 2899 Handle<Code> LoadStubCompiler::CompileLoadViaGetter(
2919 Handle<String> name,
2920 Handle<JSObject> receiver, 2900 Handle<JSObject> receiver,
2921 Handle<JSObject> holder, 2901 Handle<JSObject> holder,
2902 Handle<String> name,
2922 Handle<JSFunction> getter) { 2903 Handle<JSFunction> getter) {
2923 // ----------- S t a t e ------------- 2904 // ----------- S t a t e -------------
2924 // -- rax : receiver 2905 // -- rax : receiver
2925 // -- rcx : name 2906 // -- rcx : name
2926 // -- rsp[0] : return address 2907 // -- rsp[0] : return address
2927 // ----------------------------------- 2908 // -----------------------------------
2928 Label miss; 2909 Label miss;
2929 2910
2930 // Check that the maps haven't changed. 2911 // Check that the maps haven't changed.
2931 __ JumpIfSmi(rax, &miss); 2912 __ JumpIfSmi(rax, &miss);
2932 CheckPrototypes(receiver, rax, holder, rbx, rdx, rdi, name, &miss); 2913 CheckPrototypes(receiver, rax, holder, rbx, rdx, rdi, name, &miss);
2933 2914
2934 GenerateLoadViaGetter(masm(), getter), 2915 GenerateLoadViaGetter(masm(), getter),
2935 2916
2936 __ bind(&miss); 2917 __ bind(&miss);
2937 GenerateLoadMiss(masm(), Code::LOAD_IC); 2918 GenerateLoadMiss(masm(), Code::LOAD_IC);
2938 2919
2939 // Return the generated code. 2920 // Return the generated code.
2940 return GetCode(Code::CALLBACKS, name); 2921 return GetCode(Code::CALLBACKS, name);
2941 } 2922 }
2942 2923
2943 2924
2944 Handle<Code> LoadStubCompiler::CompileLoadConstant(Handle<JSObject> object,
2945 Handle<JSObject> holder,
2946 Handle<JSFunction> value,
2947 Handle<String> name) {
2948 // ----------- S t a t e -------------
2949 // -- rax : receiver
2950 // -- rcx : name
2951 // -- rsp[0] : return address
2952 // -----------------------------------
2953 Label miss;
2954
2955 GenerateLoadConstant(object, holder, rax, rbx, rdx, rdi, value, name, &miss);
2956 __ bind(&miss);
2957 GenerateLoadMiss(masm(), Code::LOAD_IC);
2958
2959 // Return the generated code.
2960 return GetCode(Code::CONSTANT_FUNCTION, name);
2961 }
2962
2963
2964 Handle<Code> LoadStubCompiler::CompileLoadInterceptor(Handle<JSObject> receiver,
2965 Handle<JSObject> holder,
2966 Handle<String> name) {
2967 // ----------- S t a t e -------------
2968 // -- rax : receiver
2969 // -- rcx : name
2970 // -- rsp[0] : return address
2971 // -----------------------------------
2972 Label miss;
2973 LookupResult lookup(isolate());
2974 LookupPostInterceptor(holder, name, &lookup);
2975
2976 // TODO(368): Compile in the whole chain: all the interceptors in
2977 // prototypes and ultimate answer.
2978 GenerateLoadInterceptor(receiver, holder, &lookup, rax, rcx, rdx, rbx, rdi,
2979 name, &miss);
2980 __ bind(&miss);
2981 GenerateLoadMiss(masm(), Code::LOAD_IC);
2982
2983 // Return the generated code.
2984 return GetCode(Code::INTERCEPTOR, name);
2985 }
2986
2987
2988 Handle<Code> LoadStubCompiler::CompileLoadGlobal( 2925 Handle<Code> LoadStubCompiler::CompileLoadGlobal(
2989 Handle<JSObject> object, 2926 Handle<JSObject> object,
2990 Handle<GlobalObject> holder, 2927 Handle<GlobalObject> holder,
2991 Handle<JSGlobalPropertyCell> cell, 2928 Handle<JSGlobalPropertyCell> cell,
2992 Handle<String> name, 2929 Handle<String> name,
2993 bool is_dont_delete) { 2930 bool is_dont_delete) {
2994 // ----------- S t a t e ------------- 2931 // ----------- S t a t e -------------
2995 // -- rax : receiver 2932 // -- rax : receiver
2996 // -- rcx : name 2933 // -- rcx : name
2997 // -- rsp[0] : return address 2934 // -- rsp[0] : return address
(...skipping 24 matching lines...) Expand all
3022 2959
3023 __ bind(&miss); 2960 __ bind(&miss);
3024 __ IncrementCounter(counters->named_load_global_stub_miss(), 1); 2961 __ IncrementCounter(counters->named_load_global_stub_miss(), 1);
3025 GenerateLoadMiss(masm(), Code::LOAD_IC); 2962 GenerateLoadMiss(masm(), Code::LOAD_IC);
3026 2963
3027 // Return the generated code. 2964 // Return the generated code.
3028 return GetCode(Code::NORMAL, name); 2965 return GetCode(Code::NORMAL, name);
3029 } 2966 }
3030 2967
3031 2968
3032 Handle<Code> KeyedLoadStubCompiler::CompileLoadField(Handle<String> name,
3033 Handle<JSObject> receiver,
3034 Handle<JSObject> holder,
3035 PropertyIndex index) {
3036 // ----------- S t a t e -------------
3037 // -- rax : key
3038 // -- rdx : receiver
3039 // -- rsp[0] : return address
3040 // -----------------------------------
3041 Label miss;
3042
3043 Counters* counters = isolate()->counters();
3044 __ IncrementCounter(counters->keyed_load_field(), 1);
3045
3046 // Check that the name has not changed.
3047 __ Cmp(rax, name);
3048 __ j(not_equal, &miss);
3049
3050 GenerateLoadField(receiver, holder, rdx, rbx, rcx, rdi, index, name, &miss);
3051
3052 __ bind(&miss);
3053 __ DecrementCounter(counters->keyed_load_field(), 1);
3054 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
3055
3056 // Return the generated code.
3057 return GetCode(Code::FIELD, name);
3058 }
3059
3060
3061 Handle<Code> KeyedLoadStubCompiler::CompileLoadCallback(
3062 Handle<String> name,
3063 Handle<JSObject> receiver,
3064 Handle<JSObject> holder,
3065 Handle<AccessorInfo> callback) {
3066 // ----------- S t a t e -------------
3067 // -- rax : key
3068 // -- rdx : receiver
3069 // -- rsp[0] : return address
3070 // -----------------------------------
3071 Label miss;
3072 Counters* counters = isolate()->counters();
3073 __ IncrementCounter(counters->keyed_load_callback(), 1);
3074
3075 // Check that the name has not changed.
3076 __ Cmp(rax, name);
3077 __ j(not_equal, &miss);
3078
3079 GenerateLoadCallback(receiver, holder, rdx, rax, rbx, rcx, rdi, r8, callback,
3080 name, &miss);
3081 __ bind(&miss);
3082 __ DecrementCounter(counters->keyed_load_callback(), 1);
3083 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
3084
3085 // Return the generated code.
3086 return GetCode(Code::CALLBACKS, name);
3087 }
3088
3089
3090 Handle<Code> KeyedLoadStubCompiler::CompileLoadConstant(
3091 Handle<String> name,
3092 Handle<JSObject> receiver,
3093 Handle<JSObject> holder,
3094 Handle<JSFunction> value) {
3095 // ----------- S t a t e -------------
3096 // -- rax : key
3097 // -- rdx : receiver
3098 // -- rsp[0] : return address
3099 // -----------------------------------
3100 Label miss;
3101
3102 Counters* counters = isolate()->counters();
3103 __ IncrementCounter(counters->keyed_load_constant_function(), 1);
3104
3105 // Check that the name has not changed.
3106 __ Cmp(rax, name);
3107 __ j(not_equal, &miss);
3108
3109 GenerateLoadConstant(receiver, holder, rdx, rbx, rcx, rdi,
3110 value, name, &miss);
3111 __ bind(&miss);
3112 __ DecrementCounter(counters->keyed_load_constant_function(), 1);
3113 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
3114
3115 // Return the generated code.
3116 return GetCode(Code::CONSTANT_FUNCTION, name);
3117 }
3118
3119
3120 Handle<Code> KeyedLoadStubCompiler::CompileLoadInterceptor(
3121 Handle<JSObject> receiver,
3122 Handle<JSObject> holder,
3123 Handle<String> name) {
3124 // ----------- S t a t e -------------
3125 // -- rax : key
3126 // -- rdx : receiver
3127 // -- rsp[0] : return address
3128 // -----------------------------------
3129 Label miss;
3130 Counters* counters = isolate()->counters();
3131 __ IncrementCounter(counters->keyed_load_interceptor(), 1);
3132
3133 // Check that the name has not changed.
3134 __ Cmp(rax, name);
3135 __ j(not_equal, &miss);
3136
3137 LookupResult lookup(isolate());
3138 LookupPostInterceptor(holder, name, &lookup);
3139 GenerateLoadInterceptor(receiver, holder, &lookup, rdx, rax, rcx, rbx, rdi,
3140 name, &miss);
3141 __ bind(&miss);
3142 __ DecrementCounter(counters->keyed_load_interceptor(), 1);
3143 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
3144
3145 // Return the generated code.
3146 return GetCode(Code::INTERCEPTOR, name);
3147 }
3148
3149
3150 Handle<Code> KeyedLoadStubCompiler::CompileLoadElement( 2969 Handle<Code> KeyedLoadStubCompiler::CompileLoadElement(
3151 Handle<Map> receiver_map) { 2970 Handle<Map> receiver_map) {
3152 // ----------- S t a t e ------------- 2971 // ----------- S t a t e -------------
3153 // -- rax : key 2972 // -- rax : key
3154 // -- rdx : receiver 2973 // -- rdx : receiver
3155 // -- rsp[0] : return address 2974 // -- rsp[0] : return address
3156 // ----------------------------------- 2975 // -----------------------------------
3157 ElementsKind elements_kind = receiver_map->elements_kind(); 2976 ElementsKind elements_kind = receiver_map->elements_kind();
3158 if (receiver_map->has_fast_elements() || 2977 if (receiver_map->has_fast_elements() ||
3159 receiver_map->has_external_array_elements()) { 2978 receiver_map->has_external_array_elements()) {
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
3873 __ jmp(ic_slow, RelocInfo::CODE_TARGET); 3692 __ jmp(ic_slow, RelocInfo::CODE_TARGET);
3874 } 3693 }
3875 } 3694 }
3876 3695
3877 3696
3878 #undef __ 3697 #undef __
3879 3698
3880 } } // namespace v8::internal 3699 } } // namespace v8::internal
3881 3700
3882 #endif // V8_TARGET_ARCH_X64 3701 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/stub-cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698