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

Side by Side Diff: src/ic/ic.cc

Issue 584043002: Add MEGAMORPHIC state support for KeyedStoreIC (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased and updated Created 6 years, 2 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/arguments.h" 9 #include "src/arguments.h"
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 switch (state()) { 794 switch (state()) {
795 case UNINITIALIZED: 795 case UNINITIALIZED:
796 case PREMONOMORPHIC: 796 case PREMONOMORPHIC:
797 UpdateMonomorphicIC(code, name); 797 UpdateMonomorphicIC(code, name);
798 break; 798 break;
799 case PROTOTYPE_FAILURE: 799 case PROTOTYPE_FAILURE:
800 case MONOMORPHIC: 800 case MONOMORPHIC:
801 case POLYMORPHIC: 801 case POLYMORPHIC:
802 if (!target()->is_keyed_stub() || state() == PROTOTYPE_FAILURE) { 802 if (!target()->is_keyed_stub() || state() == PROTOTYPE_FAILURE) {
803 if (UpdatePolymorphicIC(name, code)) break; 803 if (UpdatePolymorphicIC(name, code)) break;
804 // For keyed stubs, we can't know whether old handlers were for the
805 // same key.
804 CopyICToMegamorphicCache(name); 806 CopyICToMegamorphicCache(name);
805 } 807 }
806 set_target(*megamorphic_stub()); 808 set_target(*megamorphic_stub());
807 // Fall through. 809 // Fall through.
808 case MEGAMORPHIC: 810 case MEGAMORPHIC:
809 UpdateMegamorphicCache(*receiver_type(), *name, *code); 811 UpdateMegamorphicCache(*receiver_type(), *name, *code);
812 // Indicate that we've handled this case.
813 target_set_ = true;
810 break; 814 break;
811 case DEBUG_STUB: 815 case DEBUG_STUB:
812 break; 816 break;
813 case DEFAULT: 817 case DEFAULT:
818 UNREACHABLE();
819 break;
814 case GENERIC: 820 case GENERIC:
815 UNREACHABLE(); 821 // The generic keyed store stub re-uses store handlers, which can miss.
822 // That's ok, no reason to do anything.
823 DCHECK(target()->kind() == Code::KEYED_STORE_IC);
816 break; 824 break;
817 } 825 }
818 } 826 }
819 827
820 828
821 Handle<Code> LoadIC::initialize_stub(Isolate* isolate, 829 Handle<Code> LoadIC::initialize_stub(Isolate* isolate,
822 ExtraICState extra_state) { 830 ExtraICState extra_state) {
823 return PropertyICCompiler::ComputeLoad(isolate, UNINITIALIZED, extra_state); 831 return PropertyICCompiler::ComputeLoad(isolate, UNINITIALIZED, extra_state);
824 } 832 }
825 833
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 } else { 895 } else {
888 code = ComputeHandler(lookup); 896 code = ComputeHandler(lookup);
889 } 897 }
890 898
891 PatchCache(lookup->name(), code); 899 PatchCache(lookup->name(), code);
892 TRACE_IC("LoadIC", lookup->name()); 900 TRACE_IC("LoadIC", lookup->name());
893 } 901 }
894 902
895 903
896 void IC::UpdateMegamorphicCache(HeapType* type, Name* name, Code* code) { 904 void IC::UpdateMegamorphicCache(HeapType* type, Name* name, Code* code) {
897 if (kind() == Code::KEYED_LOAD_IC || kind() == Code::KEYED_STORE_IC) return; 905 if (kind() == Code::KEYED_LOAD_IC) return;
mvstanton 2014/10/08 14:04:51 Maybe a comment here? I'm not sure why keyed store
Jakob Kummerow 2014/10/20 10:39:37 Because this CL adds megamorphic state for keyed s
898 Map* map = *TypeToMap(type, isolate()); 906 Map* map = *TypeToMap(type, isolate());
899 isolate()->stub_cache()->Set(name, map, code); 907 isolate()->stub_cache()->Set(name, map, code);
900 } 908 }
901 909
902 910
903 Handle<Code> IC::ComputeHandler(LookupIterator* lookup, Handle<Object> value) { 911 Handle<Code> IC::ComputeHandler(LookupIterator* lookup, Handle<Object> value) {
904 bool receiver_is_holder = 912 bool receiver_is_holder =
905 lookup->GetReceiver().is_identical_to(lookup->GetHolder<JSObject>()); 913 lookup->GetReceiver().is_identical_to(lookup->GetHolder<JSObject>());
906 CacheHolderFlag flag; 914 CacheHolderFlag flag;
907 Handle<Map> stub_holder_map = IC::GetHandlerCacheHolder( 915 Handle<Map> stub_holder_map = IC::GetHandlerCacheHolder(
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 } 1366 }
1359 1367
1360 1368
1361 Handle<Code> StoreIC::megamorphic_stub() { 1369 Handle<Code> StoreIC::megamorphic_stub() {
1362 if (kind() == Code::STORE_IC) { 1370 if (kind() == Code::STORE_IC) {
1363 return PropertyICCompiler::ComputeStore(isolate(), MEGAMORPHIC, 1371 return PropertyICCompiler::ComputeStore(isolate(), MEGAMORPHIC,
1364 extra_ic_state()); 1372 extra_ic_state());
1365 } else { 1373 } else {
1366 DCHECK(kind() == Code::KEYED_STORE_IC); 1374 DCHECK(kind() == Code::KEYED_STORE_IC);
1367 if (strict_mode() == STRICT) { 1375 if (strict_mode() == STRICT) {
1368 return isolate()->builtins()->KeyedStoreIC_Generic_Strict(); 1376 return isolate()->builtins()->KeyedStoreIC_Megamorphic_Strict();
1369 } else { 1377 } else {
1370 return isolate()->builtins()->KeyedStoreIC_Generic(); 1378 return isolate()->builtins()->KeyedStoreIC_Megamorphic();
1371 } 1379 }
1372 } 1380 }
1373 } 1381 }
1374 1382
1375 1383
1376 Handle<Code> StoreIC::generic_stub() const { 1384 Handle<Code> StoreIC::generic_stub() const {
1377 if (kind() == Code::STORE_IC) { 1385 if (kind() == Code::STORE_IC) {
1378 return PropertyICCompiler::ComputeStore(isolate(), GENERIC, 1386 return PropertyICCompiler::ComputeStore(isolate(), GENERIC,
1379 extra_ic_state()); 1387 extra_ic_state());
1380 } else { 1388 } else {
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1806 1814
1807 Handle<Object> store_handle; 1815 Handle<Object> store_handle;
1808 Handle<Code> stub = generic_stub(); 1816 Handle<Code> stub = generic_stub();
1809 1817
1810 if (key->IsInternalizedString()) { 1818 if (key->IsInternalizedString()) {
1811 ASSIGN_RETURN_ON_EXCEPTION( 1819 ASSIGN_RETURN_ON_EXCEPTION(
1812 isolate(), store_handle, 1820 isolate(), store_handle,
1813 StoreIC::Store(object, Handle<String>::cast(key), value, 1821 StoreIC::Store(object, Handle<String>::cast(key), value,
1814 JSReceiver::MAY_BE_STORE_FROM_KEYED), 1822 JSReceiver::MAY_BE_STORE_FROM_KEYED),
1815 Object); 1823 Object);
1816 // TODO(jkummerow): Ideally we'd wrap this in "if (!is_target_set())", 1824 if (!is_target_set()) {
1817 // but doing so causes Hydrogen crashes. Needs investigation. 1825 TRACE_GENERIC_IC(isolate(), "KeyedStoreIC",
1818 TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", 1826 "unhandled internalized string key");
1819 "unhandled internalized string key"); 1827 TRACE_IC("StoreIC", key);
1820 TRACE_IC("StoreIC", key); 1828 set_target(*stub);
1821 set_target(*stub); 1829 }
1822 return store_handle; 1830 return store_handle;
1823 } 1831 }
1824 1832
1825 bool use_ic = 1833 bool use_ic =
1826 FLAG_use_ic && !object->IsStringWrapper() && 1834 FLAG_use_ic && !object->IsStringWrapper() &&
1827 !object->IsAccessCheckNeeded() && !object->IsJSGlobalProxy() && 1835 !object->IsAccessCheckNeeded() && !object->IsJSGlobalProxy() &&
1828 !(object->IsJSObject() && JSObject::cast(*object)->map()->is_observed()); 1836 !(object->IsJSObject() && JSObject::cast(*object)->map()->is_observed());
1829 if (use_ic && !object->IsSmi()) { 1837 if (use_ic && !object->IsSmi()) {
1830 // Don't use ICs for maps of the objects in Array's prototype chain. We 1838 // Don't use ICs for maps of the objects in Array's prototype chain. We
1831 // expect to be able to trap element sets to objects with those maps in 1839 // expect to be able to trap element sets to objects with those maps in
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
2081 } 2089 }
2082 2090
2083 2091
2084 // Used from ic-<arch>.cc. 2092 // Used from ic-<arch>.cc.
2085 RUNTIME_FUNCTION(StoreIC_Miss) { 2093 RUNTIME_FUNCTION(StoreIC_Miss) {
2086 TimerEventScope<TimerEventIcMiss> timer(isolate); 2094 TimerEventScope<TimerEventIcMiss> timer(isolate);
2087 HandleScope scope(isolate); 2095 HandleScope scope(isolate);
2088 DCHECK(args.length() == 3); 2096 DCHECK(args.length() == 3);
2089 StoreIC ic(IC::NO_EXTRA_FRAME, isolate); 2097 StoreIC ic(IC::NO_EXTRA_FRAME, isolate);
2090 Handle<Object> receiver = args.at<Object>(0); 2098 Handle<Object> receiver = args.at<Object>(0);
2091 Handle<String> key = args.at<String>(1); 2099 Handle<Name> key = args.at<Name>(1);
2092 ic.UpdateState(receiver, key); 2100 ic.UpdateState(receiver, key);
2093 Handle<Object> result; 2101 Handle<Object> result;
2094 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 2102 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
2095 isolate, result, ic.Store(receiver, key, args.at<Object>(2))); 2103 isolate, result, ic.Store(receiver, key, args.at<Object>(2)));
2096 return *result; 2104 return *result;
2097 } 2105 }
2098 2106
2099 2107
2100 RUNTIME_FUNCTION(StoreIC_MissFromStubFailure) { 2108 RUNTIME_FUNCTION(StoreIC_MissFromStubFailure) {
2101 TimerEventScope<TimerEventIcMiss> timer(isolate); 2109 TimerEventScope<TimerEventIcMiss> timer(isolate);
2102 HandleScope scope(isolate); 2110 HandleScope scope(isolate);
2103 DCHECK(args.length() == 3 || args.length() == 4); 2111 DCHECK(args.length() == 3 || args.length() == 4);
2104 StoreIC ic(IC::EXTRA_CALL_FRAME, isolate); 2112 StoreIC ic(IC::EXTRA_CALL_FRAME, isolate);
2105 Handle<Object> receiver = args.at<Object>(0); 2113 Handle<Object> receiver = args.at<Object>(0);
2106 Handle<String> key = args.at<String>(1); 2114 Handle<Name> key = args.at<Name>(1);
2107 ic.UpdateState(receiver, key); 2115 ic.UpdateState(receiver, key);
2108 Handle<Object> result; 2116 Handle<Object> result;
2109 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 2117 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
2110 isolate, result, ic.Store(receiver, key, args.at<Object>(2))); 2118 isolate, result, ic.Store(receiver, key, args.at<Object>(2)));
2111 return *result; 2119 return *result;
2112 } 2120 }
2113 2121
2114 2122
2115 // Used from ic-<arch>.cc. 2123 // Used from ic-<arch>.cc.
2116 RUNTIME_FUNCTION(KeyedStoreIC_Miss) { 2124 RUNTIME_FUNCTION(KeyedStoreIC_Miss) {
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
2662 static const Address IC_utilities[] = { 2670 static const Address IC_utilities[] = {
2663 #define ADDR(name) FUNCTION_ADDR(name), 2671 #define ADDR(name) FUNCTION_ADDR(name),
2664 IC_UTIL_LIST(ADDR) NULL 2672 IC_UTIL_LIST(ADDR) NULL
2665 #undef ADDR 2673 #undef ADDR
2666 }; 2674 };
2667 2675
2668 2676
2669 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } 2677 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; }
2670 } 2678 }
2671 } // namespace v8::internal 2679 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ic/ic.h ('k') | src/ic/x64/ic-x64.cc » ('j') | src/ic/x64/stub-cache-x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698