Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(982)

Side by Side Diff: src/ic.cc

Issue 11747022: Introduce POLYMORPHIC (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 25 matching lines...) Expand all
36 #include "runtime.h" 36 #include "runtime.h"
37 #include "stub-cache.h" 37 #include "stub-cache.h"
38 38
39 namespace v8 { 39 namespace v8 {
40 namespace internal { 40 namespace internal {
41 41
42 #ifdef DEBUG 42 #ifdef DEBUG
43 char IC::TransitionMarkFromState(IC::State state) { 43 char IC::TransitionMarkFromState(IC::State state) {
44 switch (state) { 44 switch (state) {
45 case UNINITIALIZED: return '0'; 45 case UNINITIALIZED: return '0';
46 case PREMONOMORPHIC: return 'P'; 46 case PREMONOMORPHIC: return '.';
47 case MONOMORPHIC: return '1'; 47 case MONOMORPHIC: return '1';
48 case MONOMORPHIC_PROTOTYPE_FAILURE: return '^'; 48 case MONOMORPHIC_PROTOTYPE_FAILURE: return '^';
49 case POLYMORPHIC: return 'P';
49 case MEGAMORPHIC: return IsGeneric() ? 'G' : 'N'; 50 case MEGAMORPHIC: return IsGeneric() ? 'G' : 'N';
50 51
51 // We never see the debugger states here, because the state is 52 // We never see the debugger states here, because the state is
52 // computed from the original code - not the patched code. Let 53 // computed from the original code - not the patched code. Let
53 // these cases fall through to the unreachable code below. 54 // these cases fall through to the unreachable code below.
54 case DEBUG_BREAK: break; 55 case DEBUG_BREAK: break;
55 case DEBUG_PREPARE_STEP_IN: break; 56 case DEBUG_PREPARE_STEP_IN: break;
56 } 57 }
57 UNREACHABLE(); 58 UNREACHABLE();
58 return 0; 59 return 0;
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 Handle<JSObject> cache_object = object->IsJSObject() 766 Handle<JSObject> cache_object = object->IsJSObject()
766 ? Handle<JSObject>::cast(object) 767 ? Handle<JSObject>::cast(object)
767 : Handle<JSObject>(JSObject::cast(object->GetPrototype())); 768 : Handle<JSObject>(JSObject::cast(object->GetPrototype()));
768 // Update the stub cache. 769 // Update the stub cache.
769 isolate()->stub_cache()->Set(*name, cache_object->map(), *code); 770 isolate()->stub_cache()->Set(*name, cache_object->map(), *code);
770 break; 771 break;
771 } 772 }
772 case DEBUG_BREAK: 773 case DEBUG_BREAK:
773 case DEBUG_PREPARE_STEP_IN: 774 case DEBUG_PREPARE_STEP_IN:
774 break; 775 break;
776 case POLYMORPHIC:
777 UNREACHABLE();
778 break;
775 } 779 }
776 780
777 TRACE_IC(kind_ == Code::CALL_IC ? "CallIC" : "KeyedCallIC", 781 TRACE_IC(kind_ == Code::CALL_IC ? "CallIC" : "KeyedCallIC",
778 name, state, target()); 782 name, state, target());
779 } 783 }
780 784
781 785
782 MaybeObject* KeyedCallIC::LoadFunction(State state, 786 MaybeObject* KeyedCallIC::LoadFunction(State state,
783 Handle<Object> object, 787 Handle<Object> object,
784 Handle<Object> key) { 788 Handle<Object> key) {
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 set_target(*megamorphic_stub()); 1061 set_target(*megamorphic_stub());
1058 } 1062 }
1059 break; 1063 break;
1060 case MEGAMORPHIC: 1064 case MEGAMORPHIC:
1061 // Cache code holding map should be consistent with 1065 // Cache code holding map should be consistent with
1062 // GenerateMonomorphicCacheProbe. 1066 // GenerateMonomorphicCacheProbe.
1063 isolate()->stub_cache()->Set(*name, receiver->map(), *code); 1067 isolate()->stub_cache()->Set(*name, receiver->map(), *code);
1064 case DEBUG_BREAK: 1068 case DEBUG_BREAK:
1065 case DEBUG_PREPARE_STEP_IN: 1069 case DEBUG_PREPARE_STEP_IN:
1066 break; 1070 break;
1071 case POLYMORPHIC:
1072 UNREACHABLE();
1073 break;
1067 } 1074 }
1068 1075
1069 TRACE_IC("LoadIC", name, state, target()); 1076 TRACE_IC("LoadIC", name, state, target());
1070 } 1077 }
1071 1078
1072 1079
1073 Handle<Code> KeyedLoadIC::GetElementStubWithoutMapCheck( 1080 Handle<Code> KeyedLoadIC::GetElementStubWithoutMapCheck(
1074 bool is_js_array, 1081 bool is_js_array,
1075 ElementsKind elements_kind, 1082 ElementsKind elements_kind,
1076 KeyedAccessGrowMode grow_mode) { 1083 KeyedAccessGrowMode grow_mode) {
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 case MONOMORPHIC: 1333 case MONOMORPHIC:
1327 // Only move to megamorphic if the target changes. 1334 // Only move to megamorphic if the target changes.
1328 if (target() != *code) { 1335 if (target() != *code) {
1329 set_target(*megamorphic_stub()); 1336 set_target(*megamorphic_stub());
1330 } 1337 }
1331 case MEGAMORPHIC: 1338 case MEGAMORPHIC:
1332 case DEBUG_BREAK: 1339 case DEBUG_BREAK:
1333 case DEBUG_PREPARE_STEP_IN: 1340 case DEBUG_PREPARE_STEP_IN:
1334 break; 1341 break;
1335 case MONOMORPHIC_PROTOTYPE_FAILURE: 1342 case MONOMORPHIC_PROTOTYPE_FAILURE:
1343 case POLYMORPHIC:
1336 UNREACHABLE(); 1344 UNREACHABLE();
1337 break; 1345 break;
1338 } 1346 }
1339 1347
1340 TRACE_IC("KeyedLoadIC", name, state, target()); 1348 TRACE_IC("KeyedLoadIC", name, state, target());
1341 } 1349 }
1342 1350
1343 1351
1344 static bool StoreICableLookup(LookupResult* lookup) { 1352 static bool StoreICableLookup(LookupResult* lookup) {
1345 // Bail out if we didn't find a result. 1353 // Bail out if we didn't find a result.
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1598 : megamorphic_stub()); 1606 : megamorphic_stub());
1599 } 1607 }
1600 break; 1608 break;
1601 case MEGAMORPHIC: 1609 case MEGAMORPHIC:
1602 // Update the stub cache. 1610 // Update the stub cache.
1603 isolate()->stub_cache()->Set(*name, receiver->map(), *code); 1611 isolate()->stub_cache()->Set(*name, receiver->map(), *code);
1604 break; 1612 break;
1605 case DEBUG_BREAK: 1613 case DEBUG_BREAK:
1606 case DEBUG_PREPARE_STEP_IN: 1614 case DEBUG_PREPARE_STEP_IN:
1607 break; 1615 break;
1616 case POLYMORPHIC:
1617 UNREACHABLE();
1618 break;
1608 } 1619 }
1609 1620
1610 TRACE_IC("StoreIC", name, state, target()); 1621 TRACE_IC("StoreIC", name, state, target());
1611 } 1622 }
1612 1623
1613 1624
1614 static bool AddOneReceiverMapIfMissing(MapHandleList* receiver_maps, 1625 static bool AddOneReceiverMapIfMissing(MapHandleList* receiver_maps,
1615 Handle<Map> new_receiver_map) { 1626 Handle<Map> new_receiver_map) {
1616 ASSERT(!new_receiver_map.is_null()); 1627 ASSERT(!new_receiver_map.is_null());
1617 for (int current = 0; current < receiver_maps->length(); ++current) { 1628 for (int current = 0; current < receiver_maps->length(); ++current) {
(...skipping 24 matching lines...) Expand all
1642 RelocInfo* info = it.rinfo(); 1653 RelocInfo* info = it.rinfo();
1643 Handle<Object> object(info->target_object()); 1654 Handle<Object> object(info->target_object());
1644 ASSERT(object->IsMap()); 1655 ASSERT(object->IsMap());
1645 AddOneReceiverMapIfMissing(result, Handle<Map>::cast(object)); 1656 AddOneReceiverMapIfMissing(result, Handle<Map>::cast(object));
1646 } 1657 }
1647 break; 1658 break;
1648 } 1659 }
1649 case UNINITIALIZED: 1660 case UNINITIALIZED:
1650 case PREMONOMORPHIC: 1661 case PREMONOMORPHIC:
1651 case MONOMORPHIC_PROTOTYPE_FAILURE: 1662 case MONOMORPHIC_PROTOTYPE_FAILURE:
1663 case POLYMORPHIC:
1652 case DEBUG_BREAK: 1664 case DEBUG_BREAK:
1653 case DEBUG_PREPARE_STEP_IN: 1665 case DEBUG_PREPARE_STEP_IN:
1654 UNREACHABLE(); 1666 UNREACHABLE();
1655 break; 1667 break;
1656 } 1668 }
1657 } 1669 }
1658 } 1670 }
1659 1671
1660 1672
1661 Handle<Code> KeyedIC::ComputeStub(Handle<JSObject> receiver, 1673 Handle<Code> KeyedIC::ComputeStub(Handle<JSObject> receiver,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1735 1747
1736 if ((Code::GetKeyedAccessGrowMode(target()->extra_ic_state()) == 1748 if ((Code::GetKeyedAccessGrowMode(target()->extra_ic_state()) ==
1737 ALLOW_JSARRAY_GROWTH)) { 1749 ALLOW_JSARRAY_GROWTH)) {
1738 grow_mode = ALLOW_JSARRAY_GROWTH; 1750 grow_mode = ALLOW_JSARRAY_GROWTH;
1739 } 1751 }
1740 1752
1741 Handle<PolymorphicCodeCache> cache = 1753 Handle<PolymorphicCodeCache> cache =
1742 isolate()->factory()->polymorphic_code_cache(); 1754 isolate()->factory()->polymorphic_code_cache();
1743 Code::ExtraICState extra_state = Code::ComputeExtraICState(grow_mode, 1755 Code::ExtraICState extra_state = Code::ComputeExtraICState(grow_mode,
1744 strict_mode); 1756 strict_mode);
1745 Code::Flags flags = Code::ComputeFlags(kind(), MEGAMORPHIC, extra_state); 1757 Code::Flags flags = Code::ComputeFlags(kind(), POLYMORPHIC, extra_state);
1746 Handle<Object> probe = cache->Lookup(&target_receiver_maps, flags); 1758 Handle<Object> probe = cache->Lookup(&target_receiver_maps, flags);
1747 if (probe->IsCode()) return Handle<Code>::cast(probe); 1759 if (probe->IsCode()) return Handle<Code>::cast(probe);
1748 1760
1749 Handle<Code> stub = 1761 Handle<Code> stub =
1750 ComputePolymorphicStub(&target_receiver_maps, strict_mode, grow_mode); 1762 ComputePolymorphicStub(&target_receiver_maps, strict_mode, grow_mode);
1751 PolymorphicCodeCache::Update(cache, &target_receiver_maps, flags, stub); 1763 PolymorphicCodeCache::Update(cache, &target_receiver_maps, flags, stub);
1752 return stub; 1764 return stub;
1753 } 1765 }
1754 1766
1755 1767
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
2092 set_target((strict_mode == kStrictMode) 2104 set_target((strict_mode == kStrictMode)
2093 ? *megamorphic_stub_strict() 2105 ? *megamorphic_stub_strict()
2094 : *megamorphic_stub()); 2106 : *megamorphic_stub());
2095 } 2107 }
2096 break; 2108 break;
2097 case MEGAMORPHIC: 2109 case MEGAMORPHIC:
2098 case DEBUG_BREAK: 2110 case DEBUG_BREAK:
2099 case DEBUG_PREPARE_STEP_IN: 2111 case DEBUG_PREPARE_STEP_IN:
2100 break; 2112 break;
2101 case MONOMORPHIC_PROTOTYPE_FAILURE: 2113 case MONOMORPHIC_PROTOTYPE_FAILURE:
2114 case POLYMORPHIC:
2102 UNREACHABLE(); 2115 UNREACHABLE();
2103 break; 2116 break;
2104 } 2117 }
2105 2118
2106 TRACE_IC("KeyedStoreIC", name, state, target()); 2119 TRACE_IC("KeyedStoreIC", name, state, target());
2107 } 2120 }
2108 2121
2109 2122
2110 #undef TRACE_IC 2123 #undef TRACE_IC
2111 2124
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
2845 #undef ADDR 2858 #undef ADDR
2846 }; 2859 };
2847 2860
2848 2861
2849 Address IC::AddressFromUtilityId(IC::UtilityId id) { 2862 Address IC::AddressFromUtilityId(IC::UtilityId id) {
2850 return IC_utilities[id]; 2863 return IC_utilities[id];
2851 } 2864 }
2852 2865
2853 2866
2854 } } // namespace v8::internal 2867 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698