| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2995 &miss); | 2995 &miss); |
| 2996 | 2996 |
| 2997 __ bind(&miss); | 2997 __ bind(&miss); |
| 2998 GenerateLoadMiss(masm(), Code::LOAD_IC); | 2998 GenerateLoadMiss(masm(), Code::LOAD_IC); |
| 2999 | 2999 |
| 3000 // Return the generated code. | 3000 // Return the generated code. |
| 3001 return TryGetCode(INTERCEPTOR, name); | 3001 return TryGetCode(INTERCEPTOR, name); |
| 3002 } | 3002 } |
| 3003 | 3003 |
| 3004 | 3004 |
| 3005 MaybeObject* LoadStubCompiler::CompileLoadGlobal(JSObject* object, | 3005 Handle<Code> LoadStubCompiler::CompileLoadGlobal( |
| 3006 GlobalObject* holder, | 3006 Handle<JSObject> object, |
| 3007 JSGlobalPropertyCell* cell, | 3007 Handle<GlobalObject> holder, |
| 3008 String* name, | 3008 Handle<JSGlobalPropertyCell> cell, |
| 3009 bool is_dont_delete) { | 3009 Handle<String> name, |
| 3010 bool is_dont_delete) { |
| 3010 // ----------- S t a t e ------------- | 3011 // ----------- S t a t e ------------- |
| 3011 // -- rax : receiver | 3012 // -- rax : receiver |
| 3012 // -- rcx : name | 3013 // -- rcx : name |
| 3013 // -- rsp[0] : return address | 3014 // -- rsp[0] : return address |
| 3014 // ----------------------------------- | 3015 // ----------------------------------- |
| 3015 Label miss; | 3016 Label miss; |
| 3016 | 3017 |
| 3017 // If the object is the holder then we know that it's a global | 3018 // If the object is the holder then we know that it's a global |
| 3018 // object which can only happen for contextual loads. In this case, | 3019 // object which can only happen for contextual loads. In this case, |
| 3019 // the receiver cannot be a smi. | 3020 // the receiver cannot be a smi. |
| 3020 if (object != holder) { | 3021 if (!object.is_identical_to(holder)) { |
| 3021 __ JumpIfSmi(rax, &miss); | 3022 __ JumpIfSmi(rax, &miss); |
| 3022 } | 3023 } |
| 3023 | 3024 |
| 3024 // Check that the maps haven't changed. | 3025 // Check that the maps haven't changed. |
| 3025 CheckPrototypes(object, rax, holder, rbx, rdx, rdi, name, &miss); | 3026 CheckPrototypes(object, rax, holder, rbx, rdx, rdi, name, &miss); |
| 3026 | 3027 |
| 3027 // Get the value from the cell. | 3028 // Get the value from the cell. |
| 3028 __ Move(rbx, Handle<JSGlobalPropertyCell>(cell)); | 3029 __ Move(rbx, cell); |
| 3029 __ movq(rbx, FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset)); | 3030 __ movq(rbx, FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset)); |
| 3030 | 3031 |
| 3031 // Check for deleted property if property can actually be deleted. | 3032 // Check for deleted property if property can actually be deleted. |
| 3032 if (!is_dont_delete) { | 3033 if (!is_dont_delete) { |
| 3033 __ CompareRoot(rbx, Heap::kTheHoleValueRootIndex); | 3034 __ CompareRoot(rbx, Heap::kTheHoleValueRootIndex); |
| 3034 __ j(equal, &miss); | 3035 __ j(equal, &miss); |
| 3035 } else if (FLAG_debug_code) { | 3036 } else if (FLAG_debug_code) { |
| 3036 __ CompareRoot(rbx, Heap::kTheHoleValueRootIndex); | 3037 __ CompareRoot(rbx, Heap::kTheHoleValueRootIndex); |
| 3037 __ Check(not_equal, "DontDelete cells can't contain the hole"); | 3038 __ Check(not_equal, "DontDelete cells can't contain the hole"); |
| 3038 } | 3039 } |
| 3039 | 3040 |
| 3040 Counters* counters = isolate()->counters(); | 3041 Counters* counters = isolate()->counters(); |
| 3041 __ IncrementCounter(counters->named_load_global_stub(), 1); | 3042 __ IncrementCounter(counters->named_load_global_stub(), 1); |
| 3042 __ movq(rax, rbx); | 3043 __ movq(rax, rbx); |
| 3043 __ ret(0); | 3044 __ ret(0); |
| 3044 | 3045 |
| 3045 __ bind(&miss); | 3046 __ bind(&miss); |
| 3046 __ IncrementCounter(counters->named_load_global_stub_miss(), 1); | 3047 __ IncrementCounter(counters->named_load_global_stub_miss(), 1); |
| 3047 GenerateLoadMiss(masm(), Code::LOAD_IC); | 3048 GenerateLoadMiss(masm(), Code::LOAD_IC); |
| 3048 | 3049 |
| 3049 // Return the generated code. | 3050 // Return the generated code. |
| 3050 return TryGetCode(NORMAL, name); | 3051 return GetCode(NORMAL, name); |
| 3051 } | 3052 } |
| 3052 | 3053 |
| 3053 | 3054 |
| 3054 Handle<Code> KeyedLoadStubCompiler::CompileLoadField(Handle<String> name, | 3055 Handle<Code> KeyedLoadStubCompiler::CompileLoadField(Handle<String> name, |
| 3055 Handle<JSObject> receiver, | 3056 Handle<JSObject> receiver, |
| 3056 Handle<JSObject> holder, | 3057 Handle<JSObject> holder, |
| 3057 int index) { | 3058 int index) { |
| 3058 // ----------- S t a t e ------------- | 3059 // ----------- S t a t e ------------- |
| 3059 // -- rax : key | 3060 // -- rax : key |
| 3060 // -- rdx : receiver | 3061 // -- rdx : receiver |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3255 GenerateLoadFunctionPrototype(masm(), rdx, rcx, rbx, &miss); | 3256 GenerateLoadFunctionPrototype(masm(), rdx, rcx, rbx, &miss); |
| 3256 __ bind(&miss); | 3257 __ bind(&miss); |
| 3257 __ DecrementCounter(counters->keyed_load_function_prototype(), 1); | 3258 __ DecrementCounter(counters->keyed_load_function_prototype(), 1); |
| 3258 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); | 3259 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); |
| 3259 | 3260 |
| 3260 // Return the generated code. | 3261 // Return the generated code. |
| 3261 return GetCode(CALLBACKS, name); | 3262 return GetCode(CALLBACKS, name); |
| 3262 } | 3263 } |
| 3263 | 3264 |
| 3264 | 3265 |
| 3265 MaybeObject* KeyedLoadStubCompiler::CompileLoadElement(Map* receiver_map) { | 3266 Handle<Code> KeyedLoadStubCompiler::CompileLoadElement( |
| 3267 Handle<Map> receiver_map) { |
| 3266 // ----------- S t a t e ------------- | 3268 // ----------- S t a t e ------------- |
| 3267 // -- rax : key | 3269 // -- rax : key |
| 3268 // -- rdx : receiver | 3270 // -- rdx : receiver |
| 3269 // -- rsp[0] : return address | 3271 // -- rsp[0] : return address |
| 3270 // ----------------------------------- | 3272 // ----------------------------------- |
| 3271 Code* stub; | |
| 3272 ElementsKind elements_kind = receiver_map->elements_kind(); | 3273 ElementsKind elements_kind = receiver_map->elements_kind(); |
| 3273 MaybeObject* maybe_stub = KeyedLoadElementStub(elements_kind).TryGetCode(); | 3274 Handle<Code> stub = KeyedLoadElementStub(elements_kind).GetCode(); |
| 3274 if (!maybe_stub->To(&stub)) return maybe_stub; | 3275 |
| 3275 __ DispatchMap(rdx, | 3276 __ DispatchMap(rdx, |
| 3276 Handle<Map>(receiver_map), | 3277 receiver_map, |
| 3277 Handle<Code>(stub), | 3278 stub, |
| 3278 DO_SMI_CHECK); | 3279 DO_SMI_CHECK); |
| 3279 | 3280 |
| 3280 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Miss(); | 3281 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Miss(); |
| 3281 __ jmp(ic, RelocInfo::CODE_TARGET); | 3282 __ jmp(ic, RelocInfo::CODE_TARGET); |
| 3282 | 3283 |
| 3283 // Return the generated code. | 3284 // Return the generated code. |
| 3284 return TryGetCode(NORMAL, NULL); | 3285 return GetCode(NORMAL, factory()->empty_string()); |
| 3285 } | 3286 } |
| 3286 | 3287 |
| 3287 | 3288 |
| 3288 MaybeObject* KeyedLoadStubCompiler::CompileLoadPolymorphic( | 3289 Handle<Code> KeyedLoadStubCompiler::CompileLoadPolymorphic( |
| 3289 MapList* receiver_maps, | 3290 MapHandleList* receiver_maps, |
| 3290 CodeList* handler_ics) { | 3291 CodeHandleList* handler_ics) { |
| 3291 // ----------- S t a t e ------------- | 3292 // ----------- S t a t e ------------- |
| 3292 // -- rax : key | 3293 // -- rax : key |
| 3293 // -- rdx : receiver | 3294 // -- rdx : receiver |
| 3294 // -- rsp[0] : return address | 3295 // -- rsp[0] : return address |
| 3295 // ----------------------------------- | 3296 // ----------------------------------- |
| 3296 Label miss; | 3297 Label miss; |
| 3297 __ JumpIfSmi(rdx, &miss); | 3298 __ JumpIfSmi(rdx, &miss); |
| 3298 | 3299 |
| 3299 Register map_reg = rbx; | 3300 Register map_reg = rbx; |
| 3300 __ movq(map_reg, FieldOperand(rdx, HeapObject::kMapOffset)); | 3301 __ movq(map_reg, FieldOperand(rdx, HeapObject::kMapOffset)); |
| 3301 int receiver_count = receiver_maps->length(); | 3302 int receiver_count = receiver_maps->length(); |
| 3302 for (int current = 0; current < receiver_count; ++current) { | 3303 for (int current = 0; current < receiver_count; ++current) { |
| 3303 // Check map and tail call if there's a match | 3304 // Check map and tail call if there's a match |
| 3304 Handle<Map> map(receiver_maps->at(current)); | 3305 __ Cmp(map_reg, receiver_maps->at(current)); |
| 3305 __ Cmp(map_reg, map); | 3306 __ j(equal, handler_ics->at(current), RelocInfo::CODE_TARGET); |
| 3306 __ j(equal, | |
| 3307 Handle<Code>(handler_ics->at(current)), | |
| 3308 RelocInfo::CODE_TARGET); | |
| 3309 } | 3307 } |
| 3310 | 3308 |
| 3311 __ bind(&miss); | 3309 __ bind(&miss); |
| 3312 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); | 3310 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); |
| 3313 | 3311 |
| 3314 // Return the generated code. | 3312 // Return the generated code. |
| 3315 return TryGetCode(NORMAL, NULL, MEGAMORPHIC); | 3313 return GetCode(NORMAL, factory()->empty_string(), MEGAMORPHIC); |
| 3316 } | 3314 } |
| 3317 | 3315 |
| 3318 | 3316 |
| 3319 // Specialized stub for constructing objects from functions which only have only | 3317 // Specialized stub for constructing objects from functions which only have only |
| 3320 // simple assignments of the form this.x = ...; in their body. | 3318 // simple assignments of the form this.x = ...; in their body. |
| 3321 MaybeObject* ConstructStubCompiler::CompileConstructStub(JSFunction* function) { | 3319 MaybeObject* ConstructStubCompiler::CompileConstructStub(JSFunction* function) { |
| 3322 // ----------- S t a t e ------------- | 3320 // ----------- S t a t e ------------- |
| 3323 // -- rax : argc | 3321 // -- rax : argc |
| 3324 // -- rdi : constructor | 3322 // -- rdi : constructor |
| 3325 // -- rsp[0] : return address | 3323 // -- rsp[0] : return address |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4021 Handle<Code> ic_miss = masm->isolate()->builtins()->KeyedStoreIC_Miss(); | 4019 Handle<Code> ic_miss = masm->isolate()->builtins()->KeyedStoreIC_Miss(); |
| 4022 __ jmp(ic_miss, RelocInfo::CODE_TARGET); | 4020 __ jmp(ic_miss, RelocInfo::CODE_TARGET); |
| 4023 } | 4021 } |
| 4024 | 4022 |
| 4025 | 4023 |
| 4026 #undef __ | 4024 #undef __ |
| 4027 | 4025 |
| 4028 } } // namespace v8::internal | 4026 } } // namespace v8::internal |
| 4029 | 4027 |
| 4030 #endif // V8_TARGET_ARCH_X64 | 4028 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |