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

Side by Side Diff: src/ic.cc

Issue 196653015: Fixed spec violation of storing to length of a frozen object. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review notes applied 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/ia32/stub-cache-ia32.cc ('k') | src/stub-cache.h » ('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 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 } 1227 }
1228 1228
1229 // Observed objects are always modified through the runtime. 1229 // Observed objects are always modified through the runtime.
1230 if (receiver->map()->is_observed()) { 1230 if (receiver->map()->is_observed()) {
1231 Handle<Object> result = JSReceiver::SetProperty( 1231 Handle<Object> result = JSReceiver::SetProperty(
1232 receiver, name, value, NONE, strict_mode(), store_mode); 1232 receiver, name, value, NONE, strict_mode(), store_mode);
1233 RETURN_IF_EMPTY_HANDLE(isolate(), result); 1233 RETURN_IF_EMPTY_HANDLE(isolate(), result);
1234 return *result; 1234 return *result;
1235 } 1235 }
1236 1236
1237 // Use specialized code for setting the length of arrays with fast
1238 // properties. Slow properties might indicate redefinition of the length
1239 // property. Note that when redefined using Object.freeze, it's possible
1240 // to have fast properties but a read-only length.
1241 if (FLAG_use_ic &&
1242 receiver->IsJSArray() &&
1243 name->Equals(isolate()->heap()->length_string()) &&
1244 Handle<JSArray>::cast(receiver)->AllowsSetElementsLength() &&
1245 receiver->HasFastProperties() &&
1246 !receiver->map()->is_frozen()) {
1247 Handle<Code> stub =
1248 StoreArrayLengthStub(kind(), strict_mode()).GetCode(isolate());
1249 set_target(*stub);
1250 TRACE_IC("StoreIC", name);
1251 Handle<Object> result = JSReceiver::SetProperty(
1252 receiver, name, value, NONE, strict_mode(), store_mode);
1253 RETURN_IF_EMPTY_HANDLE(isolate(), result);
1254 return *result;
1255 }
1256
1257 LookupResult lookup(isolate()); 1237 LookupResult lookup(isolate());
1258 bool can_store = LookupForWrite(receiver, name, value, &lookup, this); 1238 bool can_store = LookupForWrite(receiver, name, value, &lookup, this);
1259 if (!can_store && 1239 if (!can_store &&
1260 strict_mode() == STRICT && 1240 strict_mode() == STRICT &&
1261 !(lookup.IsProperty() && lookup.IsReadOnly()) && 1241 !(lookup.IsProperty() && lookup.IsReadOnly()) &&
1262 object->IsGlobalObject()) { 1242 object->IsGlobalObject()) {
1263 // Strict mode doesn't allow setting non-existent global property. 1243 // Strict mode doesn't allow setting non-existent global property.
1264 return ReferenceError("not_defined", name); 1244 return ReferenceError("not_defined", name);
1265 } 1245 }
1266 if (FLAG_use_ic) { 1246 if (FLAG_use_ic) {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1397 call_optimization.IsCompatibleReceiver(receiver, holder)) { 1377 call_optimization.IsCompatibleReceiver(receiver, holder)) {
1398 return compiler.CompileStoreCallback( 1378 return compiler.CompileStoreCallback(
1399 receiver, holder, name, call_optimization); 1379 receiver, holder, name, call_optimization);
1400 } 1380 }
1401 return compiler.CompileStoreViaSetter( 1381 return compiler.CompileStoreViaSetter(
1402 receiver, holder, name, Handle<JSFunction>::cast(setter)); 1382 receiver, holder, name, Handle<JSFunction>::cast(setter));
1403 } 1383 }
1404 // TODO(dcarney): Handle correctly. 1384 // TODO(dcarney): Handle correctly.
1405 if (callback->IsDeclaredAccessorInfo()) break; 1385 if (callback->IsDeclaredAccessorInfo()) break;
1406 ASSERT(callback->IsForeign()); 1386 ASSERT(callback->IsForeign());
1387
1388 // Use specialized code for setting the length of arrays with fast
1389 // properties. Slow properties might indicate redefinition of the length
1390 // property.
1391 if (receiver->IsJSArray() &&
1392 name->Equals(isolate()->heap()->length_string()) &&
1393 Handle<JSArray>::cast(receiver)->AllowsSetElementsLength() &&
1394 receiver->HasFastProperties()) {
1395 return compiler.CompileStoreArrayLength(receiver, lookup, name);
1396 }
1397
1407 // No IC support for old-style native accessors. 1398 // No IC support for old-style native accessors.
1408 break; 1399 break;
1409 } 1400 }
1410 case INTERCEPTOR: 1401 case INTERCEPTOR:
1411 if (kind() == Code::KEYED_STORE_IC) break; 1402 if (kind() == Code::KEYED_STORE_IC) break;
1412 ASSERT(HasInterceptorSetter(*holder)); 1403 ASSERT(HasInterceptorSetter(*holder));
1413 return compiler.CompileStoreInterceptor(receiver, name); 1404 return compiler.CompileStoreInterceptor(receiver, name);
1414 case CONSTANT: 1405 case CONSTANT:
1415 break; 1406 break;
1416 case NONEXISTENT: 1407 case NONEXISTENT:
(...skipping 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after
2844 #undef ADDR 2835 #undef ADDR
2845 }; 2836 };
2846 2837
2847 2838
2848 Address IC::AddressFromUtilityId(IC::UtilityId id) { 2839 Address IC::AddressFromUtilityId(IC::UtilityId id) {
2849 return IC_utilities[id]; 2840 return IC_utilities[id];
2850 } 2841 }
2851 2842
2852 2843
2853 } } // namespace v8::internal 2844 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/stub-cache-ia32.cc ('k') | src/stub-cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698