OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1398 if (object->IsUndefined() || object->IsNull()) { | 1398 if (object->IsUndefined() || object->IsNull()) { |
1399 return TypeError("non_object_property_store", object, name); | 1399 return TypeError("non_object_property_store", object, name); |
1400 } | 1400 } |
1401 | 1401 |
1402 // The length property of string values is read-only. Throw in strict mode. | 1402 // The length property of string values is read-only. Throw in strict mode. |
1403 if (strict_mode == kStrictMode && object->IsString() && | 1403 if (strict_mode == kStrictMode && object->IsString() && |
1404 name->Equals(isolate()->heap()->length_symbol())) { | 1404 name->Equals(isolate()->heap()->length_symbol())) { |
1405 return TypeError("strict_read_only_property", object, name); | 1405 return TypeError("strict_read_only_property", object, name); |
1406 } | 1406 } |
1407 // Ignore other stores where the receiver is not a JSObject. | 1407 // Ignore other stores where the receiver is not a JSObject. |
| 1408 // TODO(1475): Must check prototype chains of object wrappers. |
1408 return *value; | 1409 return *value; |
1409 } | 1410 } |
1410 | 1411 |
1411 Handle<JSObject> receiver = Handle<JSObject>::cast(object); | 1412 Handle<JSObject> receiver = Handle<JSObject>::cast(object); |
1412 | 1413 |
1413 // Check if the given name is an array index. | 1414 // Check if the given name is an array index. |
1414 uint32_t index; | 1415 uint32_t index; |
1415 if (name->AsArrayIndex(&index)) { | 1416 if (name->AsArrayIndex(&index)) { |
1416 HandleScope scope(isolate()); | 1417 HandleScope scope(isolate()); |
1417 Handle<Object> result = SetElement(receiver, index, value, strict_mode); | 1418 Handle<Object> result = SetElement(receiver, index, value, strict_mode); |
(...skipping 11 matching lines...) Expand all Loading... |
1429 Builtins::Name target = (strict_mode == kStrictMode) | 1430 Builtins::Name target = (strict_mode == kStrictMode) |
1430 ? Builtins::kStoreIC_ArrayLength_Strict | 1431 ? Builtins::kStoreIC_ArrayLength_Strict |
1431 : Builtins::kStoreIC_ArrayLength; | 1432 : Builtins::kStoreIC_ArrayLength; |
1432 set_target(isolate()->builtins()->builtin(target)); | 1433 set_target(isolate()->builtins()->builtin(target)); |
1433 return receiver->SetProperty(*name, *value, NONE, strict_mode); | 1434 return receiver->SetProperty(*name, *value, NONE, strict_mode); |
1434 } | 1435 } |
1435 | 1436 |
1436 // Lookup the property locally in the receiver. | 1437 // Lookup the property locally in the receiver. |
1437 if (FLAG_use_ic && !receiver->IsJSGlobalProxy()) { | 1438 if (FLAG_use_ic && !receiver->IsJSGlobalProxy()) { |
1438 LookupResult lookup(isolate()); | 1439 LookupResult lookup(isolate()); |
1439 | |
1440 if (LookupForWrite(*receiver, *name, &lookup)) { | 1440 if (LookupForWrite(*receiver, *name, &lookup)) { |
1441 // Generate a stub for this store. | 1441 // Generate a stub for this store. |
1442 UpdateCaches(&lookup, state, strict_mode, receiver, name, value); | 1442 UpdateCaches(&lookup, state, strict_mode, receiver, name, value); |
1443 } else { | 1443 } else { |
1444 // Strict mode doesn't allow setting non-existent global property | 1444 // Strict mode doesn't allow setting non-existent global property |
1445 // or an assignment to a read only property. | 1445 // or an assignment to a read only property. |
1446 if (strict_mode == kStrictMode) { | 1446 if (strict_mode == kStrictMode) { |
1447 if (lookup.IsFound() && lookup.IsReadOnly()) { | 1447 if (lookup.IsFound() && lookup.IsReadOnly()) { |
1448 return TypeError("strict_read_only_property", object, name); | 1448 return TypeError("strict_read_only_property", object, name); |
1449 } else if (IsContextual(object)) { | 1449 } else if (IsContextual(object)) { |
(...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2612 #undef ADDR | 2612 #undef ADDR |
2613 }; | 2613 }; |
2614 | 2614 |
2615 | 2615 |
2616 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2616 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
2617 return IC_utilities[id]; | 2617 return IC_utilities[id]; |
2618 } | 2618 } |
2619 | 2619 |
2620 | 2620 |
2621 } } // namespace v8::internal | 2621 } } // namespace v8::internal |
OLD | NEW |