| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1416 StrictModeFlag strict_mode, | 1416 StrictModeFlag strict_mode, |
| 1417 Handle<Object> object, | 1417 Handle<Object> object, |
| 1418 Handle<String> name, | 1418 Handle<String> name, |
| 1419 Handle<Object> value) { | 1419 Handle<Object> value) { |
| 1420 // If the object is undefined or null it's illegal to try to set any | 1420 // If the object is undefined or null it's illegal to try to set any |
| 1421 // properties on it; throw a TypeError in that case. | 1421 // properties on it; throw a TypeError in that case. |
| 1422 if (object->IsUndefined() || object->IsNull()) { | 1422 if (object->IsUndefined() || object->IsNull()) { |
| 1423 return TypeError("non_object_property_store", object, name); | 1423 return TypeError("non_object_property_store", object, name); |
| 1424 } | 1424 } |
| 1425 | 1425 |
| 1426 // Ignore stores where the receiver is not a JSObject. | 1426 if (!object->IsJSObject()) { |
| 1427 if (!object->IsJSObject()) return *value; | 1427 // The length property of string values is read-only. Throw in strict mode. |
| 1428 if (strict_mode == kStrictMode && object->IsString() && |
| 1429 name->Equals(isolate()->heap()->length_symbol())) { |
| 1430 return TypeError("strict_read_only_property", object, name); |
| 1431 } |
| 1432 // Ignore stores where the receiver is not a JSObject. |
| 1433 return *value; |
| 1434 } |
| 1435 |
| 1428 Handle<JSObject> receiver = Handle<JSObject>::cast(object); | 1436 Handle<JSObject> receiver = Handle<JSObject>::cast(object); |
| 1429 | 1437 |
| 1430 // Check if the given name is an array index. | 1438 // Check if the given name is an array index. |
| 1431 uint32_t index; | 1439 uint32_t index; |
| 1432 if (name->AsArrayIndex(&index)) { | 1440 if (name->AsArrayIndex(&index)) { |
| 1433 HandleScope scope(isolate()); | 1441 HandleScope scope(isolate()); |
| 1434 Handle<Object> result = SetElement(receiver, index, value); | 1442 Handle<Object> result = SetElement(receiver, index, value, strict_mode); |
| 1435 if (result.is_null()) return Failure::Exception(); | 1443 if (result.is_null()) return Failure::Exception(); |
| 1436 return *value; | 1444 return *value; |
| 1437 } | 1445 } |
| 1438 | 1446 |
| 1439 // Use specialized code for setting the length of arrays. | 1447 // Use specialized code for setting the length of arrays. |
| 1440 if (receiver->IsJSArray() | 1448 if (receiver->IsJSArray() |
| 1441 && name->Equals(isolate()->heap()->length_symbol()) | 1449 && name->Equals(isolate()->heap()->length_symbol()) |
| 1442 && receiver->AllowsSetElementsLength()) { | 1450 && receiver->AllowsSetElementsLength()) { |
| 1443 #ifdef DEBUG | 1451 #ifdef DEBUG |
| 1444 if (FLAG_trace_ic) PrintF("[StoreIC : +#length /array]\n"); | 1452 if (FLAG_trace_ic) PrintF("[StoreIC : +#length /array]\n"); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1652 } | 1660 } |
| 1653 | 1661 |
| 1654 // Ignore stores where the receiver is not a JSObject. | 1662 // Ignore stores where the receiver is not a JSObject. |
| 1655 if (!object->IsJSObject()) return *value; | 1663 if (!object->IsJSObject()) return *value; |
| 1656 Handle<JSObject> receiver = Handle<JSObject>::cast(object); | 1664 Handle<JSObject> receiver = Handle<JSObject>::cast(object); |
| 1657 | 1665 |
| 1658 // Check if the given name is an array index. | 1666 // Check if the given name is an array index. |
| 1659 uint32_t index; | 1667 uint32_t index; |
| 1660 if (name->AsArrayIndex(&index)) { | 1668 if (name->AsArrayIndex(&index)) { |
| 1661 HandleScope scope(isolate()); | 1669 HandleScope scope(isolate()); |
| 1662 Handle<Object> result = SetElement(receiver, index, value); | 1670 Handle<Object> result = SetElement(receiver, index, value, strict_mode); |
| 1663 if (result.is_null()) return Failure::Exception(); | 1671 if (result.is_null()) return Failure::Exception(); |
| 1664 return *value; | 1672 return *value; |
| 1665 } | 1673 } |
| 1666 | 1674 |
| 1667 // Lookup the property locally in the receiver. | 1675 // Lookup the property locally in the receiver. |
| 1668 LookupResult lookup; | 1676 LookupResult lookup; |
| 1669 receiver->LocalLookup(*name, &lookup); | 1677 receiver->LocalLookup(*name, &lookup); |
| 1670 | 1678 |
| 1671 // Update inline cache and stub cache. | 1679 // Update inline cache and stub cache. |
| 1672 if (FLAG_use_ic) { | 1680 if (FLAG_use_ic) { |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2375 #undef ADDR | 2383 #undef ADDR |
| 2376 }; | 2384 }; |
| 2377 | 2385 |
| 2378 | 2386 |
| 2379 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2387 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
| 2380 return IC_utilities[id]; | 2388 return IC_utilities[id]; |
| 2381 } | 2389 } |
| 2382 | 2390 |
| 2383 | 2391 |
| 2384 } } // namespace v8::internal | 2392 } } // namespace v8::internal |
| OLD | NEW |