Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api.h" | 8 #include "src/api.h" |
| 9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 932 // Use specialized code for getting prototype of functions. | 932 // Use specialized code for getting prototype of functions. |
| 933 if (object->IsJSFunction() && | 933 if (object->IsJSFunction() && |
| 934 String::Equals(isolate()->factory()->prototype_string(), name) && | 934 String::Equals(isolate()->factory()->prototype_string(), name) && |
| 935 Handle<JSFunction>::cast(object)->should_have_prototype() && | 935 Handle<JSFunction>::cast(object)->should_have_prototype() && |
| 936 !Handle<JSFunction>::cast(object)->map()->has_non_instance_prototype()) { | 936 !Handle<JSFunction>::cast(object)->map()->has_non_instance_prototype()) { |
| 937 Handle<Code> stub; | 937 Handle<Code> stub; |
| 938 FunctionPrototypeStub function_prototype_stub(isolate()); | 938 FunctionPrototypeStub function_prototype_stub(isolate()); |
| 939 return function_prototype_stub.GetCode(); | 939 return function_prototype_stub.GetCode(); |
| 940 } | 940 } |
| 941 | 941 |
| 942 Handle<HeapType> type = receiver_type(); | 942 Handle<HeapType> type = receiver_type(); |
|
Igor Sheludko
2014/07/30 09:19:46
You replaced half of the |type| usages with the |r
| |
| 943 Handle<JSObject> holder(lookup->holder()); | 943 Handle<JSObject> holder(lookup->holder()); |
| 944 bool receiver_is_holder = object.is_identical_to(holder); | 944 bool receiver_is_holder = object.is_identical_to(holder); |
| 945 NamedLoadHandlerCompiler compiler(isolate(), cache_holder); | 945 NamedLoadHandlerCompiler compiler(isolate(), receiver_type(), cache_holder); |
| 946 | 946 |
| 947 switch (lookup->type()) { | 947 switch (lookup->type()) { |
| 948 case FIELD: { | 948 case FIELD: { |
| 949 FieldIndex field = lookup->GetFieldIndex(); | 949 FieldIndex field = lookup->GetFieldIndex(); |
| 950 if (receiver_is_holder) { | 950 if (receiver_is_holder) { |
| 951 return SimpleFieldLoad(field); | 951 return SimpleFieldLoad(field); |
| 952 } | 952 } |
| 953 return compiler.CompileLoadField( | 953 return compiler.CompileLoadField(holder, name, field, |
| 954 type, holder, name, field, lookup->representation()); | 954 lookup->representation()); |
| 955 } | 955 } |
| 956 case CONSTANT: { | 956 case CONSTANT: { |
| 957 Handle<Object> constant(lookup->GetConstant(), isolate()); | 957 Handle<Object> constant(lookup->GetConstant(), isolate()); |
| 958 return compiler.CompileLoadConstant(type, holder, name, constant); | 958 return compiler.CompileLoadConstant(holder, name, constant); |
| 959 } | 959 } |
| 960 case NORMAL: | 960 case NORMAL: |
| 961 if (kind() != Code::LOAD_IC) break; | 961 if (kind() != Code::LOAD_IC) break; |
| 962 if (holder->IsGlobalObject()) { | 962 if (holder->IsGlobalObject()) { |
| 963 Handle<GlobalObject> global = Handle<GlobalObject>::cast(holder); | 963 Handle<GlobalObject> global = Handle<GlobalObject>::cast(holder); |
| 964 Handle<PropertyCell> cell( | 964 Handle<PropertyCell> cell( |
| 965 global->GetPropertyCell(lookup), isolate()); | 965 global->GetPropertyCell(lookup), isolate()); |
| 966 Handle<Code> code = compiler.CompileLoadGlobal( | 966 Handle<Code> code = compiler.CompileLoadGlobal(global, cell, name, |
| 967 type, global, cell, name, lookup->IsDontDelete()); | 967 lookup->IsDontDelete()); |
| 968 // TODO(verwaest): Move caching of these NORMAL stubs outside as well. | 968 // TODO(verwaest): Move caching of these NORMAL stubs outside as well. |
| 969 CacheHolderFlag flag; | 969 CacheHolderFlag flag; |
| 970 Handle<Map> stub_holder_map = | 970 Handle<Map> stub_holder_map = |
| 971 GetHandlerCacheHolder(*type, receiver_is_holder, isolate(), &flag); | 971 GetHandlerCacheHolder(*type, receiver_is_holder, isolate(), &flag); |
| 972 Map::UpdateCodeCache(stub_holder_map, name, code); | 972 Map::UpdateCodeCache(stub_holder_map, name, code); |
| 973 return code; | 973 return code; |
| 974 } | 974 } |
| 975 // There is only one shared stub for loading normalized | 975 // There is only one shared stub for loading normalized |
| 976 // properties. It does not traverse the prototype chain, so the | 976 // properties. It does not traverse the prototype chain, so the |
| 977 // property must be found in the object for the stub to be | 977 // property must be found in the object for the stub to be |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 990 object_offset, receiver->map()); | 990 object_offset, receiver->map()); |
| 991 return SimpleFieldLoad(index); | 991 return SimpleFieldLoad(index); |
| 992 } | 992 } |
| 993 } | 993 } |
| 994 | 994 |
| 995 Handle<Object> callback(lookup->GetCallbackObject(), isolate()); | 995 Handle<Object> callback(lookup->GetCallbackObject(), isolate()); |
| 996 if (callback->IsExecutableAccessorInfo()) { | 996 if (callback->IsExecutableAccessorInfo()) { |
| 997 Handle<ExecutableAccessorInfo> info = | 997 Handle<ExecutableAccessorInfo> info = |
| 998 Handle<ExecutableAccessorInfo>::cast(callback); | 998 Handle<ExecutableAccessorInfo>::cast(callback); |
| 999 if (v8::ToCData<Address>(info->getter()) == 0) break; | 999 if (v8::ToCData<Address>(info->getter()) == 0) break; |
| 1000 if (!info->IsCompatibleReceiver(*object)) break; | 1000 Handle<Map> map = TypeToMap(*receiver_type(), isolate()); |
| 1001 return compiler.CompileLoadCallback(type, holder, name, info); | 1001 if (info->HasExpectedReceiverType() && |
| 1002 !info->IsCompatibleReceiver(*map)) { | |
|
Igor Sheludko
2014/07/30 09:19:46
Consider
!info->IsCompatibleReceiver(TypeToMap(
| |
| 1003 break; | |
| 1004 } | |
| 1005 return compiler.CompileLoadCallback(holder, name, info); | |
| 1002 } else if (callback->IsAccessorPair()) { | 1006 } else if (callback->IsAccessorPair()) { |
| 1003 Handle<Object> getter(Handle<AccessorPair>::cast(callback)->getter(), | 1007 Handle<Object> getter(Handle<AccessorPair>::cast(callback)->getter(), |
| 1004 isolate()); | 1008 isolate()); |
| 1005 if (!getter->IsJSFunction()) break; | 1009 if (!getter->IsJSFunction()) break; |
| 1006 if (holder->IsGlobalObject()) break; | 1010 if (holder->IsGlobalObject()) break; |
| 1007 if (!holder->HasFastProperties()) break; | 1011 if (!holder->HasFastProperties()) break; |
| 1008 Handle<JSFunction> function = Handle<JSFunction>::cast(getter); | 1012 Handle<JSFunction> function = Handle<JSFunction>::cast(getter); |
| 1009 if (!object->IsJSObject() && | 1013 if (!object->IsJSObject() && |
| 1010 !function->IsBuiltin() && | 1014 !function->IsBuiltin() && |
| 1011 function->shared()->strict_mode() == SLOPPY) { | 1015 function->shared()->strict_mode() == SLOPPY) { |
| 1012 // Calling sloppy non-builtins with a value as the receiver | 1016 // Calling sloppy non-builtins with a value as the receiver |
| 1013 // requires boxing. | 1017 // requires boxing. |
| 1014 break; | 1018 break; |
| 1015 } | 1019 } |
| 1016 CallOptimization call_optimization(function); | 1020 CallOptimization call_optimization(function); |
| 1017 if (call_optimization.is_simple_api_call() && | 1021 if (call_optimization.is_simple_api_call() && |
| 1018 call_optimization.IsCompatibleReceiver(object, holder)) { | 1022 call_optimization.IsCompatibleReceiver(object, holder)) { |
| 1019 return compiler.CompileLoadCallback( | 1023 return compiler.CompileLoadCallback(holder, name, call_optimization); |
| 1020 type, holder, name, call_optimization); | |
| 1021 } | 1024 } |
| 1022 return compiler.CompileLoadViaGetter(type, holder, name, function); | 1025 return compiler.CompileLoadViaGetter(holder, name, function); |
| 1023 } | 1026 } |
| 1024 // TODO(dcarney): Handle correctly. | 1027 // TODO(dcarney): Handle correctly. |
| 1025 ASSERT(callback->IsDeclaredAccessorInfo()); | 1028 ASSERT(callback->IsDeclaredAccessorInfo()); |
| 1026 break; | 1029 break; |
| 1027 } | 1030 } |
| 1028 case INTERCEPTOR: | 1031 case INTERCEPTOR: |
| 1029 ASSERT(HasInterceptorGetter(*holder)); | 1032 ASSERT(HasInterceptorGetter(*holder)); |
| 1030 return compiler.CompileLoadInterceptor(type, holder, name); | 1033 return compiler.CompileLoadInterceptor(holder, name); |
| 1031 default: | 1034 default: |
| 1032 break; | 1035 break; |
| 1033 } | 1036 } |
| 1034 | 1037 |
| 1035 return slow_stub(); | 1038 return slow_stub(); |
| 1036 } | 1039 } |
| 1037 | 1040 |
| 1038 | 1041 |
| 1039 static Handle<Object> TryConvertKey(Handle<Object> key, Isolate* isolate) { | 1042 static Handle<Object> TryConvertKey(Handle<Object> key, Isolate* isolate) { |
| 1040 // This helper implements a few common fast cases for converting | 1043 // This helper implements a few common fast cases for converting |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1385 Handle<Object> object, Handle<String> name, | 1388 Handle<Object> object, Handle<String> name, |
| 1386 Handle<Object> value, | 1389 Handle<Object> value, |
| 1387 CacheHolderFlag cache_holder) { | 1390 CacheHolderFlag cache_holder) { |
| 1388 if (object->IsAccessCheckNeeded()) return slow_stub(); | 1391 if (object->IsAccessCheckNeeded()) return slow_stub(); |
| 1389 ASSERT(cache_holder == kCacheOnReceiver || lookup->type() == CALLBACKS || | 1392 ASSERT(cache_holder == kCacheOnReceiver || lookup->type() == CALLBACKS || |
| 1390 (object->IsJSGlobalProxy() && lookup->holder()->IsJSGlobalObject())); | 1393 (object->IsJSGlobalProxy() && lookup->holder()->IsJSGlobalObject())); |
| 1391 // This is currently guaranteed by checks in StoreIC::Store. | 1394 // This is currently guaranteed by checks in StoreIC::Store. |
| 1392 Handle<JSObject> receiver = Handle<JSObject>::cast(object); | 1395 Handle<JSObject> receiver = Handle<JSObject>::cast(object); |
| 1393 | 1396 |
| 1394 Handle<JSObject> holder(lookup->holder()); | 1397 Handle<JSObject> holder(lookup->holder()); |
| 1395 NamedStoreHandlerCompiler compiler(isolate()); | 1398 NamedStoreHandlerCompiler compiler(isolate(), receiver_type()); |
| 1396 | 1399 |
| 1397 if (lookup->IsTransition()) { | 1400 if (lookup->IsTransition()) { |
| 1398 // Explicitly pass in the receiver map since LookupForWrite may have | 1401 // Explicitly pass in the receiver map since LookupForWrite may have |
| 1399 // stored something else than the receiver in the holder. | 1402 // stored something else than the receiver in the holder. |
| 1400 Handle<Map> transition(lookup->GetTransitionTarget()); | 1403 Handle<Map> transition(lookup->GetTransitionTarget()); |
| 1401 PropertyDetails details = lookup->GetPropertyDetails(); | 1404 PropertyDetails details = lookup->GetPropertyDetails(); |
| 1402 | 1405 |
| 1403 if (details.type() != CALLBACKS && details.attributes() == NONE) { | 1406 if (details.type() != CALLBACKS && details.attributes() == NONE) { |
| 1404 return compiler.CompileStoreTransition( | 1407 return compiler.CompileStoreTransition( |
| 1405 receiver, lookup, transition, name); | 1408 receiver, lookup, transition, name); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 1431 } | 1434 } |
| 1432 ASSERT(holder.is_identical_to(receiver)); | 1435 ASSERT(holder.is_identical_to(receiver)); |
| 1433 return isolate()->builtins()->StoreIC_Normal(); | 1436 return isolate()->builtins()->StoreIC_Normal(); |
| 1434 case CALLBACKS: { | 1437 case CALLBACKS: { |
| 1435 Handle<Object> callback(lookup->GetCallbackObject(), isolate()); | 1438 Handle<Object> callback(lookup->GetCallbackObject(), isolate()); |
| 1436 if (callback->IsExecutableAccessorInfo()) { | 1439 if (callback->IsExecutableAccessorInfo()) { |
| 1437 Handle<ExecutableAccessorInfo> info = | 1440 Handle<ExecutableAccessorInfo> info = |
| 1438 Handle<ExecutableAccessorInfo>::cast(callback); | 1441 Handle<ExecutableAccessorInfo>::cast(callback); |
| 1439 if (v8::ToCData<Address>(info->setter()) == 0) break; | 1442 if (v8::ToCData<Address>(info->setter()) == 0) break; |
| 1440 if (!holder->HasFastProperties()) break; | 1443 if (!holder->HasFastProperties()) break; |
| 1441 if (!info->IsCompatibleReceiver(*receiver)) break; | 1444 Handle<Map> map = TypeToMap(*receiver_type(), isolate()); |
| 1445 if (info->HasExpectedReceiverType() && | |
| 1446 !info->IsCompatibleReceiver(*map)) { | |
|
Igor Sheludko
2014/07/30 09:19:46
Same here.
| |
| 1447 break; | |
| 1448 } | |
| 1442 return compiler.CompileStoreCallback(receiver, holder, name, info); | 1449 return compiler.CompileStoreCallback(receiver, holder, name, info); |
| 1443 } else if (callback->IsAccessorPair()) { | 1450 } else if (callback->IsAccessorPair()) { |
| 1444 Handle<Object> setter( | 1451 Handle<Object> setter( |
| 1445 Handle<AccessorPair>::cast(callback)->setter(), isolate()); | 1452 Handle<AccessorPair>::cast(callback)->setter(), isolate()); |
| 1446 if (!setter->IsJSFunction()) break; | 1453 if (!setter->IsJSFunction()) break; |
| 1447 if (holder->IsGlobalObject()) break; | 1454 if (holder->IsGlobalObject()) break; |
| 1448 if (!holder->HasFastProperties()) break; | 1455 if (!holder->HasFastProperties()) break; |
| 1449 Handle<JSFunction> function = Handle<JSFunction>::cast(setter); | 1456 Handle<JSFunction> function = Handle<JSFunction>::cast(setter); |
| 1450 CallOptimization call_optimization(function); | 1457 CallOptimization call_optimization(function); |
| 1451 if (call_optimization.is_simple_api_call() && | 1458 if (call_optimization.is_simple_api_call() && |
| (...skipping 1583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3035 #undef ADDR | 3042 #undef ADDR |
| 3036 }; | 3043 }; |
| 3037 | 3044 |
| 3038 | 3045 |
| 3039 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 3046 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
| 3040 return IC_utilities[id]; | 3047 return IC_utilities[id]; |
| 3041 } | 3048 } |
| 3042 | 3049 |
| 3043 | 3050 |
| 3044 } } // namespace v8::internal | 3051 } } // namespace v8::internal |
| OLD | NEW |