| 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 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1348 if (!lookup->IsPropertyOrTransition() || !lookup->IsCacheable()) return false; | 1348 if (!lookup->IsPropertyOrTransition() || !lookup->IsCacheable()) return false; |
| 1349 | 1349 |
| 1350 // If the property is read-only, we leave the IC in its current | 1350 // If the property is read-only, we leave the IC in its current |
| 1351 // state. | 1351 // state. |
| 1352 if (lookup->IsReadOnly()) return false; | 1352 if (lookup->IsReadOnly()) return false; |
| 1353 | 1353 |
| 1354 return true; | 1354 return true; |
| 1355 } | 1355 } |
| 1356 | 1356 |
| 1357 | 1357 |
| 1358 static bool LookupForWrite(JSObject* object, | 1358 static bool LookupForWrite(JSReceiver* receiver, |
| 1359 String* name, | 1359 String* name, |
| 1360 LookupResult* lookup) { | 1360 LookupResult* lookup) { |
| 1361 object->LocalLookup(name, lookup); | 1361 receiver->LocalLookup(name, lookup); |
| 1362 if (!StoreICableLookup(lookup)) { | 1362 if (!StoreICableLookup(lookup)) { |
| 1363 return false; | 1363 return false; |
| 1364 } | 1364 } |
| 1365 | 1365 |
| 1366 if (lookup->type() == INTERCEPTOR) { | 1366 if (lookup->type() == INTERCEPTOR) { |
| 1367 JSObject* object = JSObject::cast(receiver); |
| 1367 if (object->GetNamedInterceptor()->setter()->IsUndefined()) { | 1368 if (object->GetNamedInterceptor()->setter()->IsUndefined()) { |
| 1368 object->LocalLookupRealNamedProperty(name, lookup); | 1369 object->LocalLookupRealNamedProperty(name, lookup); |
| 1369 return StoreICableLookup(lookup); | 1370 return StoreICableLookup(lookup); |
| 1370 } | 1371 } |
| 1371 } | 1372 } |
| 1372 | 1373 |
| 1373 return true; | 1374 return true; |
| 1374 } | 1375 } |
| 1375 | 1376 |
| 1376 | 1377 |
| 1377 MaybeObject* StoreIC::Store(State state, | 1378 MaybeObject* StoreIC::Store(State state, |
| 1378 StrictModeFlag strict_mode, | 1379 StrictModeFlag strict_mode, |
| 1379 Handle<Object> object, | 1380 Handle<Object> object, |
| 1380 Handle<String> name, | 1381 Handle<String> name, |
| 1381 Handle<Object> value) { | 1382 Handle<Object> value) { |
| 1382 // If the object is undefined or null it's illegal to try to set any | 1383 // If the object is undefined or null it's illegal to try to set any |
| 1383 // properties on it; throw a TypeError in that case. | 1384 // properties on it; throw a TypeError in that case. |
| 1384 if (object->IsUndefined() || object->IsNull()) { | 1385 if (object->IsUndefined() || object->IsNull()) { |
| 1385 return TypeError("non_object_property_store", object, name); | 1386 return TypeError("non_object_property_store", object, name); |
| 1386 } | 1387 } |
| 1387 | 1388 |
| 1388 if (!object->IsJSObject()) { | 1389 if (!object->IsJSReceiver()) { |
| 1389 // 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. |
| 1390 if (strict_mode == kStrictMode && object->IsString() && | 1391 if (strict_mode == kStrictMode && object->IsString() && |
| 1391 name->Equals(isolate()->heap()->length_symbol())) { | 1392 name->Equals(isolate()->heap()->length_symbol())) { |
| 1392 return TypeError("strict_read_only_property", object, name); | 1393 return TypeError("strict_read_only_property", object, name); |
| 1393 } | 1394 } |
| 1394 // Ignore stores where the receiver is not a JSObject. | 1395 // Ignore stores where the receiver is not a JSObject. |
| 1395 return *value; | 1396 return *value; |
| 1396 } | 1397 } |
| 1397 | 1398 |
| 1399 // Handle proxies. |
| 1400 if (object->IsJSProxy()) { |
| 1401 return JSReceiver::cast(*object)-> |
| 1402 SetProperty(*name, *value, NONE, strict_mode); |
| 1403 } |
| 1404 |
| 1398 Handle<JSObject> receiver = Handle<JSObject>::cast(object); | 1405 Handle<JSObject> receiver = Handle<JSObject>::cast(object); |
| 1399 | 1406 |
| 1400 // Check if the given name is an array index. | 1407 // Check if the given name is an array index. |
| 1401 uint32_t index; | 1408 uint32_t index; |
| 1402 if (name->AsArrayIndex(&index)) { | 1409 if (name->AsArrayIndex(&index)) { |
| 1403 HandleScope scope(isolate()); | 1410 HandleScope scope(isolate()); |
| 1404 Handle<Object> result = SetElement(receiver, index, value, strict_mode); | 1411 Handle<Object> result = SetElement(receiver, index, value, strict_mode); |
| 1405 if (result.is_null()) return Failure::Exception(); | 1412 if (result.is_null()) return Failure::Exception(); |
| 1406 return *value; | 1413 return *value; |
| 1407 } | 1414 } |
| 1408 | 1415 |
| 1409 // Use specialized code for setting the length of arrays. | 1416 // Use specialized code for setting the length of arrays. |
| 1410 if (receiver->IsJSArray() | 1417 if (receiver->IsJSArray() |
| 1411 && name->Equals(isolate()->heap()->length_symbol()) | 1418 && name->Equals(isolate()->heap()->length_symbol()) |
| 1412 && receiver->AllowsSetElementsLength()) { | 1419 && JSArray::cast(*receiver)->AllowsSetElementsLength()) { |
| 1413 #ifdef DEBUG | 1420 #ifdef DEBUG |
| 1414 if (FLAG_trace_ic) PrintF("[StoreIC : +#length /array]\n"); | 1421 if (FLAG_trace_ic) PrintF("[StoreIC : +#length /array]\n"); |
| 1415 #endif | 1422 #endif |
| 1416 Builtins::Name target = (strict_mode == kStrictMode) | 1423 Builtins::Name target = (strict_mode == kStrictMode) |
| 1417 ? Builtins::kStoreIC_ArrayLength_Strict | 1424 ? Builtins::kStoreIC_ArrayLength_Strict |
| 1418 : Builtins::kStoreIC_ArrayLength; | 1425 : Builtins::kStoreIC_ArrayLength; |
| 1419 set_target(isolate()->builtins()->builtin(target)); | 1426 set_target(isolate()->builtins()->builtin(target)); |
| 1420 return receiver->SetProperty(*name, *value, NONE, strict_mode); | 1427 return receiver->SetProperty(*name, *value, NONE, strict_mode); |
| 1421 } | 1428 } |
| 1422 | 1429 |
| (...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2568 #undef ADDR | 2575 #undef ADDR |
| 2569 }; | 2576 }; |
| 2570 | 2577 |
| 2571 | 2578 |
| 2572 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2579 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
| 2573 return IC_utilities[id]; | 2580 return IC_utilities[id]; |
| 2574 } | 2581 } |
| 2575 | 2582 |
| 2576 | 2583 |
| 2577 } } // namespace v8::internal | 2584 } } // namespace v8::internal |
| OLD | NEW |