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

Side by Side Diff: src/ia32/stub-cache-ia32.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/arm/stub-cache-arm.cc ('k') | src/stub-cache.h » ('j') | 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 2947 matching lines...) Expand 10 before | Expand all | Expand 10 after
2958 __ bind(&miss); 2958 __ bind(&miss);
2959 Handle<Code> miss_ic = isolate()->builtins()->KeyedStoreIC_Miss(); 2959 Handle<Code> miss_ic = isolate()->builtins()->KeyedStoreIC_Miss();
2960 __ jmp(miss_ic, RelocInfo::CODE_TARGET); 2960 __ jmp(miss_ic, RelocInfo::CODE_TARGET);
2961 2961
2962 // Return the generated code. 2962 // Return the generated code.
2963 return GetCode(Code::NORMAL, factory()->empty_string(), POLYMORPHIC); 2963 return GetCode(Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
2964 } 2964 }
2965 2965
2966 2966
2967 Handle<Code> LoadStubCompiler::CompileLoadNonexistent( 2967 Handle<Code> LoadStubCompiler::CompileLoadNonexistent(
2968 Handle<String> name,
2969 Handle<JSObject> object, 2968 Handle<JSObject> object,
2970 Handle<JSObject> last, 2969 Handle<JSObject> last,
2970 Handle<String> name,
2971 Handle<GlobalObject> global) { 2971 Handle<GlobalObject> global) {
2972 // ----------- S t a t e ------------- 2972 // ----------- S t a t e -------------
2973 // -- ecx : name 2973 // -- ecx : name
2974 // -- edx : receiver 2974 // -- edx : receiver
2975 // -- esp[0] : return address 2975 // -- esp[0] : return address
2976 // ----------------------------------- 2976 // -----------------------------------
2977 Label miss; 2977 Label miss;
2978 2978
2979 // Check that the receiver isn't a smi. 2979 // Check that the receiver isn't a smi.
2980 __ JumpIfSmi(edx, &miss); 2980 __ JumpIfSmi(edx, &miss);
(...skipping 25 matching lines...) Expand all
3006 __ ret(0); 3006 __ ret(0);
3007 3007
3008 __ bind(&miss); 3008 __ bind(&miss);
3009 GenerateLoadMiss(masm(), Code::LOAD_IC); 3009 GenerateLoadMiss(masm(), Code::LOAD_IC);
3010 3010
3011 // Return the generated code. 3011 // Return the generated code.
3012 return GetCode(Code::NONEXISTENT, factory()->empty_string()); 3012 return GetCode(Code::NONEXISTENT, factory()->empty_string());
3013 } 3013 }
3014 3014
3015 3015
3016 Handle<Code> LoadStubCompiler::CompileLoadField(Handle<JSObject> object, 3016 Register* LoadStubCompiler::registers() {
3017 Handle<JSObject> holder, 3017 // receiver, name, scratch1, scratch2, scratch3, scratch4.
3018 PropertyIndex index, 3018 static Register registers[] = { edx, ecx, ebx, eax, edi, no_reg };
3019 Handle<String> name) { 3019 return registers;
3020 // ----------- S t a t e -------------
3021 // -- ecx : name
3022 // -- edx : receiver
3023 // -- esp[0] : return address
3024 // -----------------------------------
3025 Label miss;
3026
3027 GenerateLoadField(object, holder, edx, ebx, eax, edi, index, name, &miss);
3028 __ bind(&miss);
3029 GenerateLoadMiss(masm(), Code::LOAD_IC);
3030
3031 // Return the generated code.
3032 return GetCode(Code::FIELD, name);
3033 } 3020 }
3034 3021
3035 3022
3036 Handle<Code> LoadStubCompiler::CompileLoadCallback( 3023 Register* KeyedLoadStubCompiler::registers() {
3037 Handle<String> name, 3024 // receiver, name, scratch1, scratch2, scratch3, scratch4.
3038 Handle<JSObject> object, 3025 static Register registers[] = { edx, ecx, ebx, eax, edi, no_reg };
3039 Handle<JSObject> holder, 3026 return registers;
3040 Handle<AccessorInfo> callback) {
3041 // ----------- S t a t e -------------
3042 // -- ecx : name
3043 // -- edx : receiver
3044 // -- esp[0] : return address
3045 // -----------------------------------
3046 Label miss;
3047
3048 GenerateLoadCallback(object, holder, edx, ecx, ebx, eax, edi, no_reg,
3049 callback, name, &miss);
3050 __ bind(&miss);
3051 GenerateLoadMiss(masm(), Code::LOAD_IC);
3052
3053 // Return the generated code.
3054 return GetCode(Code::CALLBACKS, name);
3055 } 3027 }
3056 3028
3057 3029
3030 void KeyedLoadStubCompiler::GenerateNameCheck(Handle<String> name,
3031 Register name_reg,
3032 Label* miss) {
3033 __ cmp(name_reg, Immediate(name));
3034 __ j(not_equal, miss);
3035 }
3036
3037
3058 #undef __ 3038 #undef __
3059 #define __ ACCESS_MASM(masm) 3039 #define __ ACCESS_MASM(masm)
3060 3040
3061 3041
3062 void LoadStubCompiler::GenerateLoadViaGetter(MacroAssembler* masm, 3042 void LoadStubCompiler::GenerateLoadViaGetter(MacroAssembler* masm,
3063 Handle<JSFunction> getter) { 3043 Handle<JSFunction> getter) {
3064 // ----------- S t a t e ------------- 3044 // ----------- S t a t e -------------
3065 // -- ecx : name 3045 // -- ecx : name
3066 // -- edx : receiver 3046 // -- edx : receiver
3067 // -- esp[0] : return address 3047 // -- esp[0] : return address
(...skipping 18 matching lines...) Expand all
3086 } 3066 }
3087 __ ret(0); 3067 __ ret(0);
3088 } 3068 }
3089 3069
3090 3070
3091 #undef __ 3071 #undef __
3092 #define __ ACCESS_MASM(masm()) 3072 #define __ ACCESS_MASM(masm())
3093 3073
3094 3074
3095 Handle<Code> LoadStubCompiler::CompileLoadViaGetter( 3075 Handle<Code> LoadStubCompiler::CompileLoadViaGetter(
3096 Handle<String> name,
3097 Handle<JSObject> receiver, 3076 Handle<JSObject> receiver,
3098 Handle<JSObject> holder, 3077 Handle<JSObject> holder,
3078 Handle<String> name,
3099 Handle<JSFunction> getter) { 3079 Handle<JSFunction> getter) {
3100 // ----------- S t a t e ------------- 3080 // ----------- S t a t e -------------
3101 // -- ecx : name 3081 // -- ecx : name
3102 // -- edx : receiver 3082 // -- edx : receiver
3103 // -- esp[0] : return address 3083 // -- esp[0] : return address
3104 // ----------------------------------- 3084 // -----------------------------------
3105 Label miss; 3085 Label miss;
3106 3086
3107 // Check that the maps haven't changed. 3087 // Check that the maps haven't changed.
3108 __ JumpIfSmi(edx, &miss); 3088 __ JumpIfSmi(edx, &miss);
3109 CheckPrototypes(receiver, edx, holder, ebx, eax, edi, name, &miss); 3089 CheckPrototypes(receiver, edx, holder, ebx, eax, edi, name, &miss);
3110 3090
3111 GenerateLoadViaGetter(masm(), getter); 3091 GenerateLoadViaGetter(masm(), getter);
3112 3092
3113 __ bind(&miss); 3093 __ bind(&miss);
3114 GenerateLoadMiss(masm(), Code::LOAD_IC); 3094 GenerateLoadMiss(masm(), Code::LOAD_IC);
3115 3095
3116 // Return the generated code. 3096 // Return the generated code.
3117 return GetCode(Code::CALLBACKS, name); 3097 return GetCode(Code::CALLBACKS, name);
3118 } 3098 }
3119 3099
3120 3100
3121 Handle<Code> LoadStubCompiler::CompileLoadConstant(Handle<JSObject> object,
3122 Handle<JSObject> holder,
3123 Handle<JSFunction> value,
3124 Handle<String> name) {
3125 // ----------- S t a t e -------------
3126 // -- ecx : name
3127 // -- edx : receiver
3128 // -- esp[0] : return address
3129 // -----------------------------------
3130 Label miss;
3131
3132 GenerateLoadConstant(object, holder, edx, ebx, eax, edi, value, name, &miss);
3133 __ bind(&miss);
3134 GenerateLoadMiss(masm(), Code::LOAD_IC);
3135
3136 // Return the generated code.
3137 return GetCode(Code::CONSTANT_FUNCTION, name);
3138 }
3139
3140
3141 Handle<Code> LoadStubCompiler::CompileLoadInterceptor(Handle<JSObject> receiver,
3142 Handle<JSObject> holder,
3143 Handle<String> name) {
3144 // ----------- S t a t e -------------
3145 // -- ecx : name
3146 // -- edx : receiver
3147 // -- esp[0] : return address
3148 // -----------------------------------
3149 Label miss;
3150
3151 LookupResult lookup(isolate());
3152 LookupPostInterceptor(holder, name, &lookup);
3153
3154 // TODO(368): Compile in the whole chain: all the interceptors in
3155 // prototypes and ultimate answer.
3156 GenerateLoadInterceptor(receiver, holder, &lookup, edx, ecx, eax, ebx, edi,
3157 name, &miss);
3158
3159 __ bind(&miss);
3160 GenerateLoadMiss(masm(), Code::LOAD_IC);
3161
3162 // Return the generated code.
3163 return GetCode(Code::INTERCEPTOR, name);
3164 }
3165
3166
3167 Handle<Code> LoadStubCompiler::CompileLoadGlobal( 3101 Handle<Code> LoadStubCompiler::CompileLoadGlobal(
3168 Handle<JSObject> object, 3102 Handle<JSObject> object,
3169 Handle<GlobalObject> holder, 3103 Handle<GlobalObject> holder,
3170 Handle<JSGlobalPropertyCell> cell, 3104 Handle<JSGlobalPropertyCell> cell,
3171 Handle<String> name, 3105 Handle<String> name,
3172 bool is_dont_delete) { 3106 bool is_dont_delete) {
3173 // ----------- S t a t e ------------- 3107 // ----------- S t a t e -------------
3174 // -- ecx : name 3108 // -- ecx : name
3175 // -- edx : receiver 3109 // -- edx : receiver
3176 // -- esp[0] : return address 3110 // -- esp[0] : return address
(...skipping 28 matching lines...) Expand all
3205 3139
3206 __ bind(&miss); 3140 __ bind(&miss);
3207 __ IncrementCounter(counters->named_load_global_stub_miss(), 1); 3141 __ IncrementCounter(counters->named_load_global_stub_miss(), 1);
3208 GenerateLoadMiss(masm(), Code::LOAD_IC); 3142 GenerateLoadMiss(masm(), Code::LOAD_IC);
3209 3143
3210 // Return the generated code. 3144 // Return the generated code.
3211 return GetCode(Code::NORMAL, name); 3145 return GetCode(Code::NORMAL, name);
3212 } 3146 }
3213 3147
3214 3148
3215 Handle<Code> KeyedLoadStubCompiler::CompileLoadField(Handle<String> name,
3216 Handle<JSObject> receiver,
3217 Handle<JSObject> holder,
3218 PropertyIndex index) {
3219 // ----------- S t a t e -------------
3220 // -- ecx : key
3221 // -- edx : receiver
3222 // -- esp[0] : return address
3223 // -----------------------------------
3224 Label miss;
3225
3226 Counters* counters = isolate()->counters();
3227 __ IncrementCounter(counters->keyed_load_field(), 1);
3228
3229 // Check that the name has not changed.
3230 __ cmp(ecx, Immediate(name));
3231 __ j(not_equal, &miss);
3232
3233 GenerateLoadField(receiver, holder, edx, ebx, eax, edi, index, name, &miss);
3234
3235 __ bind(&miss);
3236 __ DecrementCounter(counters->keyed_load_field(), 1);
3237 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
3238
3239 // Return the generated code.
3240 return GetCode(Code::FIELD, name);
3241 }
3242
3243
3244 Handle<Code> KeyedLoadStubCompiler::CompileLoadCallback(
3245 Handle<String> name,
3246 Handle<JSObject> receiver,
3247 Handle<JSObject> holder,
3248 Handle<AccessorInfo> callback) {
3249 // ----------- S t a t e -------------
3250 // -- ecx : key
3251 // -- edx : receiver
3252 // -- esp[0] : return address
3253 // -----------------------------------
3254 Label miss;
3255
3256 Counters* counters = isolate()->counters();
3257 __ IncrementCounter(counters->keyed_load_callback(), 1);
3258
3259 // Check that the name has not changed.
3260 __ cmp(ecx, Immediate(name));
3261 __ j(not_equal, &miss);
3262
3263 GenerateLoadCallback(receiver, holder, edx, ecx, ebx, eax, edi, no_reg,
3264 callback, name, &miss);
3265
3266 __ bind(&miss);
3267 __ DecrementCounter(counters->keyed_load_callback(), 1);
3268 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
3269
3270 // Return the generated code.
3271 return GetCode(Code::CALLBACKS, name);
3272 }
3273
3274
3275 Handle<Code> KeyedLoadStubCompiler::CompileLoadConstant(
3276 Handle<String> name,
3277 Handle<JSObject> receiver,
3278 Handle<JSObject> holder,
3279 Handle<JSFunction> value) {
3280 // ----------- S t a t e -------------
3281 // -- ecx : key
3282 // -- edx : receiver
3283 // -- esp[0] : return address
3284 // -----------------------------------
3285 Label miss;
3286
3287 Counters* counters = isolate()->counters();
3288 __ IncrementCounter(counters->keyed_load_constant_function(), 1);
3289
3290 // Check that the name has not changed.
3291 __ cmp(ecx, Immediate(name));
3292 __ j(not_equal, &miss);
3293
3294 GenerateLoadConstant(
3295 receiver, holder, edx, ebx, eax, edi, value, name, &miss);
3296 __ bind(&miss);
3297 __ DecrementCounter(counters->keyed_load_constant_function(), 1);
3298 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
3299
3300 // Return the generated code.
3301 return GetCode(Code::CONSTANT_FUNCTION, name);
3302 }
3303
3304
3305 Handle<Code> KeyedLoadStubCompiler::CompileLoadInterceptor(
3306 Handle<JSObject> receiver,
3307 Handle<JSObject> holder,
3308 Handle<String> name) {
3309 // ----------- S t a t e -------------
3310 // -- ecx : key
3311 // -- edx : receiver
3312 // -- esp[0] : return address
3313 // -----------------------------------
3314 Label miss;
3315
3316 Counters* counters = isolate()->counters();
3317 __ IncrementCounter(counters->keyed_load_interceptor(), 1);
3318
3319 // Check that the name has not changed.
3320 __ cmp(ecx, Immediate(name));
3321 __ j(not_equal, &miss);
3322
3323 LookupResult lookup(isolate());
3324 LookupPostInterceptor(holder, name, &lookup);
3325 GenerateLoadInterceptor(receiver, holder, &lookup, edx, ecx, eax, ebx, edi,
3326 name, &miss);
3327 __ bind(&miss);
3328 __ DecrementCounter(counters->keyed_load_interceptor(), 1);
3329 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
3330
3331 // Return the generated code.
3332 return GetCode(Code::INTERCEPTOR, name);
3333 }
3334
3335
3336 Handle<Code> KeyedLoadStubCompiler::CompileLoadElement( 3149 Handle<Code> KeyedLoadStubCompiler::CompileLoadElement(
3337 Handle<Map> receiver_map) { 3150 Handle<Map> receiver_map) {
3338 // ----------- S t a t e ------------- 3151 // ----------- S t a t e -------------
3339 // -- ecx : key 3152 // -- ecx : key
3340 // -- edx : receiver 3153 // -- edx : receiver
3341 // -- esp[0] : return address 3154 // -- esp[0] : return address
3342 // ----------------------------------- 3155 // -----------------------------------
3343 3156
3344 ElementsKind elements_kind = receiver_map->elements_kind(); 3157 ElementsKind elements_kind = receiver_map->elements_kind();
3345 if (receiver_map->has_fast_elements() || 3158 if (receiver_map->has_fast_elements() ||
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
4104 __ jmp(ic_slow, RelocInfo::CODE_TARGET); 3917 __ jmp(ic_slow, RelocInfo::CODE_TARGET);
4105 } 3918 }
4106 } 3919 }
4107 3920
4108 3921
4109 #undef __ 3922 #undef __
4110 3923
4111 } } // namespace v8::internal 3924 } } // namespace v8::internal
4112 3925
4113 #endif // V8_TARGET_ARCH_IA32 3926 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/arm/stub-cache-arm.cc ('k') | src/stub-cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698