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

Side by Side Diff: src/stub-cache.cc

Issue 14367018: Add monomorphic CompareNilICs and Crankshaft support (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback Created 7 years, 8 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 | « src/stub-cache.h ('k') | src/type-info.h » ('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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 Handle<JSObject> StubCache::StubHolder(Handle<JSObject> receiver, 103 Handle<JSObject> StubCache::StubHolder(Handle<JSObject> receiver,
104 Handle<JSObject> holder) { 104 Handle<JSObject> holder) {
105 InlineCacheHolderFlag cache_holder = 105 InlineCacheHolderFlag cache_holder =
106 IC::GetCodeCacheForObject(*receiver, *holder); 106 IC::GetCodeCacheForObject(*receiver, *holder);
107 return Handle<JSObject>(IC::GetCodeCacheHolder( 107 return Handle<JSObject>(IC::GetCodeCacheHolder(
108 isolate_, *receiver, cache_holder)); 108 isolate_, *receiver, cache_holder));
109 } 109 }
110 110
111 111
112 Handle<Code> StubCache::FindIC(Handle<Name> name, 112 Handle<Code> StubCache::FindIC(Handle<Name> name,
113 Handle<Map> stub_holder_map,
114 Code::Kind kind,
115 Code::StubType type,
116 Code::ExtraICState extra_state) {
117 Code::Flags flags = Code::ComputeMonomorphicFlags(kind, extra_state, type);
118 Handle<Object> probe(stub_holder_map->FindInCodeCache(*name, flags),
119 isolate_);
120 if (probe->IsCode()) return Handle<Code>::cast(probe);
121 return Handle<Code>::null();
122 }
123
124
125 Handle<Code> StubCache::FindIC(Handle<Name> name,
113 Handle<JSObject> stub_holder, 126 Handle<JSObject> stub_holder,
114 Code::Kind kind, 127 Code::Kind kind,
115 Code::StubType type, 128 Code::StubType type,
116 Code::ExtraICState extra_ic_state) { 129 Code::ExtraICState extra_ic_state) {
117 Code::Flags flags = Code::ComputeMonomorphicFlags(kind, extra_ic_state, type); 130 return FindIC(name, Handle<Map>(stub_holder->map()), kind,
118 Handle<Object> probe(stub_holder->map()->FindInCodeCache(*name, flags), 131 type, extra_ic_state);
119 isolate_);
120 if (probe->IsCode()) return Handle<Code>::cast(probe);
121 return Handle<Code>::null();
122 } 132 }
123 133
124 134
125 Handle<Code> StubCache::FindHandler(Handle<Name> name, 135 Handle<Code> StubCache::FindHandler(Handle<Name> name,
126 Handle<JSObject> receiver, 136 Handle<JSObject> receiver,
127 Handle<JSObject> stub_holder, 137 Handle<JSObject> stub_holder,
128 Code::Kind kind, 138 Code::Kind kind,
129 Code::StubType type) { 139 Code::StubType type) {
130 Code::ExtraICState extra_ic_state = Code::ComputeExtraICState( 140 Code::ExtraICState extra_ic_state = Code::ComputeExtraICState(
131 receiver.is_identical_to(stub_holder) ? Code::OWN_STUB 141 receiver.is_identical_to(stub_holder) ? Code::OWN_STUB
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 ? isolate_->builtins()->Builtins::StoreIC_Normal_Strict() 490 ? isolate_->builtins()->Builtins::StoreIC_Normal_Strict()
481 : isolate_->builtins()->Builtins::StoreIC_Normal(); 491 : isolate_->builtins()->Builtins::StoreIC_Normal();
482 } 492 }
483 493
484 494
485 Handle<Code> StubCache::ComputeStoreGlobal(Handle<Name> name, 495 Handle<Code> StubCache::ComputeStoreGlobal(Handle<Name> name,
486 Handle<GlobalObject> receiver, 496 Handle<GlobalObject> receiver,
487 Handle<JSGlobalPropertyCell> cell, 497 Handle<JSGlobalPropertyCell> cell,
488 StrictModeFlag strict_mode) { 498 StrictModeFlag strict_mode) {
489 Handle<Code> stub = FindIC( 499 Handle<Code> stub = FindIC(
490 name, receiver, Code::STORE_IC, Code::NORMAL, strict_mode); 500 name, Handle<JSObject>::cast(receiver),
501 Code::STORE_IC, Code::NORMAL, strict_mode);
491 if (!stub.is_null()) return stub; 502 if (!stub.is_null()) return stub;
492 503
493 StoreStubCompiler compiler(isolate_, strict_mode); 504 StoreStubCompiler compiler(isolate_, strict_mode);
494 Handle<Code> code = compiler.CompileStoreGlobal(receiver, cell, name); 505 Handle<Code> code = compiler.CompileStoreGlobal(receiver, cell, name);
495 JSObject::UpdateMapCodeCache(receiver, name, code); 506 JSObject::UpdateMapCodeCache(receiver, name, code);
496 return code; 507 return code;
497 } 508 }
498 509
499 510
500 Handle<Code> StubCache::ComputeStoreCallback( 511 Handle<Code> StubCache::ComputeStoreCallback(
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 int entry = cache->FindEntry(isolate_, flags); 897 int entry = cache->FindEntry(isolate_, flags);
887 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); 898 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry)));
888 899
889 StubCompiler compiler(isolate_); 900 StubCompiler compiler(isolate_);
890 Handle<Code> code = compiler.CompileCallMiss(flags); 901 Handle<Code> code = compiler.CompileCallMiss(flags);
891 FillCache(isolate_, code); 902 FillCache(isolate_, code);
892 return code; 903 return code;
893 } 904 }
894 905
895 906
907 Handle<Code> StubCache::ComputeCompareNil(Handle<Map> receiver_map,
908 NilValue nil,
909 CompareNilICStub::Types types) {
910 CompareNilICStub stub(kNonStrictEquality, nil, types);
911
912 Handle<String> name(isolate_->heap()->empty_string());
913 if (!receiver_map->is_shared()) {
914 Handle<Code> cached_ic = FindIC(name, receiver_map, Code::COMPARE_NIL_IC,
915 Code::NORMAL, stub.GetExtraICState());
916 if (!cached_ic.is_null()) return cached_ic;
917 }
918
919 Handle<Code> ic = stub.GetCode(isolate_);
920 // For monomorphic maps, use the code as a template, copying and replacing
921 // the monomorphic map that checks the object's type.
922 ic = isolate_->factory()->CopyCode(ic);
923 ic->ReplaceFirstMap(*receiver_map);
924
925 if (!receiver_map->is_shared()) {
926 Map::UpdateCodeCache(receiver_map, name, ic);
927 }
928
929 return ic;
930 }
931
932
896 Handle<Code> StubCache::ComputeLoadElementPolymorphic( 933 Handle<Code> StubCache::ComputeLoadElementPolymorphic(
897 MapHandleList* receiver_maps) { 934 MapHandleList* receiver_maps) {
898 Code::Flags flags = Code::ComputeFlags(Code::KEYED_LOAD_IC, POLYMORPHIC); 935 Code::Flags flags = Code::ComputeFlags(Code::KEYED_LOAD_IC, POLYMORPHIC);
899 Handle<PolymorphicCodeCache> cache = 936 Handle<PolymorphicCodeCache> cache =
900 isolate_->factory()->polymorphic_code_cache(); 937 isolate_->factory()->polymorphic_code_cache();
901 Handle<Object> probe = cache->Lookup(receiver_maps, flags); 938 Handle<Object> probe = cache->Lookup(receiver_maps, flags);
902 if (probe->IsCode()) return Handle<Code>::cast(probe); 939 if (probe->IsCode()) return Handle<Code>::cast(probe);
903 940
904 CodeHandleList handlers(receiver_maps->length()); 941 CodeHandleList handlers(receiver_maps->length());
905 KeyedLoadStubCompiler compiler(isolate_); 942 KeyedLoadStubCompiler compiler(isolate_);
(...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after
2062 Handle<FunctionTemplateInfo>( 2099 Handle<FunctionTemplateInfo>(
2063 FunctionTemplateInfo::cast(signature->receiver())); 2100 FunctionTemplateInfo::cast(signature->receiver()));
2064 } 2101 }
2065 } 2102 }
2066 2103
2067 is_simple_api_call_ = true; 2104 is_simple_api_call_ = true;
2068 } 2105 }
2069 2106
2070 2107
2071 } } // namespace v8::internal 2108 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/stub-cache.h ('k') | src/type-info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698