| 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 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 | 929 |
| 930 // If we did not find a property, check if we need to throw an exception. | 930 // If we did not find a property, check if we need to throw an exception. |
| 931 if (!lookup.IsFound()) { | 931 if (!lookup.IsFound()) { |
| 932 if (IsUndeclaredGlobal(object)) { | 932 if (IsUndeclaredGlobal(object)) { |
| 933 return ReferenceError("not_defined", name); | 933 return ReferenceError("not_defined", name); |
| 934 } | 934 } |
| 935 LOG(isolate(), SuspectReadEvent(*name, *object)); | 935 LOG(isolate(), SuspectReadEvent(*name, *object)); |
| 936 } | 936 } |
| 937 | 937 |
| 938 // Update inline cache and stub cache. | 938 // Update inline cache and stub cache. |
| 939 if (FLAG_use_ic) { | 939 if (FLAG_use_ic) UpdateCaches(&lookup, state, object, name); |
| 940 if (!object->IsJSObject()) { | |
| 941 // TODO(jkummerow): It would be nice to support non-JSObjects in | |
| 942 // UpdateCaches, then we wouldn't need to go generic here. | |
| 943 set_target(*generic_stub()); | |
| 944 } else { | |
| 945 UpdateCaches(&lookup, state, object, name); | |
| 946 } | |
| 947 } | |
| 948 | 940 |
| 949 PropertyAttributes attr; | 941 PropertyAttributes attr; |
| 950 if (lookup.IsInterceptor() || lookup.IsHandler()) { | 942 if (lookup.IsInterceptor() || lookup.IsHandler()) { |
| 951 // Get the property. | 943 // Get the property. |
| 952 Handle<Object> result = | 944 Handle<Object> result = |
| 953 Object::GetProperty(object, object, &lookup, name, &attr); | 945 Object::GetProperty(object, object, &lookup, name, &attr); |
| 954 RETURN_IF_EMPTY_HANDLE(isolate(), result); | 946 RETURN_IF_EMPTY_HANDLE(isolate(), result); |
| 955 // If the property is not present, check if we need to throw an | 947 // If the property is not present, check if we need to throw an |
| 956 // exception. | 948 // exception. |
| 957 if (attr == ABSENT && IsUndeclaredGlobal(object)) { | 949 if (attr == ABSENT && IsUndeclaredGlobal(object)) { |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1197 break; | 1189 break; |
| 1198 } | 1190 } |
| 1199 } | 1191 } |
| 1200 | 1192 |
| 1201 | 1193 |
| 1202 void LoadIC::UpdateCaches(LookupResult* lookup, | 1194 void LoadIC::UpdateCaches(LookupResult* lookup, |
| 1203 State state, | 1195 State state, |
| 1204 Handle<Object> object, | 1196 Handle<Object> object, |
| 1205 Handle<String> name) { | 1197 Handle<String> name) { |
| 1206 // Bail out if the result is not cacheable. | 1198 // Bail out if the result is not cacheable. |
| 1207 if (!lookup->IsCacheable()) return; | 1199 if (!lookup->IsCacheable()) { |
| 1200 set_target(*generic_stub()); |
| 1201 return; |
| 1202 } |
| 1208 | 1203 |
| 1209 // Loading properties from values is not common, so don't try to | 1204 // TODO(jkummerow): It would be nice to support non-JSObjects in |
| 1210 // deal with non-JS objects here. | 1205 // UpdateCaches, then we wouldn't need to go generic here. |
| 1211 if (!object->IsJSObject()) return; | 1206 if (!object->IsJSObject()) { |
| 1207 set_target(*generic_stub()); |
| 1208 return; |
| 1209 } |
| 1212 | 1210 |
| 1213 Handle<JSObject> receiver = Handle<JSObject>::cast(object); | 1211 Handle<JSObject> receiver = Handle<JSObject>::cast(object); |
| 1214 Handle<Code> code; | 1212 Handle<Code> code; |
| 1215 if (state == UNINITIALIZED) { | 1213 if (state == UNINITIALIZED) { |
| 1216 // This is the first time we execute this inline cache. | 1214 // This is the first time we execute this inline cache. |
| 1217 // Set the target to the pre monomorphic stub to delay | 1215 // Set the target to the pre monomorphic stub to delay |
| 1218 // setting the monomorphic state. | 1216 // setting the monomorphic state. |
| 1219 code = pre_monomorphic_stub(); | 1217 code = pre_monomorphic_stub(); |
| 1220 } else { | 1218 } else { |
| 1221 code = ComputeLoadHandler(lookup, receiver, name); | 1219 code = ComputeLoadHandler(lookup, receiver, name); |
| 1222 if (code.is_null()) return; | 1220 if (code.is_null()) { |
| 1221 set_target(*generic_stub()); |
| 1222 return; |
| 1223 } |
| 1223 } | 1224 } |
| 1224 | 1225 |
| 1225 PatchCache(state, kNonStrictMode, receiver, name, code); | 1226 PatchCache(state, kNonStrictMode, receiver, name, code); |
| 1226 TRACE_IC("LoadIC", name, state, target()); | 1227 TRACE_IC("LoadIC", name, state, target()); |
| 1227 } | 1228 } |
| 1228 | 1229 |
| 1229 | 1230 |
| 1230 void IC::UpdateMegamorphicCache(Map* map, Name* name, Code* code) { | 1231 void IC::UpdateMegamorphicCache(Map* map, Name* name, Code* code) { |
| 1231 // Cache code holding map should be consistent with | 1232 // Cache code holding map should be consistent with |
| 1232 // GenerateMonomorphicCacheProbe. | 1233 // GenerateMonomorphicCacheProbe. |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1633 LookupResult lookup(isolate()); | 1634 LookupResult lookup(isolate()); |
| 1634 if (LookupForWrite(receiver, name, value, &lookup, &state)) { | 1635 if (LookupForWrite(receiver, name, value, &lookup, &state)) { |
| 1635 if (FLAG_use_ic) { | 1636 if (FLAG_use_ic) { |
| 1636 UpdateCaches(&lookup, state, strict_mode, receiver, name, value); | 1637 UpdateCaches(&lookup, state, strict_mode, receiver, name, value); |
| 1637 } | 1638 } |
| 1638 } else if (strict_mode == kStrictMode && | 1639 } else if (strict_mode == kStrictMode && |
| 1639 !(lookup.IsProperty() && lookup.IsReadOnly()) && | 1640 !(lookup.IsProperty() && lookup.IsReadOnly()) && |
| 1640 IsUndeclaredGlobal(object)) { | 1641 IsUndeclaredGlobal(object)) { |
| 1641 // Strict mode doesn't allow setting non-existent global property. | 1642 // Strict mode doesn't allow setting non-existent global property. |
| 1642 return ReferenceError("not_defined", name); | 1643 return ReferenceError("not_defined", name); |
| 1644 } else if (FLAG_use_ic && |
| 1645 (lookup.IsNormal() || |
| 1646 (lookup.IsField() && lookup.CanHoldValue(value)))) { |
| 1647 Handle<Code> stub = strict_mode == kStrictMode |
| 1648 ? generic_stub_strict() : generic_stub(); |
| 1649 set_target(*stub); |
| 1643 } | 1650 } |
| 1644 | 1651 |
| 1645 // Set the property. | 1652 // Set the property. |
| 1646 return JSReceiver::SetPropertyOrFail( | 1653 return JSReceiver::SetPropertyOrFail( |
| 1647 receiver, name, value, NONE, strict_mode, store_mode); | 1654 receiver, name, value, NONE, strict_mode, store_mode); |
| 1648 } | 1655 } |
| 1649 | 1656 |
| 1650 | 1657 |
| 1651 void StoreIC::UpdateCaches(LookupResult* lookup, | 1658 void StoreIC::UpdateCaches(LookupResult* lookup, |
| 1652 State state, | 1659 State state, |
| 1653 StrictModeFlag strict_mode, | 1660 StrictModeFlag strict_mode, |
| 1654 Handle<JSObject> receiver, | 1661 Handle<JSObject> receiver, |
| 1655 Handle<String> name, | 1662 Handle<String> name, |
| 1656 Handle<Object> value) { | 1663 Handle<Object> value) { |
| 1657 ASSERT(!receiver->IsJSGlobalProxy()); | 1664 ASSERT(!receiver->IsJSGlobalProxy()); |
| 1658 ASSERT(lookup->IsFound()); | 1665 ASSERT(lookup->IsFound()); |
| 1659 | 1666 |
| 1660 // These are not cacheable, so we never see such LookupResults here. | 1667 // These are not cacheable, so we never see such LookupResults here. |
| 1661 ASSERT(!lookup->IsHandler()); | 1668 ASSERT(!lookup->IsHandler()); |
| 1662 | 1669 |
| 1663 Handle<Code> code = | 1670 Handle<Code> code = ComputeStoreMonomorphic( |
| 1664 ComputeStoreMonomorphic(lookup, strict_mode, receiver, name); | 1671 lookup, strict_mode, receiver, name); |
| 1665 if (code.is_null()) return; | 1672 if (code.is_null()) { |
| 1673 Handle<Code> stub = strict_mode == kStrictMode |
| 1674 ? generic_stub_strict() : generic_stub(); |
| 1675 set_target(*stub); |
| 1676 return; |
| 1677 } |
| 1666 | 1678 |
| 1667 PatchCache(state, strict_mode, receiver, name, code); | 1679 PatchCache(state, strict_mode, receiver, name, code); |
| 1668 TRACE_IC("StoreIC", name, state, target()); | 1680 TRACE_IC("StoreIC", name, state, target()); |
| 1669 } | 1681 } |
| 1670 | 1682 |
| 1671 | 1683 |
| 1672 Handle<Code> StoreIC::ComputeStoreMonomorphic(LookupResult* lookup, | 1684 Handle<Code> StoreIC::ComputeStoreMonomorphic(LookupResult* lookup, |
| 1673 StrictModeFlag strict_mode, | 1685 StrictModeFlag strict_mode, |
| 1674 Handle<JSObject> receiver, | 1686 Handle<JSObject> receiver, |
| 1675 Handle<String> name) { | 1687 Handle<String> name) { |
| (...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3052 #undef ADDR | 3064 #undef ADDR |
| 3053 }; | 3065 }; |
| 3054 | 3066 |
| 3055 | 3067 |
| 3056 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 3068 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
| 3057 return IC_utilities[id]; | 3069 return IC_utilities[id]; |
| 3058 } | 3070 } |
| 3059 | 3071 |
| 3060 | 3072 |
| 3061 } } // namespace v8::internal | 3073 } } // namespace v8::internal |
| OLD | NEW |