OLD | NEW |
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 Loading... |
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 Loading... |
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 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2841 #undef ADDR | 2832 #undef ADDR |
2842 }; | 2833 }; |
2843 | 2834 |
2844 | 2835 |
2845 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2836 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
2846 return IC_utilities[id]; | 2837 return IC_utilities[id]; |
2847 } | 2838 } |
2848 | 2839 |
2849 | 2840 |
2850 } } // namespace v8::internal | 2841 } } // namespace v8::internal |
OLD | NEW |