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/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 } else if (!lookup->IsFound()) { | 1028 } else if (!lookup->IsFound()) { |
1029 if (kind() == Code::LOAD_IC && !is_strong(language_mode())) { | 1029 if (kind() == Code::LOAD_IC && !is_strong(language_mode())) { |
1030 code = NamedLoadHandlerCompiler::ComputeLoadNonexistent(lookup->name(), | 1030 code = NamedLoadHandlerCompiler::ComputeLoadNonexistent(lookup->name(), |
1031 receiver_map()); | 1031 receiver_map()); |
1032 // TODO(jkummerow/verwaest): Introduce a builtin that handles this case. | 1032 // TODO(jkummerow/verwaest): Introduce a builtin that handles this case. |
1033 if (code.is_null()) code = slow_stub(); | 1033 if (code.is_null()) code = slow_stub(); |
1034 } else { | 1034 } else { |
1035 code = slow_stub(); | 1035 code = slow_stub(); |
1036 } | 1036 } |
1037 } else { | 1037 } else { |
1038 code = ComputeHandler(lookup); | 1038 if (lookup->state() == LookupIterator::ACCESSOR) { |
| 1039 Handle<Object> accessors = lookup->GetAccessors(); |
| 1040 Handle<Map> map = receiver_map(); |
| 1041 if (accessors->IsExecutableAccessorInfo()) { |
| 1042 Handle<ExecutableAccessorInfo> info = |
| 1043 Handle<ExecutableAccessorInfo>::cast(accessors); |
| 1044 if ((v8::ToCData<Address>(info->getter()) != 0) && |
| 1045 !ExecutableAccessorInfo::IsCompatibleReceiverMap(isolate(), info, |
| 1046 map)) { |
| 1047 TRACE_GENERIC_IC(isolate(), "LoadIC", "incompatible receiver type"); |
| 1048 code = slow_stub(); |
| 1049 } |
| 1050 } else if (accessors->IsAccessorPair()) { |
| 1051 Handle<Object> getter(Handle<AccessorPair>::cast(accessors)->getter(), |
| 1052 isolate()); |
| 1053 Handle<JSObject> holder = lookup->GetHolder<JSObject>(); |
| 1054 Handle<Object> receiver = lookup->GetReceiver(); |
| 1055 if (getter->IsJSFunction() && holder->HasFastProperties()) { |
| 1056 Handle<JSFunction> function = Handle<JSFunction>::cast(getter); |
| 1057 if (receiver->IsJSObject() || function->IsBuiltin() || |
| 1058 !is_sloppy(function->shared()->language_mode())) { |
| 1059 CallOptimization call_optimization(function); |
| 1060 if (call_optimization.is_simple_api_call() && |
| 1061 !call_optimization.IsCompatibleReceiver(receiver, holder)) { |
| 1062 TRACE_GENERIC_IC(isolate(), "LoadIC", |
| 1063 "incompatible receiver type"); |
| 1064 code = slow_stub(); |
| 1065 } |
| 1066 } |
| 1067 } |
| 1068 } |
| 1069 } |
| 1070 if (code.is_null()) code = ComputeHandler(lookup); |
1039 } | 1071 } |
1040 | 1072 |
1041 PatchCache(lookup->name(), code); | 1073 PatchCache(lookup->name(), code); |
1042 TRACE_IC("LoadIC", lookup->name()); | 1074 TRACE_IC("LoadIC", lookup->name()); |
1043 } | 1075 } |
1044 | 1076 |
1045 | 1077 |
1046 void IC::UpdateMegamorphicCache(Map* map, Name* name, Code* code) { | 1078 void IC::UpdateMegamorphicCache(Map* map, Name* name, Code* code) { |
1047 isolate()->stub_cache()->Set(name, map, code); | 1079 isolate()->stub_cache()->Set(name, map, code); |
1048 } | 1080 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1158 return stub.GetCode(); | 1190 return stub.GetCode(); |
1159 } | 1191 } |
1160 | 1192 |
1161 Handle<Object> accessors = lookup->GetAccessors(); | 1193 Handle<Object> accessors = lookup->GetAccessors(); |
1162 if (accessors->IsExecutableAccessorInfo()) { | 1194 if (accessors->IsExecutableAccessorInfo()) { |
1163 Handle<ExecutableAccessorInfo> info = | 1195 Handle<ExecutableAccessorInfo> info = |
1164 Handle<ExecutableAccessorInfo>::cast(accessors); | 1196 Handle<ExecutableAccessorInfo>::cast(accessors); |
1165 if (v8::ToCData<Address>(info->getter()) == 0) break; | 1197 if (v8::ToCData<Address>(info->getter()) == 0) break; |
1166 if (!ExecutableAccessorInfo::IsCompatibleReceiverMap(isolate(), info, | 1198 if (!ExecutableAccessorInfo::IsCompatibleReceiverMap(isolate(), info, |
1167 map)) { | 1199 map)) { |
| 1200 // This case should be already handled in LoadIC::UpdateCaches. |
| 1201 UNREACHABLE(); |
1168 break; | 1202 break; |
1169 } | 1203 } |
1170 if (!holder->HasFastProperties()) break; | 1204 if (!holder->HasFastProperties()) break; |
1171 NamedLoadHandlerCompiler compiler(isolate(), map, holder, cache_holder); | 1205 NamedLoadHandlerCompiler compiler(isolate(), map, holder, cache_holder); |
1172 return compiler.CompileLoadCallback(lookup->name(), info); | 1206 return compiler.CompileLoadCallback(lookup->name(), info); |
1173 } | 1207 } |
1174 if (accessors->IsAccessorPair()) { | 1208 if (accessors->IsAccessorPair()) { |
1175 Handle<Object> getter(Handle<AccessorPair>::cast(accessors)->getter(), | 1209 Handle<Object> getter(Handle<AccessorPair>::cast(accessors)->getter(), |
1176 isolate()); | 1210 isolate()); |
1177 if (!getter->IsJSFunction()) break; | 1211 if (!getter->IsJSFunction()) break; |
1178 if (!holder->HasFastProperties()) break; | 1212 if (!holder->HasFastProperties()) break; |
1179 Handle<JSFunction> function = Handle<JSFunction>::cast(getter); | 1213 Handle<JSFunction> function = Handle<JSFunction>::cast(getter); |
1180 if (!receiver->IsJSObject() && !function->IsBuiltin() && | 1214 if (!receiver->IsJSObject() && !function->IsBuiltin() && |
1181 is_sloppy(function->shared()->language_mode())) { | 1215 is_sloppy(function->shared()->language_mode())) { |
1182 // Calling sloppy non-builtins with a value as the receiver | 1216 // Calling sloppy non-builtins with a value as the receiver |
1183 // requires boxing. | 1217 // requires boxing. |
1184 break; | 1218 break; |
1185 } | 1219 } |
1186 CallOptimization call_optimization(function); | 1220 CallOptimization call_optimization(function); |
1187 NamedLoadHandlerCompiler compiler(isolate(), map, holder, cache_holder); | 1221 NamedLoadHandlerCompiler compiler(isolate(), map, holder, cache_holder); |
1188 if (call_optimization.is_simple_api_call() && | 1222 if (call_optimization.is_simple_api_call()) { |
1189 call_optimization.IsCompatibleReceiver(receiver, holder)) { | 1223 if (call_optimization.IsCompatibleReceiver(receiver, holder)) { |
1190 return compiler.CompileLoadCallback(lookup->name(), call_optimization, | 1224 return compiler.CompileLoadCallback( |
1191 lookup->GetAccessorIndex()); | 1225 lookup->name(), call_optimization, lookup->GetAccessorIndex()); |
| 1226 } else { |
| 1227 // This case should be already handled in LoadIC::UpdateCaches. |
| 1228 UNREACHABLE(); |
| 1229 } |
1192 } | 1230 } |
1193 int expected_arguments = | 1231 int expected_arguments = |
1194 function->shared()->internal_formal_parameter_count(); | 1232 function->shared()->internal_formal_parameter_count(); |
1195 return compiler.CompileLoadViaGetter( | 1233 return compiler.CompileLoadViaGetter( |
1196 lookup->name(), lookup->GetAccessorIndex(), expected_arguments); | 1234 lookup->name(), lookup->GetAccessorIndex(), expected_arguments); |
1197 } | 1235 } |
1198 break; | 1236 break; |
1199 } | 1237 } |
1200 | 1238 |
1201 case LookupIterator::DATA: { | 1239 case LookupIterator::DATA: { |
(...skipping 1861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3063 static const Address IC_utilities[] = { | 3101 static const Address IC_utilities[] = { |
3064 #define ADDR(name) FUNCTION_ADDR(name), | 3102 #define ADDR(name) FUNCTION_ADDR(name), |
3065 IC_UTIL_LIST(ADDR) NULL | 3103 IC_UTIL_LIST(ADDR) NULL |
3066 #undef ADDR | 3104 #undef ADDR |
3067 }; | 3105 }; |
3068 | 3106 |
3069 | 3107 |
3070 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } | 3108 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } |
3071 } // namespace internal | 3109 } // namespace internal |
3072 } // namespace v8 | 3110 } // namespace v8 |
OLD | NEW |