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 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1443 ASSERT(lookup->type() != NULL_DESCRIPTOR); | 1443 ASSERT(lookup->type() != NULL_DESCRIPTOR); |
1444 | 1444 |
1445 // If the property has a non-field type allowing map transitions | 1445 // If the property has a non-field type allowing map transitions |
1446 // where there is extra room in the object, we leave the IC in its | 1446 // where there is extra room in the object, we leave the IC in its |
1447 // current state. | 1447 // current state. |
1448 PropertyType type = lookup->type(); | 1448 PropertyType type = lookup->type(); |
1449 | 1449 |
1450 // Compute the code stub for this store; used for rewriting to | 1450 // Compute the code stub for this store; used for rewriting to |
1451 // monomorphic state and making sure that the code stub is in the | 1451 // monomorphic state and making sure that the code stub is in the |
1452 // stub cache. | 1452 // stub cache. |
| 1453 Handle<JSObject> holder(lookup->holder()); |
1453 Handle<Code> code; | 1454 Handle<Code> code; |
1454 switch (type) { | 1455 switch (type) { |
1455 case FIELD: | 1456 case FIELD: |
1456 code = isolate()->stub_cache()->ComputeStoreField(name, | 1457 code = isolate()->stub_cache()->ComputeStoreField(name, |
1457 receiver, | 1458 receiver, |
1458 lookup->GetFieldIndex(), | 1459 lookup->GetFieldIndex(), |
1459 Handle<Map>::null(), | 1460 Handle<Map>::null(), |
1460 strict_mode); | 1461 strict_mode); |
1461 break; | 1462 break; |
1462 case MAP_TRANSITION: { | 1463 case MAP_TRANSITION: { |
1463 if (lookup->GetAttributes() != NONE) return; | 1464 if (lookup->GetAttributes() != NONE) return; |
1464 Handle<Map> transition(lookup->GetTransitionMap()); | 1465 Handle<Map> transition(lookup->GetTransitionMap()); |
1465 int index = transition->PropertyIndexFor(*name); | 1466 int index = transition->PropertyIndexFor(*name); |
1466 code = isolate()->stub_cache()->ComputeStoreField( | 1467 code = isolate()->stub_cache()->ComputeStoreField( |
1467 name, receiver, index, transition, strict_mode); | 1468 name, receiver, index, transition, strict_mode); |
1468 break; | 1469 break; |
1469 } | 1470 } |
1470 case NORMAL: | 1471 case NORMAL: |
1471 if (receiver->IsGlobalObject()) { | 1472 if (receiver->IsGlobalObject()) { |
1472 // The stub generated for the global object picks the value directly | 1473 // The stub generated for the global object picks the value directly |
1473 // from the property cell. So the property must be directly on the | 1474 // from the property cell. So the property must be directly on the |
1474 // global object. | 1475 // global object. |
1475 Handle<GlobalObject> global = Handle<GlobalObject>::cast(receiver); | 1476 Handle<GlobalObject> global = Handle<GlobalObject>::cast(receiver); |
1476 Handle<JSGlobalPropertyCell> cell(global->GetPropertyCell(lookup)); | 1477 Handle<JSGlobalPropertyCell> cell(global->GetPropertyCell(lookup)); |
1477 code = isolate()->stub_cache()->ComputeStoreGlobal( | 1478 code = isolate()->stub_cache()->ComputeStoreGlobal( |
1478 name, global, cell, strict_mode); | 1479 name, global, cell, strict_mode); |
1479 } else { | 1480 } else { |
1480 if (lookup->holder() != *receiver) return; | 1481 if (!holder.is_identical_to(receiver)) return; |
1481 code = isolate()->stub_cache()->ComputeStoreNormal(strict_mode); | 1482 code = isolate()->stub_cache()->ComputeStoreNormal(strict_mode); |
1482 } | 1483 } |
1483 break; | 1484 break; |
1484 case CALLBACKS: { | 1485 case CALLBACKS: { |
1485 Handle<Object> callback_object(lookup->GetCallbackObject()); | 1486 Handle<Object> callback(lookup->GetCallbackObject()); |
1486 if (!callback_object->IsAccessorInfo()) return; | 1487 if (callback->IsAccessorInfo()) { |
1487 Handle<AccessorInfo> callback = | 1488 Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(callback); |
1488 Handle<AccessorInfo>::cast(callback_object); | 1489 if (v8::ToCData<Address>(info->setter()) == 0) return; |
1489 if (v8::ToCData<Address>(callback->setter()) == 0) return; | 1490 ASSERT(info->IsCompatibleReceiver(*receiver)); |
1490 ASSERT(callback->IsCompatibleReceiver(*receiver)); | 1491 code = isolate()->stub_cache()->ComputeStoreCallback( |
1491 code = isolate()->stub_cache()->ComputeStoreCallback( | 1492 name, receiver, info, strict_mode); |
1492 name, receiver, callback, strict_mode); | 1493 } else if (callback->IsAccessorPair()) { |
| 1494 Handle<Object> setter(Handle<AccessorPair>::cast(callback)->setter()); |
| 1495 if (!setter->IsJSFunction()) return; |
| 1496 if (holder->IsGlobalObject()) return; |
| 1497 if (!receiver->HasFastProperties()) return; |
| 1498 code = isolate()->stub_cache()->ComputeStoreViaSetter( |
| 1499 name, receiver, Handle<JSFunction>::cast(setter), strict_mode); |
| 1500 } else { |
| 1501 ASSERT(callback->IsForeign()); |
| 1502 // No IC support for old-style native accessors. |
| 1503 return; |
| 1504 } |
1493 break; | 1505 break; |
1494 } | 1506 } |
1495 case INTERCEPTOR: | 1507 case INTERCEPTOR: |
1496 ASSERT(!receiver->GetNamedInterceptor()->setter()->IsUndefined()); | 1508 ASSERT(!receiver->GetNamedInterceptor()->setter()->IsUndefined()); |
1497 code = isolate()->stub_cache()->ComputeStoreInterceptor( | 1509 code = isolate()->stub_cache()->ComputeStoreInterceptor( |
1498 name, receiver, strict_mode); | 1510 name, receiver, strict_mode); |
1499 break; | 1511 break; |
1500 case CONSTANT_FUNCTION: | 1512 case CONSTANT_FUNCTION: |
1501 case CONSTANT_TRANSITION: | 1513 case CONSTANT_TRANSITION: |
1502 return; | 1514 return; |
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2660 #undef ADDR | 2672 #undef ADDR |
2661 }; | 2673 }; |
2662 | 2674 |
2663 | 2675 |
2664 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2676 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
2665 return IC_utilities[id]; | 2677 return IC_utilities[id]; |
2666 } | 2678 } |
2667 | 2679 |
2668 | 2680 |
2669 } } // namespace v8::internal | 2681 } } // namespace v8::internal |
OLD | NEW |