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

Side by Side Diff: src/ic.cc

Issue 181543002: Eliminate extended mode, and other modes clean-up (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/ic.h ('k') | src/isolate.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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 return compiler.CompileLoadCallback(type, holder, name, info); 936 return compiler.CompileLoadCallback(type, holder, name, info);
937 } else if (callback->IsAccessorPair()) { 937 } else if (callback->IsAccessorPair()) {
938 Handle<Object> getter(Handle<AccessorPair>::cast(callback)->getter(), 938 Handle<Object> getter(Handle<AccessorPair>::cast(callback)->getter(),
939 isolate()); 939 isolate());
940 if (!getter->IsJSFunction()) break; 940 if (!getter->IsJSFunction()) break;
941 if (holder->IsGlobalObject()) break; 941 if (holder->IsGlobalObject()) break;
942 if (!holder->HasFastProperties()) break; 942 if (!holder->HasFastProperties()) break;
943 Handle<JSFunction> function = Handle<JSFunction>::cast(getter); 943 Handle<JSFunction> function = Handle<JSFunction>::cast(getter);
944 if (!object->IsJSObject() && 944 if (!object->IsJSObject() &&
945 !function->IsBuiltin() && 945 !function->IsBuiltin() &&
946 function->shared()->is_sloppy_mode()) { 946 function->shared()->strict_mode() == SLOPPY) {
947 // Calling sloppy non-builtins with a value as the receiver 947 // Calling sloppy non-builtins with a value as the receiver
948 // requires boxing. 948 // requires boxing.
949 break; 949 break;
950 } 950 }
951 CallOptimization call_optimization(function); 951 CallOptimization call_optimization(function);
952 if (call_optimization.is_simple_api_call() && 952 if (call_optimization.is_simple_api_call() &&
953 call_optimization.IsCompatibleReceiver(object, holder)) { 953 call_optimization.IsCompatibleReceiver(object, holder)) {
954 return compiler.CompileLoadCallback( 954 return compiler.CompileLoadCallback(
955 type, holder, name, call_optimization); 955 type, holder, name, call_optimization);
956 } 956 }
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 return *result; 1173 return *result;
1174 } 1174 }
1175 1175
1176 // If the object is undefined or null it's illegal to try to set any 1176 // If the object is undefined or null it's illegal to try to set any
1177 // properties on it; throw a TypeError in that case. 1177 // properties on it; throw a TypeError in that case.
1178 if (object->IsUndefined() || object->IsNull()) { 1178 if (object->IsUndefined() || object->IsNull()) {
1179 return TypeError("non_object_property_store", object, name); 1179 return TypeError("non_object_property_store", object, name);
1180 } 1180 }
1181 1181
1182 // The length property of string values is read-only. Throw in strict mode. 1182 // The length property of string values is read-only. Throw in strict mode.
1183 if (strict_mode() == kStrictMode && object->IsString() && 1183 if (strict_mode() == STRICT && object->IsString() &&
1184 name->Equals(isolate()->heap()->length_string())) { 1184 name->Equals(isolate()->heap()->length_string())) {
1185 return TypeError("strict_read_only_property", object, name); 1185 return TypeError("strict_read_only_property", object, name);
1186 } 1186 }
1187 1187
1188 // Ignore other stores where the receiver is not a JSObject. 1188 // Ignore other stores where the receiver is not a JSObject.
1189 // TODO(1475): Must check prototype chains of object wrappers. 1189 // TODO(1475): Must check prototype chains of object wrappers.
1190 if (!object->IsJSObject()) return *value; 1190 if (!object->IsJSObject()) return *value;
1191 1191
1192 Handle<JSObject> receiver = Handle<JSObject>::cast(object); 1192 Handle<JSObject> receiver = Handle<JSObject>::cast(object);
1193 1193
(...skipping 30 matching lines...) Expand all
1224 TRACE_IC("StoreIC", name); 1224 TRACE_IC("StoreIC", name);
1225 Handle<Object> result = JSReceiver::SetProperty( 1225 Handle<Object> result = JSReceiver::SetProperty(
1226 receiver, name, value, NONE, strict_mode(), store_mode); 1226 receiver, name, value, NONE, strict_mode(), store_mode);
1227 RETURN_IF_EMPTY_HANDLE(isolate(), result); 1227 RETURN_IF_EMPTY_HANDLE(isolate(), result);
1228 return *result; 1228 return *result;
1229 } 1229 }
1230 1230
1231 LookupResult lookup(isolate()); 1231 LookupResult lookup(isolate());
1232 bool can_store = LookupForWrite(receiver, name, value, &lookup, this); 1232 bool can_store = LookupForWrite(receiver, name, value, &lookup, this);
1233 if (!can_store && 1233 if (!can_store &&
1234 strict_mode() == kStrictMode && 1234 strict_mode() == STRICT &&
1235 !(lookup.IsProperty() && lookup.IsReadOnly()) && 1235 !(lookup.IsProperty() && lookup.IsReadOnly()) &&
1236 object->IsGlobalObject()) { 1236 object->IsGlobalObject()) {
1237 // Strict mode doesn't allow setting non-existent global property. 1237 // Strict mode doesn't allow setting non-existent global property.
1238 return ReferenceError("not_defined", name); 1238 return ReferenceError("not_defined", name);
1239 } 1239 }
1240 if (FLAG_use_ic) { 1240 if (FLAG_use_ic) {
1241 if (state() == UNINITIALIZED) { 1241 if (state() == UNINITIALIZED) {
1242 Handle<Code> stub = pre_monomorphic_stub(); 1242 Handle<Code> stub = pre_monomorphic_stub();
1243 set_target(*stub); 1243 set_target(*stub);
1244 TRACE_IC("StoreIC", name); 1244 TRACE_IC("StoreIC", name);
1245 } else if (can_store) { 1245 } else if (can_store) {
1246 UpdateCaches(&lookup, receiver, name, value); 1246 UpdateCaches(&lookup, receiver, name, value);
1247 } else if (!name->IsCacheable(isolate()) || 1247 } else if (!name->IsCacheable(isolate()) ||
1248 lookup.IsNormal() || 1248 lookup.IsNormal() ||
1249 (lookup.IsField() && lookup.CanHoldValue(value))) { 1249 (lookup.IsField() && lookup.CanHoldValue(value))) {
1250 Handle<Code> stub = generic_stub(); 1250 Handle<Code> stub = generic_stub();
1251 set_target(*stub); 1251 set_target(*stub);
1252 } 1252 }
1253 } 1253 }
1254 1254
1255 // Set the property. 1255 // Set the property.
1256 Handle<Object> result = JSReceiver::SetProperty( 1256 Handle<Object> result = JSReceiver::SetProperty(
1257 receiver, name, value, NONE, strict_mode(), store_mode); 1257 receiver, name, value, NONE, strict_mode(), store_mode);
1258 RETURN_IF_EMPTY_HANDLE(isolate(), result); 1258 RETURN_IF_EMPTY_HANDLE(isolate(), result);
1259 return *result; 1259 return *result;
1260 } 1260 }
1261 1261
1262 1262
1263 Handle<Code> StoreIC::initialize_stub(Isolate* isolate, 1263 Handle<Code> StoreIC::initialize_stub(Isolate* isolate,
1264 StrictModeFlag strict_mode) { 1264 StrictMode strict_mode) {
1265 ExtraICState extra_state = ComputeExtraICState(strict_mode); 1265 ExtraICState extra_state = ComputeExtraICState(strict_mode);
1266 Handle<Code> ic = isolate->stub_cache()->ComputeStore( 1266 Handle<Code> ic = isolate->stub_cache()->ComputeStore(
1267 UNINITIALIZED, extra_state); 1267 UNINITIALIZED, extra_state);
1268 return ic; 1268 return ic;
1269 } 1269 }
1270 1270
1271 1271
1272 Handle<Code> StoreIC::megamorphic_stub() { 1272 Handle<Code> StoreIC::megamorphic_stub() {
1273 return isolate()->stub_cache()->ComputeStore(MEGAMORPHIC, extra_ic_state()); 1273 return isolate()->stub_cache()->ComputeStore(MEGAMORPHIC, extra_ic_state());
1274 } 1274 }
1275 1275
1276 1276
1277 Handle<Code> StoreIC::generic_stub() const { 1277 Handle<Code> StoreIC::generic_stub() const {
1278 return isolate()->stub_cache()->ComputeStore(GENERIC, extra_ic_state()); 1278 return isolate()->stub_cache()->ComputeStore(GENERIC, extra_ic_state());
1279 } 1279 }
1280 1280
1281 1281
1282 Handle<Code> StoreIC::pre_monomorphic_stub(Isolate* isolate, 1282 Handle<Code> StoreIC::pre_monomorphic_stub(Isolate* isolate,
1283 StrictModeFlag strict_mode) { 1283 StrictMode strict_mode) {
1284 ExtraICState state = ComputeExtraICState(strict_mode); 1284 ExtraICState state = ComputeExtraICState(strict_mode);
1285 return isolate->stub_cache()->ComputeStore(PREMONOMORPHIC, state); 1285 return isolate->stub_cache()->ComputeStore(PREMONOMORPHIC, state);
1286 } 1286 }
1287 1287
1288 1288
1289 void StoreIC::UpdateCaches(LookupResult* lookup, 1289 void StoreIC::UpdateCaches(LookupResult* lookup,
1290 Handle<JSObject> receiver, 1290 Handle<JSObject> receiver,
1291 Handle<String> name, 1291 Handle<String> name,
1292 Handle<Object> value) { 1292 Handle<Object> value) {
1293 ASSERT(lookup->IsFound()); 1293 ASSERT(lookup->IsFound());
(...skipping 13 matching lines...) Expand all
1307 Handle<String> name, 1307 Handle<String> name,
1308 Handle<Object> value, 1308 Handle<Object> value,
1309 InlineCacheHolderFlag cache_holder) { 1309 InlineCacheHolderFlag cache_holder) {
1310 if (object->IsAccessCheckNeeded()) return slow_stub(); 1310 if (object->IsAccessCheckNeeded()) return slow_stub();
1311 ASSERT(cache_holder == OWN_MAP); 1311 ASSERT(cache_holder == OWN_MAP);
1312 // This is currently guaranteed by checks in StoreIC::Store. 1312 // This is currently guaranteed by checks in StoreIC::Store.
1313 Handle<JSObject> receiver = Handle<JSObject>::cast(object); 1313 Handle<JSObject> receiver = Handle<JSObject>::cast(object);
1314 1314
1315 Handle<JSObject> holder(lookup->holder()); 1315 Handle<JSObject> holder(lookup->holder());
1316 // Handlers do not use strict mode. 1316 // Handlers do not use strict mode.
1317 StoreStubCompiler compiler(isolate(), kSloppyMode, kind()); 1317 StoreStubCompiler compiler(isolate(), SLOPPY, kind());
1318 switch (lookup->type()) { 1318 switch (lookup->type()) {
1319 case FIELD: 1319 case FIELD:
1320 return compiler.CompileStoreField(receiver, lookup, name); 1320 return compiler.CompileStoreField(receiver, lookup, name);
1321 case TRANSITION: { 1321 case TRANSITION: {
1322 // Explicitly pass in the receiver map since LookupForWrite may have 1322 // Explicitly pass in the receiver map since LookupForWrite may have
1323 // stored something else than the receiver in the holder. 1323 // stored something else than the receiver in the holder.
1324 Handle<Map> transition(lookup->GetTransitionTarget()); 1324 Handle<Map> transition(lookup->GetTransitionTarget());
1325 PropertyDetails details = transition->GetLastDescriptorDetails(); 1325 PropertyDetails details = transition->GetLastDescriptorDetails();
1326 1326
1327 if (details.type() == CALLBACKS || details.attributes() != NONE) break; 1327 if (details.type() == CALLBACKS || details.attributes() != NONE) break;
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 } 1877 }
1878 1878
1879 1879
1880 RUNTIME_FUNCTION(MaybeObject*, StoreIC_Slow) { 1880 RUNTIME_FUNCTION(MaybeObject*, StoreIC_Slow) {
1881 HandleScope scope(isolate); 1881 HandleScope scope(isolate);
1882 ASSERT(args.length() == 3); 1882 ASSERT(args.length() == 3);
1883 StoreIC ic(IC::NO_EXTRA_FRAME, isolate); 1883 StoreIC ic(IC::NO_EXTRA_FRAME, isolate);
1884 Handle<Object> object = args.at<Object>(0); 1884 Handle<Object> object = args.at<Object>(0);
1885 Handle<Object> key = args.at<Object>(1); 1885 Handle<Object> key = args.at<Object>(1);
1886 Handle<Object> value = args.at<Object>(2); 1886 Handle<Object> value = args.at<Object>(2);
1887 StrictModeFlag strict_mode = ic.strict_mode(); 1887 StrictMode strict_mode = ic.strict_mode();
1888 Handle<Object> result = Runtime::SetObjectProperty(isolate, object, key, 1888 Handle<Object> result = Runtime::SetObjectProperty(isolate, object, key,
1889 value, 1889 value,
1890 NONE, 1890 NONE,
1891 strict_mode); 1891 strict_mode);
1892 RETURN_IF_EMPTY_HANDLE(isolate, result); 1892 RETURN_IF_EMPTY_HANDLE(isolate, result);
1893 return *result; 1893 return *result;
1894 } 1894 }
1895 1895
1896 1896
1897 RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_Slow) { 1897 RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_Slow) {
1898 HandleScope scope(isolate); 1898 HandleScope scope(isolate);
1899 ASSERT(args.length() == 3); 1899 ASSERT(args.length() == 3);
1900 KeyedStoreIC ic(IC::NO_EXTRA_FRAME, isolate); 1900 KeyedStoreIC ic(IC::NO_EXTRA_FRAME, isolate);
1901 Handle<Object> object = args.at<Object>(0); 1901 Handle<Object> object = args.at<Object>(0);
1902 Handle<Object> key = args.at<Object>(1); 1902 Handle<Object> key = args.at<Object>(1);
1903 Handle<Object> value = args.at<Object>(2); 1903 Handle<Object> value = args.at<Object>(2);
1904 StrictModeFlag strict_mode = ic.strict_mode(); 1904 StrictMode strict_mode = ic.strict_mode();
1905 Handle<Object> result = Runtime::SetObjectProperty(isolate, object, key, 1905 Handle<Object> result = Runtime::SetObjectProperty(isolate, object, key,
1906 value, 1906 value,
1907 NONE, 1907 NONE,
1908 strict_mode); 1908 strict_mode);
1909 RETURN_IF_EMPTY_HANDLE(isolate, result); 1909 RETURN_IF_EMPTY_HANDLE(isolate, result);
1910 return *result; 1910 return *result;
1911 } 1911 }
1912 1912
1913 1913
1914 RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss) { 1914 RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss) {
1915 HandleScope scope(isolate); 1915 HandleScope scope(isolate);
1916 ASSERT(args.length() == 4); 1916 ASSERT(args.length() == 4);
1917 KeyedStoreIC ic(IC::EXTRA_CALL_FRAME, isolate); 1917 KeyedStoreIC ic(IC::EXTRA_CALL_FRAME, isolate);
1918 Handle<Object> value = args.at<Object>(0); 1918 Handle<Object> value = args.at<Object>(0);
1919 Handle<Map> map = args.at<Map>(1); 1919 Handle<Map> map = args.at<Map>(1);
1920 Handle<Object> key = args.at<Object>(2); 1920 Handle<Object> key = args.at<Object>(2);
1921 Handle<Object> object = args.at<Object>(3); 1921 Handle<Object> object = args.at<Object>(3);
1922 StrictModeFlag strict_mode = ic.strict_mode(); 1922 StrictMode strict_mode = ic.strict_mode();
1923 if (object->IsJSObject()) { 1923 if (object->IsJSObject()) {
1924 JSObject::TransitionElementsKind(Handle<JSObject>::cast(object), 1924 JSObject::TransitionElementsKind(Handle<JSObject>::cast(object),
1925 map->elements_kind()); 1925 map->elements_kind());
1926 } 1926 }
1927 Handle<Object> result = Runtime::SetObjectProperty(isolate, object, key, 1927 Handle<Object> result = Runtime::SetObjectProperty(isolate, object, key,
1928 value, 1928 value,
1929 NONE, 1929 NONE,
1930 strict_mode); 1930 strict_mode);
1931 RETURN_IF_EMPTY_HANDLE(isolate, result); 1931 RETURN_IF_EMPTY_HANDLE(isolate, result);
1932 return *result; 1932 return *result;
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
2802 #undef ADDR 2802 #undef ADDR
2803 }; 2803 };
2804 2804
2805 2805
2806 Address IC::AddressFromUtilityId(IC::UtilityId id) { 2806 Address IC::AddressFromUtilityId(IC::UtilityId id) {
2807 return IC_utilities[id]; 2807 return IC_utilities[id];
2808 } 2808 }
2809 2809
2810 2810
2811 } } // namespace v8::internal 2811 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ic.h ('k') | src/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698