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 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1344 if (!lookup->IsPropertyOrTransition() || !lookup->IsCacheable()) return false; | 1344 if (!lookup->IsPropertyOrTransition() || !lookup->IsCacheable()) return false; |
1345 | 1345 |
1346 // If the property is read-only, we leave the IC in its current | 1346 // If the property is read-only, we leave the IC in its current |
1347 // state. | 1347 // state. |
1348 if (lookup->IsReadOnly()) return false; | 1348 if (lookup->IsReadOnly()) return false; |
1349 | 1349 |
1350 return true; | 1350 return true; |
1351 } | 1351 } |
1352 | 1352 |
1353 | 1353 |
1354 static bool LookupForWrite(JSReceiver* receiver, | 1354 static bool LookupForWrite(JSObject* receiver, |
1355 String* name, | 1355 String* name, |
1356 LookupResult* lookup) { | 1356 LookupResult* lookup) { |
1357 receiver->LocalLookup(name, lookup); | 1357 receiver->LocalLookup(name, lookup); |
1358 if (!StoreICableLookup(lookup)) { | 1358 if (!StoreICableLookup(lookup)) { |
1359 return false; | 1359 return false; |
1360 } | 1360 } |
1361 | 1361 |
1362 if (lookup->type() == INTERCEPTOR) { | 1362 if (lookup->type() == INTERCEPTOR && |
1363 JSObject* object = JSObject::cast(receiver); | 1363 receiver->GetNamedInterceptor()->setter()->IsUndefined()) { |
1364 if (object->GetNamedInterceptor()->setter()->IsUndefined()) { | 1364 receiver->LocalLookupRealNamedProperty(name, lookup); |
1365 object->LocalLookupRealNamedProperty(name, lookup); | 1365 return StoreICableLookup(lookup); |
1366 return StoreICableLookup(lookup); | |
1367 } | |
1368 } | 1366 } |
1369 | 1367 |
1370 return true; | 1368 return true; |
1371 } | 1369 } |
1372 | 1370 |
1373 | 1371 |
1374 MaybeObject* StoreIC::Store(State state, | 1372 MaybeObject* StoreIC::Store(State state, |
1375 StrictModeFlag strict_mode, | 1373 StrictModeFlag strict_mode, |
1376 Handle<Object> object, | 1374 Handle<Object> object, |
1377 Handle<String> name, | 1375 Handle<String> name, |
1378 Handle<Object> value) { | 1376 Handle<Object> value) { |
1379 // If the object is undefined or null it's illegal to try to set any | 1377 if (!object->IsJSObject()) { |
1380 // properties on it; throw a TypeError in that case. | 1378 // Handle proxies. |
1381 if (object->IsUndefined() || object->IsNull()) { | 1379 if (object->IsJSProxy()) { |
1382 return TypeError("non_object_property_store", object, name); | 1380 return JSProxy::cast(*object)-> |
1383 } | 1381 SetProperty(*name, *value, NONE, strict_mode); |
| 1382 } |
1384 | 1383 |
1385 if (!object->IsJSReceiver()) { | 1384 // If the object is undefined or null it's illegal to try to set any |
| 1385 // properties on it; throw a TypeError in that case. |
| 1386 if (object->IsUndefined() || object->IsNull()) { |
| 1387 return TypeError("non_object_property_store", object, name); |
| 1388 } |
| 1389 |
1386 // The length property of string values is read-only. Throw in strict mode. | 1390 // The length property of string values is read-only. Throw in strict mode. |
1387 if (strict_mode == kStrictMode && object->IsString() && | 1391 if (strict_mode == kStrictMode && object->IsString() && |
1388 name->Equals(isolate()->heap()->length_symbol())) { | 1392 name->Equals(isolate()->heap()->length_symbol())) { |
1389 return TypeError("strict_read_only_property", object, name); | 1393 return TypeError("strict_read_only_property", object, name); |
1390 } | 1394 } |
1391 // Ignore stores where the receiver is not a JSObject. | 1395 // Ignore other stores where the receiver is not a JSObject. |
1392 return *value; | 1396 return *value; |
1393 } | 1397 } |
1394 | 1398 |
1395 // Handle proxies. | |
1396 if (object->IsJSProxy()) { | |
1397 return JSReceiver::cast(*object)-> | |
1398 SetProperty(*name, *value, NONE, strict_mode); | |
1399 } | |
1400 | |
1401 Handle<JSObject> receiver = Handle<JSObject>::cast(object); | 1399 Handle<JSObject> receiver = Handle<JSObject>::cast(object); |
1402 | 1400 |
1403 // Check if the given name is an array index. | 1401 // Check if the given name is an array index. |
1404 uint32_t index; | 1402 uint32_t index; |
1405 if (name->AsArrayIndex(&index)) { | 1403 if (name->AsArrayIndex(&index)) { |
1406 HandleScope scope(isolate()); | 1404 HandleScope scope(isolate()); |
1407 Handle<Object> result = SetElement(receiver, index, value, strict_mode); | 1405 Handle<Object> result = SetElement(receiver, index, value, strict_mode); |
1408 if (result.is_null()) return Failure::Exception(); | 1406 if (result.is_null()) return Failure::Exception(); |
1409 return *value; | 1407 return *value; |
1410 } | 1408 } |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1668 | 1666 |
1669 MaybeObject* KeyedIC::ComputeMonomorphicStubWithoutMapCheck( | 1667 MaybeObject* KeyedIC::ComputeMonomorphicStubWithoutMapCheck( |
1670 Map* receiver_map, | 1668 Map* receiver_map, |
1671 StrictModeFlag strict_mode) { | 1669 StrictModeFlag strict_mode) { |
1672 if ((receiver_map->instance_type() & kNotStringTag) == 0) { | 1670 if ((receiver_map->instance_type() & kNotStringTag) == 0) { |
1673 ASSERT(string_stub() != NULL); | 1671 ASSERT(string_stub() != NULL); |
1674 return string_stub(); | 1672 return string_stub(); |
1675 } else { | 1673 } else { |
1676 ASSERT(receiver_map->has_dictionary_elements() || | 1674 ASSERT(receiver_map->has_dictionary_elements() || |
1677 receiver_map->has_fast_elements() || | 1675 receiver_map->has_fast_elements() || |
| 1676 receiver_map->has_fast_smi_only_elements() || |
1678 receiver_map->has_fast_double_elements() || | 1677 receiver_map->has_fast_double_elements() || |
1679 receiver_map->has_external_array_elements()); | 1678 receiver_map->has_external_array_elements()); |
1680 bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE; | 1679 bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE; |
1681 return GetElementStubWithoutMapCheck(is_js_array, | 1680 return GetElementStubWithoutMapCheck(is_js_array, |
1682 receiver_map->elements_kind()); | 1681 receiver_map->elements_kind()); |
1683 } | 1682 } |
1684 } | 1683 } |
1685 | 1684 |
1686 | 1685 |
1687 MaybeObject* KeyedIC::ComputeMonomorphicStub(JSObject* receiver, | 1686 MaybeObject* KeyedIC::ComputeMonomorphicStub(JSObject* receiver, |
1688 bool is_store, | 1687 bool is_store, |
1689 StrictModeFlag strict_mode, | 1688 StrictModeFlag strict_mode, |
1690 Code* generic_stub) { | 1689 Code* generic_stub) { |
1691 Code* result = NULL; | 1690 Code* result = NULL; |
1692 if (receiver->HasFastElements() || | 1691 if (receiver->HasFastElements() || |
| 1692 receiver->HasFastSmiOnlyElements() || |
1693 receiver->HasExternalArrayElements() || | 1693 receiver->HasExternalArrayElements() || |
1694 receiver->HasFastDoubleElements() || | 1694 receiver->HasFastDoubleElements() || |
1695 receiver->HasDictionaryElements()) { | 1695 receiver->HasDictionaryElements()) { |
1696 MaybeObject* maybe_stub = | 1696 MaybeObject* maybe_stub = |
1697 isolate()->stub_cache()->ComputeKeyedLoadOrStoreElement( | 1697 isolate()->stub_cache()->ComputeKeyedLoadOrStoreElement( |
1698 receiver, is_store, strict_mode); | 1698 receiver, is_store, strict_mode); |
1699 if (!maybe_stub->To(&result)) return maybe_stub; | 1699 if (!maybe_stub->To(&result)) return maybe_stub; |
1700 } else { | 1700 } else { |
1701 result = generic_stub; | 1701 result = generic_stub; |
1702 } | 1702 } |
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2508 #undef ADDR | 2508 #undef ADDR |
2509 }; | 2509 }; |
2510 | 2510 |
2511 | 2511 |
2512 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2512 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
2513 return IC_utilities[id]; | 2513 return IC_utilities[id]; |
2514 } | 2514 } |
2515 | 2515 |
2516 | 2516 |
2517 } } // namespace v8::internal | 2517 } } // namespace v8::internal |
OLD | NEW |