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

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

Issue 1609233002: Do not eagerly instantiate accessors' JSFunction. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Make GCMole happy again. Created 4 years, 10 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/ia32/handler-compiler-ia32.cc ('k') | src/ic/mips/handler-compiler-mips.cc » ('j') | 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/ic/ic.h" 5 #include "src/ic/ic.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 968 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 Handle<Object> accessors = lookup->GetAccessors(); 979 Handle<Object> accessors = lookup->GetAccessors();
980 if (accessors->IsAccessorInfo()) { 980 if (accessors->IsAccessorInfo()) {
981 Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(accessors); 981 Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(accessors);
982 if (info->getter() != NULL && 982 if (info->getter() != NULL &&
983 !AccessorInfo::IsCompatibleReceiverMap(isolate, info, receiver_map)) { 983 !AccessorInfo::IsCompatibleReceiverMap(isolate, info, receiver_map)) {
984 return false; 984 return false;
985 } 985 }
986 } else if (accessors->IsAccessorPair()) { 986 } else if (accessors->IsAccessorPair()) {
987 Handle<Object> getter(Handle<AccessorPair>::cast(accessors)->getter(), 987 Handle<Object> getter(Handle<AccessorPair>::cast(accessors)->getter(),
988 isolate); 988 isolate);
989 if (!getter->IsJSFunction() && !getter->IsFunctionTemplateInfo())
990 return false;
989 Handle<JSObject> holder = lookup->GetHolder<JSObject>(); 991 Handle<JSObject> holder = lookup->GetHolder<JSObject>();
990 Handle<Object> receiver = lookup->GetReceiver(); 992 Handle<Object> receiver = lookup->GetReceiver();
991 if (getter->IsJSFunction() && holder->HasFastProperties()) { 993 if (holder->HasFastProperties()) {
992 Handle<JSFunction> function = Handle<JSFunction>::cast(getter); 994 if (getter->IsJSFunction()) {
993 if (receiver->IsJSObject() || function->shared()->IsBuiltin() || 995 Handle<JSFunction> function = Handle<JSFunction>::cast(getter);
994 !is_sloppy(function->shared()->language_mode())) { 996 if (!receiver->IsJSObject() && !function->shared()->IsBuiltin() &&
995 CallOptimization call_optimization(function); 997 is_sloppy(function->shared()->language_mode())) {
996 if (call_optimization.is_simple_api_call() && 998 // Calling sloppy non-builtins with a value as the receiver
997 !call_optimization.IsCompatibleReceiverMap(receiver_map, holder)) { 999 // requires boxing.
998 return false; 1000 return false;
999 } 1001 }
1000 } 1002 }
1003 CallOptimization call_optimization(getter);
1004 if (call_optimization.is_simple_api_call() &&
1005 !call_optimization.IsCompatibleReceiverMap(receiver_map, holder)) {
1006 return false;
1007 }
1001 } 1008 }
1002 } 1009 }
1003 return true; 1010 return true;
1004 } 1011 }
1005 1012
1006 1013
1007 void LoadIC::UpdateCaches(LookupIterator* lookup) { 1014 void LoadIC::UpdateCaches(LookupIterator* lookup) {
1008 if (state() == UNINITIALIZED) { 1015 if (state() == UNINITIALIZED) {
1009 // This is the first time we execute this inline cache. Set the target to 1016 // This is the first time we execute this inline cache. Set the target to
1010 // the pre monomorphic stub to delay setting the monomorphic state. 1017 // the pre monomorphic stub to delay setting the monomorphic state.
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 FieldIndex index = FieldIndex::ForInObjectOffset(object_offset, *map); 1167 FieldIndex index = FieldIndex::ForInObjectOffset(object_offset, *map);
1161 return SimpleFieldLoad(index); 1168 return SimpleFieldLoad(index);
1162 } 1169 }
1163 if (Accessors::IsJSArrayBufferViewFieldAccessor(map, lookup->name(), 1170 if (Accessors::IsJSArrayBufferViewFieldAccessor(map, lookup->name(),
1164 &object_offset)) { 1171 &object_offset)) {
1165 FieldIndex index = FieldIndex::ForInObjectOffset(object_offset, *map); 1172 FieldIndex index = FieldIndex::ForInObjectOffset(object_offset, *map);
1166 ArrayBufferViewLoadFieldStub stub(isolate(), index); 1173 ArrayBufferViewLoadFieldStub stub(isolate(), index);
1167 return stub.GetCode(); 1174 return stub.GetCode();
1168 } 1175 }
1169 1176
1170 Handle<Object> accessors = lookup->GetAccessors(); 1177 if (IsCompatibleReceiver(lookup, map)) {
1171 if (accessors->IsAccessorInfo()) { 1178 Handle<Object> accessors = lookup->GetAccessors();
1172 Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(accessors); 1179 if (accessors->IsAccessorPair()) {
1173 if (v8::ToCData<Address>(info->getter()) == 0) break; 1180 if (!holder->HasFastProperties()) break;
1174 if (!AccessorInfo::IsCompatibleReceiverMap(isolate(), info, map)) { 1181 // When debugging we need to go the slow path to flood the accessor.
1175 // This case should be already handled in LoadIC::UpdateCaches. 1182 if (GetSharedFunctionInfo()->HasDebugInfo()) break;
1176 UNREACHABLE(); 1183 Handle<Object> getter(Handle<AccessorPair>::cast(accessors)->getter(),
1177 break; 1184 isolate());
1178 } 1185 CallOptimization call_optimization(getter);
1179 if (!holder->HasFastProperties()) break; 1186 NamedLoadHandlerCompiler compiler(isolate(), map, holder,
1180 NamedLoadHandlerCompiler compiler(isolate(), map, holder, cache_holder); 1187 cache_holder);
1181 return compiler.CompileLoadCallback(lookup->name(), info); 1188 if (call_optimization.is_simple_api_call()) {
1182 }
1183 if (accessors->IsAccessorPair()) {
1184 Handle<Object> getter(Handle<AccessorPair>::cast(accessors)->getter(),
1185 isolate());
1186 if (!getter->IsJSFunction()) break;
1187 if (!holder->HasFastProperties()) break;
1188 // When debugging we need to go the slow path to flood the accessor.
1189 if (GetSharedFunctionInfo()->HasDebugInfo()) break;
1190 Handle<JSFunction> function = Handle<JSFunction>::cast(getter);
1191 if (!receiver->IsJSObject() && !function->shared()->IsBuiltin() &&
1192 is_sloppy(function->shared()->language_mode())) {
1193 // Calling sloppy non-builtins with a value as the receiver
1194 // requires boxing.
1195 break;
1196 }
1197 CallOptimization call_optimization(function);
1198 NamedLoadHandlerCompiler compiler(isolate(), map, holder, cache_holder);
1199 if (call_optimization.is_simple_api_call()) {
1200 if (call_optimization.IsCompatibleReceiver(receiver, holder)) {
1201 return compiler.CompileLoadCallback( 1189 return compiler.CompileLoadCallback(
1202 lookup->name(), call_optimization, lookup->GetAccessorIndex()); 1190 lookup->name(), call_optimization, lookup->GetAccessorIndex());
1203 } else { 1191 }
1192 int expected_arguments = Handle<JSFunction>::cast(getter)
1193 ->shared()
1194 ->internal_formal_parameter_count();
1195 return compiler.CompileLoadViaGetter(
1196 lookup->name(), lookup->GetAccessorIndex(), expected_arguments);
1197 } else if (accessors->IsAccessorInfo()) {
1198 Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(accessors);
1199 if (v8::ToCData<Address>(info->getter()) == 0) break;
1200 if (!AccessorInfo::IsCompatibleReceiverMap(isolate(), info, map)) {
1204 // This case should be already handled in LoadIC::UpdateCaches. 1201 // This case should be already handled in LoadIC::UpdateCaches.
1205 UNREACHABLE(); 1202 UNREACHABLE();
1203 break;
1206 } 1204 }
1205 if (!holder->HasFastProperties()) break;
1206 NamedLoadHandlerCompiler compiler(isolate(), map, holder,
1207 cache_holder);
1208 return compiler.CompileLoadCallback(lookup->name(), info);
1207 } 1209 }
1208 int expected_arguments =
1209 function->shared()->internal_formal_parameter_count();
1210 return compiler.CompileLoadViaGetter(
1211 lookup->name(), lookup->GetAccessorIndex(), expected_arguments);
1212 } 1210 }
1213 break; 1211 break;
1214 } 1212 }
1215 1213
1216 case LookupIterator::DATA: { 1214 case LookupIterator::DATA: {
1217 if (lookup->is_dictionary_holder()) { 1215 if (lookup->is_dictionary_holder()) {
1218 if (kind() != Code::LOAD_IC) break; 1216 if (kind() != Code::LOAD_IC) break;
1219 if (holder->IsJSGlobalObject()) { 1217 if (holder->IsJSGlobalObject()) {
1220 NamedLoadHandlerCompiler compiler(isolate(), map, holder, 1218 NamedLoadHandlerCompiler compiler(isolate(), map, holder,
1221 cache_holder); 1219 cache_holder);
(...skipping 1752 matching lines...) Expand 10 before | Expand all | Expand 10 after
2974 KeyedLoadICNexus nexus(vector, vector_slot); 2972 KeyedLoadICNexus nexus(vector, vector_slot);
2975 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); 2973 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus);
2976 ic.UpdateState(receiver, key); 2974 ic.UpdateState(receiver, key);
2977 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key)); 2975 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key));
2978 } 2976 }
2979 2977
2980 return *result; 2978 return *result;
2981 } 2979 }
2982 } // namespace internal 2980 } // namespace internal
2983 } // namespace v8 2981 } // namespace v8
OLDNEW
« no previous file with comments | « src/ic/ia32/handler-compiler-ia32.cc ('k') | src/ic/mips/handler-compiler-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698