@@ -1112,7 +1112,39 @@ void LoadIC::UpdateCaches(LookupIterator* lookup) {
11121112 code = slow_stub ();
11131113 }
11141114 } else {
1115- code = ComputeHandler (lookup);
1115+ if (lookup->state () == LookupIterator::ACCESSOR) {
1116+ Handle<Object> accessors = lookup->GetAccessors ();
1117+ Handle<Map> map = receiver_map ();
1118+ if (accessors->IsExecutableAccessorInfo ()) {
1119+ Handle<ExecutableAccessorInfo> info =
1120+ Handle<ExecutableAccessorInfo>::cast (accessors);
1121+ if ((v8::ToCData<Address>(info->getter ()) != 0 ) &&
1122+ !ExecutableAccessorInfo::IsCompatibleReceiverMap (isolate (), info,
1123+ map)) {
1124+ TRACE_GENERIC_IC (isolate (), " LoadIC" , " incompatible receiver type" );
1125+ code = slow_stub ();
1126+ }
1127+ } else if (accessors->IsAccessorPair ()) {
1128+ Handle<Object> getter (Handle<AccessorPair>::cast (accessors)->getter (),
1129+ isolate ());
1130+ Handle<JSObject> holder = lookup->GetHolder <JSObject>();
1131+ Handle<Object> receiver = lookup->GetReceiver ();
1132+ if (getter->IsJSFunction () && holder->HasFastProperties ()) {
1133+ Handle<JSFunction> function = Handle<JSFunction>::cast (getter);
1134+ if (receiver->IsJSObject () || function->IsBuiltin () ||
1135+ !is_sloppy (function->shared ()->language_mode ())) {
1136+ CallOptimization call_optimization (function);
1137+ if (call_optimization.is_simple_api_call () &&
1138+ !call_optimization.IsCompatibleReceiver (receiver, holder)) {
1139+ TRACE_GENERIC_IC (isolate (), " LoadIC" ,
1140+ " incompatible receiver type" );
1141+ code = slow_stub ();
1142+ }
1143+ }
1144+ }
1145+ }
1146+ }
1147+ if (code.is_null ()) code = ComputeHandler (lookup);
11161148 }
11171149
11181150 PatchCache (lookup->name (), code);
@@ -1242,6 +1274,8 @@ Handle<Code> LoadIC::CompileHandler(LookupIterator* lookup,
12421274 if (v8::ToCData<Address>(info->getter ()) == 0 ) break ;
12431275 if (!ExecutableAccessorInfo::IsCompatibleReceiverMap (isolate (), info,
12441276 map)) {
1277+ // This case should be already handled in LoadIC::UpdateCaches.
1278+ UNREACHABLE ();
12451279 break ;
12461280 }
12471281 if (!holder->HasFastProperties ()) break ;
@@ -1262,10 +1296,14 @@ Handle<Code> LoadIC::CompileHandler(LookupIterator* lookup,
12621296 }
12631297 CallOptimization call_optimization (function);
12641298 NamedLoadHandlerCompiler compiler (isolate (), map, holder, cache_holder);
1265- if (call_optimization.is_simple_api_call () &&
1266- call_optimization.IsCompatibleReceiver (receiver, holder)) {
1267- return compiler.CompileLoadCallback (lookup->name (), call_optimization,
1268- lookup->GetAccessorIndex ());
1299+ if (call_optimization.is_simple_api_call ()) {
1300+ if (call_optimization.IsCompatibleReceiver (receiver, holder)) {
1301+ return compiler.CompileLoadCallback (
1302+ lookup->name (), call_optimization, lookup->GetAccessorIndex ());
1303+ } else {
1304+ // This case should be already handled in LoadIC::UpdateCaches.
1305+ UNREACHABLE ();
1306+ }
12691307 }
12701308 int expected_arguments =
12711309 function->shared ()->internal_formal_parameter_count ();
0 commit comments