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 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1102 Handle<Map> receiver_map = receiver_maps->at(i); | 1102 Handle<Map> receiver_map = receiver_maps->at(i); |
1103 Handle<Code> cached_stub = ComputeMonomorphicStubWithoutMapCheck( | 1103 Handle<Code> cached_stub = ComputeMonomorphicStubWithoutMapCheck( |
1104 receiver_map, strict_mode, growth_mode); | 1104 receiver_map, strict_mode, growth_mode); |
1105 handler_ics.Add(cached_stub); | 1105 handler_ics.Add(cached_stub); |
1106 } | 1106 } |
1107 KeyedLoadStubCompiler compiler(isolate()); | 1107 KeyedLoadStubCompiler compiler(isolate()); |
1108 Handle<Code> code = compiler.CompileLoadPolymorphic( | 1108 Handle<Code> code = compiler.CompileLoadPolymorphic( |
1109 receiver_maps, &handler_ics); | 1109 receiver_maps, &handler_ics); |
1110 isolate()->counters()->keyed_load_polymorphic_stubs()->Increment(); | 1110 isolate()->counters()->keyed_load_polymorphic_stubs()->Increment(); |
1111 PROFILE(isolate(), | 1111 PROFILE(isolate(), |
1112 CodeCreateEvent(Logger::KEYED_LOAD_MEGAMORPHIC_IC_TAG, *code, 0)); | 1112 CodeCreateEvent(Logger::KEYED_LOAD_POLYMORPHIC_IC_TAG, *code, 0)); |
1113 return code; | 1113 return code; |
1114 } | 1114 } |
1115 | 1115 |
1116 | 1116 |
1117 static Handle<Object> TryConvertKey(Handle<Object> key, Isolate* isolate) { | 1117 static Handle<Object> TryConvertKey(Handle<Object> key, Isolate* isolate) { |
1118 // This helper implements a few common fast cases for converting | 1118 // This helper implements a few common fast cases for converting |
1119 // non-smi keys of keyed loads/stores to a smi or a string. | 1119 // non-smi keys of keyed loads/stores to a smi or a string. |
1120 if (key->IsHeapNumber()) { | 1120 if (key->IsHeapNumber()) { |
1121 double value = Handle<HeapNumber>::cast(key)->value(); | 1121 double value = Handle<HeapNumber>::cast(key)->value(); |
1122 if (isnan(value)) { | 1122 if (isnan(value)) { |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1322 // repeatedly try to rewrite. | 1322 // repeatedly try to rewrite. |
1323 code = generic_stub(); | 1323 code = generic_stub(); |
1324 break; | 1324 break; |
1325 } | 1325 } |
1326 } | 1326 } |
1327 | 1327 |
1328 // Patch the call site depending on the state of the cache. | 1328 // Patch the call site depending on the state of the cache. |
1329 switch (state) { | 1329 switch (state) { |
1330 case UNINITIALIZED: | 1330 case UNINITIALIZED: |
1331 case PREMONOMORPHIC: | 1331 case PREMONOMORPHIC: |
| 1332 case POLYMORPHIC: |
1332 set_target(*code); | 1333 set_target(*code); |
1333 break; | 1334 break; |
1334 case MONOMORPHIC: | 1335 case MONOMORPHIC: |
1335 // Only move to megamorphic if the target changes. | 1336 // Only move to megamorphic if the target changes. |
1336 if (target() != *code) { | 1337 if (target() != *code) { |
1337 set_target(*megamorphic_stub()); | 1338 set_target(*megamorphic_stub()); |
1338 } | 1339 } |
1339 break; | 1340 break; |
1340 case MEGAMORPHIC: | 1341 case MEGAMORPHIC: |
1341 case DEBUG_BREAK: | 1342 case DEBUG_BREAK: |
1342 case DEBUG_PREPARE_STEP_IN: | 1343 case DEBUG_PREPARE_STEP_IN: |
1343 break; | 1344 break; |
1344 case MONOMORPHIC_PROTOTYPE_FAILURE: | 1345 case MONOMORPHIC_PROTOTYPE_FAILURE: |
1345 case POLYMORPHIC: | |
1346 UNREACHABLE(); | 1346 UNREACHABLE(); |
1347 break; | 1347 break; |
1348 } | 1348 } |
1349 | 1349 |
1350 TRACE_IC("KeyedLoadIC", name, state, target()); | 1350 TRACE_IC("KeyedLoadIC", name, state, target()); |
1351 } | 1351 } |
1352 | 1352 |
1353 | 1353 |
1354 static bool StoreICableLookup(LookupResult* lookup) { | 1354 static bool StoreICableLookup(LookupResult* lookup) { |
1355 // Bail out if we didn't find a result. | 1355 // Bail out if we didn't find a result. |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1644 void KeyedIC::GetReceiverMapsForStub(Handle<Code> stub, | 1644 void KeyedIC::GetReceiverMapsForStub(Handle<Code> stub, |
1645 MapHandleList* result) { | 1645 MapHandleList* result) { |
1646 ASSERT(stub->is_inline_cache_stub()); | 1646 ASSERT(stub->is_inline_cache_stub()); |
1647 if (!string_stub().is_null() && stub.is_identical_to(string_stub())) { | 1647 if (!string_stub().is_null() && stub.is_identical_to(string_stub())) { |
1648 return result->Add(isolate()->factory()->string_map()); | 1648 return result->Add(isolate()->factory()->string_map()); |
1649 } else if (stub->is_keyed_load_stub() || stub->is_keyed_store_stub()) { | 1649 } else if (stub->is_keyed_load_stub() || stub->is_keyed_store_stub()) { |
1650 switch (stub->ic_state()) { | 1650 switch (stub->ic_state()) { |
1651 case MONOMORPHIC: | 1651 case MONOMORPHIC: |
1652 result->Add(Handle<Map>(stub->FindFirstMap())); | 1652 result->Add(Handle<Map>(stub->FindFirstMap())); |
1653 break; | 1653 break; |
1654 case MEGAMORPHIC: { | 1654 case POLYMORPHIC: { |
1655 AssertNoAllocation no_allocation; | 1655 AssertNoAllocation no_allocation; |
1656 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); | 1656 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); |
1657 for (RelocIterator it(*stub, mask); !it.done(); it.next()) { | 1657 for (RelocIterator it(*stub, mask); !it.done(); it.next()) { |
1658 RelocInfo* info = it.rinfo(); | 1658 RelocInfo* info = it.rinfo(); |
1659 Handle<Object> object(info->target_object()); | 1659 Handle<Object> object(info->target_object()); |
1660 ASSERT(object->IsMap()); | 1660 ASSERT(object->IsMap()); |
1661 AddOneReceiverMapIfMissing(result, Handle<Map>::cast(object)); | 1661 AddOneReceiverMapIfMissing(result, Handle<Map>::cast(object)); |
1662 } | 1662 } |
1663 break; | 1663 break; |
1664 } | 1664 } |
| 1665 case MEGAMORPHIC: |
| 1666 break; |
1665 case UNINITIALIZED: | 1667 case UNINITIALIZED: |
1666 case PREMONOMORPHIC: | 1668 case PREMONOMORPHIC: |
1667 case MONOMORPHIC_PROTOTYPE_FAILURE: | 1669 case MONOMORPHIC_PROTOTYPE_FAILURE: |
1668 case POLYMORPHIC: | |
1669 case DEBUG_BREAK: | 1670 case DEBUG_BREAK: |
1670 case DEBUG_PREPARE_STEP_IN: | 1671 case DEBUG_PREPARE_STEP_IN: |
1671 UNREACHABLE(); | 1672 UNREACHABLE(); |
1672 break; | 1673 break; |
1673 } | 1674 } |
1674 } | 1675 } |
1675 } | 1676 } |
1676 | 1677 |
1677 | 1678 |
1678 Handle<Code> KeyedIC::ComputeStub(Handle<JSObject> receiver, | 1679 Handle<Code> KeyedIC::ComputeStub(Handle<JSObject> receiver, |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1870 } | 1871 } |
1871 ASSERT(!cached_stub.is_null()); | 1872 ASSERT(!cached_stub.is_null()); |
1872 handler_ics.Add(cached_stub); | 1873 handler_ics.Add(cached_stub); |
1873 transitioned_maps.Add(transitioned_map); | 1874 transitioned_maps.Add(transitioned_map); |
1874 } | 1875 } |
1875 KeyedStoreStubCompiler compiler(isolate(), strict_mode, grow_mode); | 1876 KeyedStoreStubCompiler compiler(isolate(), strict_mode, grow_mode); |
1876 Handle<Code> code = compiler.CompileStorePolymorphic( | 1877 Handle<Code> code = compiler.CompileStorePolymorphic( |
1877 receiver_maps, &handler_ics, &transitioned_maps); | 1878 receiver_maps, &handler_ics, &transitioned_maps); |
1878 isolate()->counters()->keyed_store_polymorphic_stubs()->Increment(); | 1879 isolate()->counters()->keyed_store_polymorphic_stubs()->Increment(); |
1879 PROFILE(isolate(), | 1880 PROFILE(isolate(), |
1880 CodeCreateEvent(Logger::KEYED_STORE_MEGAMORPHIC_IC_TAG, *code, 0)); | 1881 CodeCreateEvent(Logger::KEYED_STORE_POLYMORPHIC_IC_TAG, *code, 0)); |
1881 return code; | 1882 return code; |
1882 } | 1883 } |
1883 | 1884 |
1884 | 1885 |
1885 KeyedIC::StubKind KeyedStoreIC::GetStubKind(Handle<JSObject> receiver, | 1886 KeyedIC::StubKind KeyedStoreIC::GetStubKind(Handle<JSObject> receiver, |
1886 Handle<Object> key, | 1887 Handle<Object> key, |
1887 Handle<Object> value) { | 1888 Handle<Object> value) { |
1888 ASSERT(key->IsSmi()); | 1889 ASSERT(key->IsSmi()); |
1889 int index = Smi::cast(*key)->value(); | 1890 int index = Smi::cast(*key)->value(); |
1890 bool allow_growth = receiver->IsJSArray() && | 1891 bool allow_growth = receiver->IsJSArray() && |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2094 UNREACHABLE(); | 2095 UNREACHABLE(); |
2095 return; | 2096 return; |
2096 } | 2097 } |
2097 | 2098 |
2098 ASSERT(!code.is_null()); | 2099 ASSERT(!code.is_null()); |
2099 | 2100 |
2100 // Patch the call site depending on the state of the cache. | 2101 // Patch the call site depending on the state of the cache. |
2101 switch (state) { | 2102 switch (state) { |
2102 case UNINITIALIZED: | 2103 case UNINITIALIZED: |
2103 case PREMONOMORPHIC: | 2104 case PREMONOMORPHIC: |
| 2105 case POLYMORPHIC: |
2104 set_target(*code); | 2106 set_target(*code); |
2105 break; | 2107 break; |
2106 case MONOMORPHIC: | 2108 case MONOMORPHIC: |
2107 // Only move to megamorphic if the target changes. | 2109 // Only move to megamorphic if the target changes. |
2108 if (target() != *code) { | 2110 if (target() != *code) { |
2109 set_target((strict_mode == kStrictMode) | 2111 set_target((strict_mode == kStrictMode) |
2110 ? *megamorphic_stub_strict() | 2112 ? *megamorphic_stub_strict() |
2111 : *megamorphic_stub()); | 2113 : *megamorphic_stub()); |
2112 } | 2114 } |
2113 break; | 2115 break; |
2114 case MEGAMORPHIC: | 2116 case MEGAMORPHIC: |
2115 case DEBUG_BREAK: | 2117 case DEBUG_BREAK: |
2116 case DEBUG_PREPARE_STEP_IN: | 2118 case DEBUG_PREPARE_STEP_IN: |
2117 break; | 2119 break; |
2118 case MONOMORPHIC_PROTOTYPE_FAILURE: | 2120 case MONOMORPHIC_PROTOTYPE_FAILURE: |
2119 case POLYMORPHIC: | |
2120 UNREACHABLE(); | 2121 UNREACHABLE(); |
2121 break; | 2122 break; |
2122 } | 2123 } |
2123 | 2124 |
2124 TRACE_IC("KeyedStoreIC", name, state, target()); | 2125 TRACE_IC("KeyedStoreIC", name, state, target()); |
2125 } | 2126 } |
2126 | 2127 |
2127 | 2128 |
2128 #undef TRACE_IC | 2129 #undef TRACE_IC |
2129 | 2130 |
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2863 #undef ADDR | 2864 #undef ADDR |
2864 }; | 2865 }; |
2865 | 2866 |
2866 | 2867 |
2867 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2868 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
2868 return IC_utilities[id]; | 2869 return IC_utilities[id]; |
2869 } | 2870 } |
2870 | 2871 |
2871 | 2872 |
2872 } } // namespace v8::internal | 2873 } } // namespace v8::internal |
OLD | NEW |