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 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1447 receiver->LocalLookupRealNamedProperty(*name, lookup); | 1447 receiver->LocalLookupRealNamedProperty(*name, lookup); |
1448 return lookup->IsFound() && | 1448 return lookup->IsFound() && |
1449 !lookup->IsReadOnly() && | 1449 !lookup->IsReadOnly() && |
1450 lookup->CanHoldValue(value) && | 1450 lookup->CanHoldValue(value) && |
1451 lookup->IsCacheable(); | 1451 lookup->IsCacheable(); |
1452 } | 1452 } |
1453 return lookup->CanHoldValue(value); | 1453 return lookup->CanHoldValue(value); |
1454 } | 1454 } |
1455 | 1455 |
1456 if (lookup->IsPropertyCallbacks()) return true; | 1456 if (lookup->IsPropertyCallbacks()) return true; |
1457 | 1457 // JSGlobalProxy always goes via the runtime, so it's safe to cache. |
| 1458 if (receiver->IsJSGlobalProxy()) return true; |
1458 // Currently normal holders in the prototype chain are not supported. They | 1459 // Currently normal holders in the prototype chain are not supported. They |
1459 // would require a runtime positive lookup and verification that the details | 1460 // would require a runtime positive lookup and verification that the details |
1460 // have not changed. | 1461 // have not changed. |
1461 if (lookup->IsInterceptor() || lookup->IsNormal()) return false; | 1462 if (lookup->IsInterceptor() || lookup->IsNormal()) return false; |
1462 holder = Handle<JSObject>(lookup->holder(), lookup->isolate()); | 1463 holder = Handle<JSObject>(lookup->holder(), lookup->isolate()); |
1463 } | 1464 } |
1464 | 1465 |
1465 // While normally LookupTransition gets passed the receiver, in this case we | 1466 // While normally LookupTransition gets passed the receiver, in this case we |
1466 // pass the holder of the property that we overwrite. This keeps the holder in | 1467 // pass the holder of the property that we overwrite. This keeps the holder in |
1467 // the LookupResult intact so we can later use it to generate a prototype | 1468 // the LookupResult intact so we can later use it to generate a prototype |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1554 Handle<Code> stub = | 1555 Handle<Code> stub = |
1555 StoreArrayLengthStub(kind(), strict_mode()).GetCode(isolate()); | 1556 StoreArrayLengthStub(kind(), strict_mode()).GetCode(isolate()); |
1556 set_target(*stub); | 1557 set_target(*stub); |
1557 TRACE_IC("StoreIC", name); | 1558 TRACE_IC("StoreIC", name); |
1558 Handle<Object> result = JSReceiver::SetProperty( | 1559 Handle<Object> result = JSReceiver::SetProperty( |
1559 receiver, name, value, NONE, strict_mode(), store_mode); | 1560 receiver, name, value, NONE, strict_mode(), store_mode); |
1560 RETURN_IF_EMPTY_HANDLE(isolate(), result); | 1561 RETURN_IF_EMPTY_HANDLE(isolate(), result); |
1561 return *result; | 1562 return *result; |
1562 } | 1563 } |
1563 | 1564 |
1564 if (receiver->IsJSGlobalProxy()) { | |
1565 if (FLAG_use_ic && kind() != Code::KEYED_STORE_IC) { | |
1566 // Generate a generic stub that goes to the runtime when we see a global | |
1567 // proxy as receiver. | |
1568 Handle<Code> stub = global_proxy_stub(); | |
1569 set_target(*stub); | |
1570 TRACE_IC("StoreIC", name); | |
1571 } | |
1572 Handle<Object> result = JSReceiver::SetProperty( | |
1573 receiver, name, value, NONE, strict_mode(), store_mode); | |
1574 RETURN_IF_EMPTY_HANDLE(isolate(), result); | |
1575 return *result; | |
1576 } | |
1577 | |
1578 LookupResult lookup(isolate()); | 1565 LookupResult lookup(isolate()); |
1579 bool can_store = LookupForWrite(receiver, name, value, &lookup, this); | 1566 bool can_store = LookupForWrite(receiver, name, value, &lookup, this); |
1580 if (!can_store && | 1567 if (!can_store && |
1581 strict_mode() == kStrictMode && | 1568 strict_mode() == kStrictMode && |
1582 !(lookup.IsProperty() && lookup.IsReadOnly()) && | 1569 !(lookup.IsProperty() && lookup.IsReadOnly()) && |
1583 IsUndeclaredGlobal(object)) { | 1570 IsUndeclaredGlobal(object)) { |
1584 // Strict mode doesn't allow setting non-existent global property. | 1571 // Strict mode doesn't allow setting non-existent global property. |
1585 return ReferenceError("not_defined", name); | 1572 return ReferenceError("not_defined", name); |
1586 } | 1573 } |
1587 if (FLAG_use_ic) { | 1574 if (FLAG_use_ic) { |
(...skipping 16 matching lines...) Expand all Loading... |
1604 receiver, name, value, NONE, strict_mode(), store_mode); | 1591 receiver, name, value, NONE, strict_mode(), store_mode); |
1605 RETURN_IF_EMPTY_HANDLE(isolate(), result); | 1592 RETURN_IF_EMPTY_HANDLE(isolate(), result); |
1606 return *result; | 1593 return *result; |
1607 } | 1594 } |
1608 | 1595 |
1609 | 1596 |
1610 void StoreIC::UpdateCaches(LookupResult* lookup, | 1597 void StoreIC::UpdateCaches(LookupResult* lookup, |
1611 Handle<JSObject> receiver, | 1598 Handle<JSObject> receiver, |
1612 Handle<String> name, | 1599 Handle<String> name, |
1613 Handle<Object> value) { | 1600 Handle<Object> value) { |
1614 ASSERT(!receiver->IsJSGlobalProxy()); | |
1615 ASSERT(lookup->IsFound()); | 1601 ASSERT(lookup->IsFound()); |
1616 | 1602 |
1617 // These are not cacheable, so we never see such LookupResults here. | 1603 // These are not cacheable, so we never see such LookupResults here. |
1618 ASSERT(!lookup->IsHandler()); | 1604 ASSERT(!lookup->IsHandler()); |
1619 | 1605 |
1620 Handle<Code> code = ComputeHandler(lookup, receiver, name, value); | 1606 Handle<Code> code = ComputeHandler(lookup, receiver, name, value); |
1621 | 1607 |
1622 PatchCache(CurrentTypeOf(receiver, isolate()), name, code); | 1608 PatchCache(CurrentTypeOf(receiver, isolate()), name, code); |
1623 TRACE_IC("StoreIC", name); | 1609 TRACE_IC("StoreIC", name); |
1624 } | 1610 } |
1625 | 1611 |
1626 | 1612 |
1627 Handle<Code> StoreIC::CompileHandler(LookupResult* lookup, | 1613 Handle<Code> StoreIC::CompileHandler(LookupResult* lookup, |
1628 Handle<Object> object, | 1614 Handle<Object> object, |
1629 Handle<String> name, | 1615 Handle<String> name, |
1630 Handle<Object> value, | 1616 Handle<Object> value, |
1631 InlineCacheHolderFlag cache_holder) { | 1617 InlineCacheHolderFlag cache_holder) { |
| 1618 if (object->IsJSGlobalProxy()) return slow_stub(); |
1632 ASSERT(cache_holder == OWN_MAP); | 1619 ASSERT(cache_holder == OWN_MAP); |
1633 // This is currently guaranteed by checks in StoreIC::Store. | 1620 // This is currently guaranteed by checks in StoreIC::Store. |
1634 Handle<JSObject> receiver = Handle<JSObject>::cast(object); | 1621 Handle<JSObject> receiver = Handle<JSObject>::cast(object); |
1635 | 1622 |
1636 Handle<JSObject> holder(lookup->holder()); | 1623 Handle<JSObject> holder(lookup->holder()); |
1637 // Handlers do not use strict mode. | 1624 // Handlers do not use strict mode. |
1638 StoreStubCompiler compiler(isolate(), kNonStrictMode, kind()); | 1625 StoreStubCompiler compiler(isolate(), kNonStrictMode, kind()); |
1639 switch (lookup->type()) { | 1626 switch (lookup->type()) { |
1640 case FIELD: | 1627 case FIELD: |
1641 return compiler.CompileStoreField(receiver, lookup, name); | 1628 return compiler.CompileStoreField(receiver, lookup, name); |
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2768 #undef ADDR | 2755 #undef ADDR |
2769 }; | 2756 }; |
2770 | 2757 |
2771 | 2758 |
2772 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2759 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
2773 return IC_utilities[id]; | 2760 return IC_utilities[id]; |
2774 } | 2761 } |
2775 | 2762 |
2776 | 2763 |
2777 } } // namespace v8::internal | 2764 } } // namespace v8::internal |
OLD | NEW |