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 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1130 LoadFieldStub stub(true, length_index, Representation::Tagged()); | 1130 LoadFieldStub stub(true, length_index, Representation::Tagged()); |
1131 code = stub.GetCode(isolate()); | 1131 code = stub.GetCode(isolate()); |
1132 } else { | 1132 } else { |
1133 KeyedLoadFieldStub stub(true, length_index, Representation::Tagged()); | 1133 KeyedLoadFieldStub stub(true, length_index, Representation::Tagged()); |
1134 code = stub.GetCode(isolate()); | 1134 code = stub.GetCode(isolate()); |
1135 } | 1135 } |
1136 } else if (!object->IsJSObject()) { | 1136 } else if (!object->IsJSObject()) { |
1137 // TODO(jkummerow): It would be nice to support non-JSObjects in | 1137 // TODO(jkummerow): It would be nice to support non-JSObjects in |
1138 // ComputeLoadHandler, then we wouldn't need to go generic here. | 1138 // ComputeLoadHandler, then we wouldn't need to go generic here. |
1139 code = slow_stub(); | 1139 code = slow_stub(); |
| 1140 } else if (!lookup->IsProperty()) { |
| 1141 code = kind() == Code::LOAD_IC |
| 1142 ? isolate()->stub_cache()->ComputeLoadNonexistent( |
| 1143 name, Handle<JSObject>::cast(receiver)) |
| 1144 : slow_stub(); |
1140 } else { | 1145 } else { |
1141 code = ComputeLoadHandler(lookup, Handle<JSObject>::cast(receiver), name); | 1146 code = ComputeHandler(lookup, Handle<JSObject>::cast(receiver), name); |
1142 } | 1147 } |
1143 | 1148 |
1144 PatchCache(receiver, name, code); | 1149 PatchCache(receiver, name, code); |
1145 TRACE_IC("LoadIC", name); | 1150 TRACE_IC("LoadIC", name); |
1146 } | 1151 } |
1147 | 1152 |
1148 | 1153 |
1149 void IC::UpdateMegamorphicCache(Map* map, Name* name, Code* code) { | 1154 void IC::UpdateMegamorphicCache(Map* map, Name* name, Code* code) { |
1150 // Cache code holding map should be consistent with | 1155 // Cache code holding map should be consistent with |
1151 // GenerateMonomorphicCacheProbe. | 1156 // GenerateMonomorphicCacheProbe. |
1152 isolate()->stub_cache()->Set(name, map, code); | 1157 isolate()->stub_cache()->Set(name, map, code); |
1153 } | 1158 } |
1154 | 1159 |
1155 | 1160 |
1156 Handle<Code> LoadIC::ComputeLoadHandler(LookupResult* lookup, | 1161 Handle<Code> IC::ComputeHandler(LookupResult* lookup, |
1157 Handle<JSObject> receiver, | 1162 Handle<JSObject> receiver, |
1158 Handle<String> name) { | 1163 Handle<String> name, |
1159 if (!lookup->IsProperty()) { | 1164 Handle<Object> value) { |
1160 return kind() == Code::LOAD_IC | |
1161 ? isolate()->stub_cache()->ComputeLoadNonexistent(name, receiver) | |
1162 : generic_stub(); | |
1163 } | |
1164 | |
1165 Handle<Code> code = isolate()->stub_cache()->FindHandler( | 1165 Handle<Code> code = isolate()->stub_cache()->FindHandler( |
1166 name, receiver, kind()); | 1166 name, receiver, kind()); |
1167 if (!code.is_null()) return code; | 1167 if (!code.is_null()) return code; |
1168 | 1168 |
1169 code = CompileLoadHandler(lookup, receiver, name); | 1169 code = CompileHandler(lookup, receiver, name, value); |
1170 if (code.is_null()) return slow_stub(); | 1170 if (code.is_null()) return slow_stub(); |
1171 | 1171 |
1172 if (code->is_handler() && code->type() != Code::NORMAL) { | 1172 if (code->is_handler() && code->type() != Code::NORMAL) { |
1173 HeapObject::UpdateMapCodeCache(receiver, name, code); | 1173 HeapObject::UpdateMapCodeCache(receiver, name, code); |
1174 } | 1174 } |
1175 | 1175 |
1176 return code; | 1176 return code; |
1177 } | 1177 } |
1178 | 1178 |
1179 | 1179 |
1180 Handle<Code> LoadIC::CompileLoadHandler(LookupResult* lookup, | 1180 Handle<Code> LoadIC::CompileHandler(LookupResult* lookup, |
1181 Handle<JSObject> receiver, | 1181 Handle<JSObject> receiver, |
1182 Handle<String> name) { | 1182 Handle<String> name, |
| 1183 Handle<Object> unused) { |
1183 Handle<JSObject> holder(lookup->holder()); | 1184 Handle<JSObject> holder(lookup->holder()); |
1184 switch (lookup->type()) { | 1185 switch (lookup->type()) { |
1185 case FIELD: | 1186 case FIELD: |
1186 return isolate()->stub_cache()->ComputeLoadField( | 1187 return isolate()->stub_cache()->ComputeLoadField( |
1187 name, receiver, holder, | 1188 name, receiver, holder, |
1188 lookup->GetFieldIndex(), lookup->representation()); | 1189 lookup->GetFieldIndex(), lookup->representation()); |
1189 case CONSTANT: { | 1190 case CONSTANT: { |
1190 Handle<Object> constant(lookup->GetConstant(), isolate()); | 1191 Handle<Object> constant(lookup->GetConstant(), isolate()); |
1191 // TODO(2803): Don't compute a stub for cons strings because they cannot | 1192 // TODO(2803): Don't compute a stub for cons strings because they cannot |
1192 // be embedded into code. | 1193 // be embedded into code. |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1383 ASSERT(!stub.is_null()); | 1384 ASSERT(!stub.is_null()); |
1384 set_target(*stub); | 1385 set_target(*stub); |
1385 TRACE_IC("LoadIC", key); | 1386 TRACE_IC("LoadIC", key); |
1386 } | 1387 } |
1387 | 1388 |
1388 | 1389 |
1389 return Runtime::GetObjectPropertyOrFail(isolate(), object, key); | 1390 return Runtime::GetObjectPropertyOrFail(isolate(), object, key); |
1390 } | 1391 } |
1391 | 1392 |
1392 | 1393 |
1393 Handle<Code> KeyedLoadIC::CompileLoadHandler(LookupResult* lookup, | 1394 Handle<Code> KeyedLoadIC::CompileHandler(LookupResult* lookup, |
1394 Handle<JSObject> receiver, | 1395 Handle<JSObject> receiver, |
1395 Handle<String> name) { | 1396 Handle<String> name, |
| 1397 Handle<Object> value) { |
1396 // Compute a monomorphic stub. | 1398 // Compute a monomorphic stub. |
1397 Handle<JSObject> holder(lookup->holder(), isolate()); | 1399 Handle<JSObject> holder(lookup->holder(), isolate()); |
1398 switch (lookup->type()) { | 1400 switch (lookup->type()) { |
1399 case FIELD: | 1401 case FIELD: |
1400 return isolate()->stub_cache()->ComputeKeyedLoadField( | 1402 return isolate()->stub_cache()->ComputeKeyedLoadField( |
1401 name, receiver, holder, | 1403 name, receiver, holder, |
1402 lookup->GetFieldIndex(), lookup->representation()); | 1404 lookup->GetFieldIndex(), lookup->representation()); |
1403 case CONSTANT: { | 1405 case CONSTANT: { |
1404 Handle<Object> constant(lookup->GetConstant(), isolate()); | 1406 Handle<Object> constant(lookup->GetConstant(), isolate()); |
1405 // TODO(2803): Don't compute a stub for cons strings because they cannot | 1407 // TODO(2803): Don't compute a stub for cons strings because they cannot |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1626 void StoreIC::UpdateCaches(LookupResult* lookup, | 1628 void StoreIC::UpdateCaches(LookupResult* lookup, |
1627 Handle<JSObject> receiver, | 1629 Handle<JSObject> receiver, |
1628 Handle<String> name, | 1630 Handle<String> name, |
1629 Handle<Object> value) { | 1631 Handle<Object> value) { |
1630 ASSERT(!receiver->IsJSGlobalProxy()); | 1632 ASSERT(!receiver->IsJSGlobalProxy()); |
1631 ASSERT(lookup->IsFound()); | 1633 ASSERT(lookup->IsFound()); |
1632 | 1634 |
1633 // These are not cacheable, so we never see such LookupResults here. | 1635 // These are not cacheable, so we never see such LookupResults here. |
1634 ASSERT(!lookup->IsHandler()); | 1636 ASSERT(!lookup->IsHandler()); |
1635 | 1637 |
1636 Handle<Code> code = ComputeStoreHandler(lookup, receiver, name, value); | 1638 Handle<Code> code = ComputeHandler(lookup, receiver, name, value); |
1637 | 1639 |
1638 PatchCache(receiver, name, code); | 1640 PatchCache(receiver, name, code); |
1639 TRACE_IC("StoreIC", name); | 1641 TRACE_IC("StoreIC", name); |
1640 } | 1642 } |
1641 | 1643 |
1642 | 1644 |
1643 Handle<Code> StoreIC::ComputeStoreHandler(LookupResult* lookup, | 1645 Handle<Code> StoreIC::CompileHandler(LookupResult* lookup, |
1644 Handle<JSObject> receiver, | 1646 Handle<JSObject> receiver, |
1645 Handle<String> name, | 1647 Handle<String> name, |
1646 Handle<Object> value) { | 1648 Handle<Object> value) { |
1647 Handle<Code> code = isolate()->stub_cache()->FindHandler( | |
1648 name, receiver, kind(), strict_mode()); | |
1649 if (!code.is_null()) return code; | |
1650 | |
1651 code = CompileStoreHandler(lookup, receiver, name, value); | |
1652 if (code.is_null()) return slow_stub(); | |
1653 | |
1654 if (code->is_handler() && code->type() != Code::NORMAL) { | |
1655 HeapObject::UpdateMapCodeCache(receiver, name, code); | |
1656 } | |
1657 | |
1658 return code; | |
1659 } | |
1660 | |
1661 | |
1662 Handle<Code> StoreIC::CompileStoreHandler(LookupResult* lookup, | |
1663 Handle<JSObject> receiver, | |
1664 Handle<String> name, | |
1665 Handle<Object> value) { | |
1666 Handle<JSObject> holder(lookup->holder()); | 1649 Handle<JSObject> holder(lookup->holder()); |
1667 switch (lookup->type()) { | 1650 switch (lookup->type()) { |
1668 case FIELD: | 1651 case FIELD: |
1669 return isolate()->stub_cache()->ComputeStoreField( | 1652 return isolate()->stub_cache()->ComputeStoreField( |
1670 name, receiver, lookup, strict_mode()); | 1653 name, receiver, lookup, strict_mode()); |
1671 case NORMAL: | 1654 case NORMAL: |
1672 if (receiver->IsGlobalObject()) { | 1655 if (receiver->IsGlobalObject()) { |
1673 // The stub generated for the global object picks the value directly | 1656 // The stub generated for the global object picks the value directly |
1674 // from the property cell. So the property must be directly on the | 1657 // from the property cell. So the property must be directly on the |
1675 // global object. | 1658 // global object. |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2044 ASSERT(!stub.is_null()); | 2027 ASSERT(!stub.is_null()); |
2045 set_target(*stub); | 2028 set_target(*stub); |
2046 TRACE_IC("StoreIC", key); | 2029 TRACE_IC("StoreIC", key); |
2047 } | 2030 } |
2048 | 2031 |
2049 return Runtime::SetObjectPropertyOrFail( | 2032 return Runtime::SetObjectPropertyOrFail( |
2050 isolate(), object , key, value, NONE, strict_mode()); | 2033 isolate(), object , key, value, NONE, strict_mode()); |
2051 } | 2034 } |
2052 | 2035 |
2053 | 2036 |
2054 Handle<Code> KeyedStoreIC::CompileStoreHandler(LookupResult* lookup, | 2037 Handle<Code> KeyedStoreIC::CompileHandler(LookupResult* lookup, |
2055 Handle<JSObject> receiver, | 2038 Handle<JSObject> receiver, |
2056 Handle<String> name, | 2039 Handle<String> name, |
2057 Handle<Object> value) { | 2040 Handle<Object> value) { |
2058 // If the property has a non-field type allowing map transitions | 2041 // If the property has a non-field type allowing map transitions |
2059 // where there is extra room in the object, we leave the IC in its | 2042 // where there is extra room in the object, we leave the IC in its |
2060 // current state. | 2043 // current state. |
2061 switch (lookup->type()) { | 2044 switch (lookup->type()) { |
2062 case FIELD: | 2045 case FIELD: |
2063 return isolate()->stub_cache()->ComputeKeyedStoreField( | 2046 return isolate()->stub_cache()->ComputeKeyedStoreField( |
2064 name, receiver, lookup, strict_mode()); | 2047 name, receiver, lookup, strict_mode()); |
2065 case TRANSITION: { | 2048 case TRANSITION: { |
2066 // Explicitly pass in the receiver map since LookupForWrite may have | 2049 // Explicitly pass in the receiver map since LookupForWrite may have |
2067 // stored something else than the receiver in the holder. | 2050 // stored something else than the receiver in the holder. |
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2819 #undef ADDR | 2802 #undef ADDR |
2820 }; | 2803 }; |
2821 | 2804 |
2822 | 2805 |
2823 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2806 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
2824 return IC_utilities[id]; | 2807 return IC_utilities[id]; |
2825 } | 2808 } |
2826 | 2809 |
2827 | 2810 |
2828 } } // namespace v8::internal | 2811 } } // namespace v8::internal |
OLD | NEW |