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

Side by Side Diff: src/ic/ic.cc

Issue 1221433010: Move compatible receiver check from CompileHandler to UpdateCaches (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « src/ic/ic.h ('k') | no next file » | 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 // 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 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 // invalid lookups later. 1091 // invalid lookups later.
1092 if (code->type() != Code::NORMAL && 1092 if (code->type() != Code::NORMAL &&
1093 Code::ExtractCacheHolderFromFlags(code->flags()) == flag) { 1093 Code::ExtractCacheHolderFromFlags(code->flags()) == flag) {
1094 Map::UpdateCodeCache(stub_holder_map, lookup->name(), code); 1094 Map::UpdateCodeCache(stub_holder_map, lookup->name(), code);
1095 } 1095 }
1096 1096
1097 return code; 1097 return code;
1098 } 1098 }
1099 1099
1100 1100
1101 Handle<Code> LoadIC::ComputeHandler(LookupIterator* lookup,
1102 Handle<Object> value) {
Toon Verwaest 2015/07/06 11:49:18 Just move this code into LoadIC::UpdateCaches, tha
1103 if (lookup->state() == LookupIterator::ACCESSOR) {
1104 Handle<Object> accessors = lookup->GetAccessors();
1105 Handle<Map> map = receiver_map();
1106 if (accessors->IsExecutableAccessorInfo()) {
1107 Handle<ExecutableAccessorInfo> info =
1108 Handle<ExecutableAccessorInfo>::cast(accessors);
1109 if ((v8::ToCData<Address>(info->getter()) != 0) &&
1110 !ExecutableAccessorInfo::IsCompatibleReceiverMap(isolate(), info,
1111 map)) {
1112 return slow_stub();
1113 }
1114 } else if (accessors->IsAccessorPair()) {
1115 Handle<Object> getter(Handle<AccessorPair>::cast(accessors)->getter(),
1116 isolate());
1117 Handle<JSObject> holder = lookup->GetHolder<JSObject>();
1118 Handle<Object> receiver = lookup->GetReceiver();
1119 if (getter->IsJSFunction() && holder->HasFastProperties()) {
1120 Handle<JSFunction> function = Handle<JSFunction>::cast(getter);
1121 if (receiver->IsJSObject() || function->IsBuiltin() ||
1122 !is_sloppy(function->shared()->language_mode())) {
1123 CallOptimization call_optimization(function);
1124 if (call_optimization.is_simple_api_call() &&
1125 !call_optimization.IsCompatibleReceiver(receiver, holder)) {
1126 return slow_stub();
1127 }
1128 }
1129 }
1130 }
1131 }
1132 return IC::ComputeHandler(lookup, value);
1133 }
1134
1135
1101 Handle<Code> LoadIC::CompileHandler(LookupIterator* lookup, 1136 Handle<Code> LoadIC::CompileHandler(LookupIterator* lookup,
1102 Handle<Object> unused, 1137 Handle<Object> unused,
1103 CacheHolderFlag cache_holder) { 1138 CacheHolderFlag cache_holder) {
1104 Handle<Object> receiver = lookup->GetReceiver(); 1139 Handle<Object> receiver = lookup->GetReceiver();
1105 if (receiver->IsString() && 1140 if (receiver->IsString() &&
1106 Name::Equals(isolate()->factory()->length_string(), lookup->name())) { 1141 Name::Equals(isolate()->factory()->length_string(), lookup->name())) {
1107 FieldIndex index = FieldIndex::ForInObjectOffset(String::kLengthOffset); 1142 FieldIndex index = FieldIndex::ForInObjectOffset(String::kLengthOffset);
1108 return SimpleFieldLoad(index); 1143 return SimpleFieldLoad(index);
1109 } 1144 }
1110 1145
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 return stub.GetCode(); 1193 return stub.GetCode();
1159 } 1194 }
1160 1195
1161 Handle<Object> accessors = lookup->GetAccessors(); 1196 Handle<Object> accessors = lookup->GetAccessors();
1162 if (accessors->IsExecutableAccessorInfo()) { 1197 if (accessors->IsExecutableAccessorInfo()) {
1163 Handle<ExecutableAccessorInfo> info = 1198 Handle<ExecutableAccessorInfo> info =
1164 Handle<ExecutableAccessorInfo>::cast(accessors); 1199 Handle<ExecutableAccessorInfo>::cast(accessors);
1165 if (v8::ToCData<Address>(info->getter()) == 0) break; 1200 if (v8::ToCData<Address>(info->getter()) == 0) break;
1166 if (!ExecutableAccessorInfo::IsCompatibleReceiverMap(isolate(), info, 1201 if (!ExecutableAccessorInfo::IsCompatibleReceiverMap(isolate(), info,
1167 map)) { 1202 map)) {
1203 // This case should be already handled in LoadIC::ComputeHandler.
1204 UNREACHABLE();
1168 break; 1205 break;
1169 } 1206 }
1170 if (!holder->HasFastProperties()) break; 1207 if (!holder->HasFastProperties()) break;
1171 NamedLoadHandlerCompiler compiler(isolate(), map, holder, cache_holder); 1208 NamedLoadHandlerCompiler compiler(isolate(), map, holder, cache_holder);
1172 return compiler.CompileLoadCallback(lookup->name(), info); 1209 return compiler.CompileLoadCallback(lookup->name(), info);
1173 } 1210 }
1174 if (accessors->IsAccessorPair()) { 1211 if (accessors->IsAccessorPair()) {
1175 Handle<Object> getter(Handle<AccessorPair>::cast(accessors)->getter(), 1212 Handle<Object> getter(Handle<AccessorPair>::cast(accessors)->getter(),
1176 isolate()); 1213 isolate());
1177 if (!getter->IsJSFunction()) break; 1214 if (!getter->IsJSFunction()) break;
1178 if (!holder->HasFastProperties()) break; 1215 if (!holder->HasFastProperties()) break;
1179 Handle<JSFunction> function = Handle<JSFunction>::cast(getter); 1216 Handle<JSFunction> function = Handle<JSFunction>::cast(getter);
1180 if (!receiver->IsJSObject() && !function->IsBuiltin() && 1217 if (!receiver->IsJSObject() && !function->IsBuiltin() &&
1181 is_sloppy(function->shared()->language_mode())) { 1218 is_sloppy(function->shared()->language_mode())) {
1182 // Calling sloppy non-builtins with a value as the receiver 1219 // Calling sloppy non-builtins with a value as the receiver
1183 // requires boxing. 1220 // requires boxing.
1184 break; 1221 break;
1185 } 1222 }
1186 CallOptimization call_optimization(function); 1223 CallOptimization call_optimization(function);
1187 NamedLoadHandlerCompiler compiler(isolate(), map, holder, cache_holder); 1224 NamedLoadHandlerCompiler compiler(isolate(), map, holder, cache_holder);
1188 if (call_optimization.is_simple_api_call() && 1225 if (call_optimization.is_simple_api_call()) {
1189 call_optimization.IsCompatibleReceiver(receiver, holder)) { 1226 if (call_optimization.IsCompatibleReceiver(receiver, holder)) {
1190 return compiler.CompileLoadCallback(lookup->name(), call_optimization, 1227 return compiler.CompileLoadCallback(
1191 lookup->GetAccessorIndex()); 1228 lookup->name(), call_optimization, lookup->GetAccessorIndex());
1229 } else {
1230 // This case should be already handled in LoadIC::ComputeHandler.
1231 UNREACHABLE();
1232 }
1192 } 1233 }
1193 int expected_arguments = 1234 int expected_arguments =
1194 function->shared()->internal_formal_parameter_count(); 1235 function->shared()->internal_formal_parameter_count();
1195 return compiler.CompileLoadViaGetter( 1236 return compiler.CompileLoadViaGetter(
1196 lookup->name(), lookup->GetAccessorIndex(), expected_arguments); 1237 lookup->name(), lookup->GetAccessorIndex(), expected_arguments);
1197 } 1238 }
1198 break; 1239 break;
1199 } 1240 }
1200 1241
1201 case LookupIterator::DATA: { 1242 case LookupIterator::DATA: {
(...skipping 1861 matching lines...) Expand 10 before | Expand all | Expand 10 after
3063 static const Address IC_utilities[] = { 3104 static const Address IC_utilities[] = {
3064 #define ADDR(name) FUNCTION_ADDR(name), 3105 #define ADDR(name) FUNCTION_ADDR(name),
3065 IC_UTIL_LIST(ADDR) NULL 3106 IC_UTIL_LIST(ADDR) NULL
3066 #undef ADDR 3107 #undef ADDR
3067 }; 3108 };
3068 3109
3069 3110
3070 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } 3111 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; }
3071 } // namespace internal 3112 } // namespace internal
3072 } // namespace v8 3113 } // namespace v8
OLDNEW
« no previous file with comments | « src/ic/ic.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698