1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef V8_IC_IC_COMPILER_H_
6 #define V8_IC_IC_COMPILER_H_
8 #include "src/ic/access-compiler.h"
14 class PropertyICCompiler : public PropertyAccessCompiler {
16 // Finds the Code object stored in the Heap::non_monomorphic_cache().
17 static Code* FindPreMonomorphic(Isolate* isolate, Code::Kind kind,
18 ExtraICState extra_ic_state);
21 static Handle<Code> ComputeStore(Isolate* isolate, InlineCacheState ic_state,
22 ExtraICState extra_state);
24 static Handle<Code> ComputeMonomorphic(Code::Kind kind, Handle<Name> name,
25 Handle<Map> map, Handle<Code> handler,
26 ExtraICState extra_ic_state);
27 static Handle<Code> ComputePolymorphic(Code::Kind kind, MapHandleList* maps,
28 CodeHandleList* handlers,
29 int number_of_valid_maps,
31 ExtraICState extra_ic_state);
34 static Handle<Code> ComputeKeyedLoadMonomorphicHandler(
35 Handle<Map> receiver_map);
37 static Handle<Code> ComputeKeyedStoreMonomorphic(
38 Handle<Map> receiver_map, LanguageMode language_mode,
39 KeyedAccessStoreMode store_mode);
40 static Handle<Code> ComputeKeyedLoadPolymorphic(MapHandleList* receiver_maps);
41 static Handle<Code> ComputeKeyedStorePolymorphic(
42 MapHandleList* receiver_maps, KeyedAccessStoreMode store_mode,
43 LanguageMode language_mode);
46 static Handle<Code> ComputeCompareNil(Handle<Map> receiver_map,
47 CompareNilICStub* stub);
50 // TODO(verwaest): Move all uses of these helpers to the PropertyICCompiler
51 // and make the helpers private.
52 static void GenerateRuntimeSetProperty(MacroAssembler* masm,
53 LanguageMode language_mode);
57 PropertyICCompiler(Isolate* isolate, Code::Kind kind,
58 ExtraICState extra_ic_state = kNoExtraICState,
59 CacheHolderFlag cache_holder = kCacheOnReceiver)
60 : PropertyAccessCompiler(isolate, kind, cache_holder),
61 extra_ic_state_(extra_ic_state) {}
63 static Handle<Code> Find(Handle<Name> name, Handle<Map> stub_holder_map,
65 ExtraICState extra_ic_state = kNoExtraICState,
66 CacheHolderFlag cache_holder = kCacheOnReceiver);
68 Handle<Code> CompileLoadInitialize(Code::Flags flags);
69 Handle<Code> CompileStoreInitialize(Code::Flags flags);
70 Handle<Code> CompileStorePreMonomorphic(Code::Flags flags);
71 Handle<Code> CompileStoreGeneric(Code::Flags flags);
72 Handle<Code> CompileStoreMegamorphic(Code::Flags flags);
74 Handle<Code> CompileMonomorphic(Handle<Map> map, Handle<Code> handler,
75 Handle<Name> name, IcCheckType check);
76 Handle<Code> CompilePolymorphic(MapHandleList* maps, CodeHandleList* handlers,
77 Handle<Name> name, Code::StubType type,
80 Handle<Code> CompileKeyedStoreMonomorphic(Handle<Map> receiver_map,
81 KeyedAccessStoreMode store_mode);
82 Handle<Code> CompileKeyedStorePolymorphic(MapHandleList* receiver_maps,
83 KeyedAccessStoreMode store_mode);
84 Handle<Code> CompileKeyedStorePolymorphic(MapHandleList* receiver_maps,
85 CodeHandleList* handler_stubs,
86 MapHandleList* transitioned_maps);
88 bool IncludesNumberMap(MapHandleList* maps);
90 Handle<Code> GetCode(Code::Kind kind, Code::StubType type, Handle<Name> name,
91 InlineCacheState state = MONOMORPHIC);
93 Logger::LogEventsAndTags log_kind(Handle<Code> code) {
94 if (kind() == Code::LOAD_IC) {
95 return code->ic_state() == MONOMORPHIC ? Logger::LOAD_IC_TAG
96 : Logger::LOAD_POLYMORPHIC_IC_TAG;
97 } else if (kind() == Code::KEYED_LOAD_IC) {
98 return code->ic_state() == MONOMORPHIC
99 ? Logger::KEYED_LOAD_IC_TAG
100 : Logger::KEYED_LOAD_POLYMORPHIC_IC_TAG;
101 } else if (kind() == Code::STORE_IC) {
102 return code->ic_state() == MONOMORPHIC ? Logger::STORE_IC_TAG
103 : Logger::STORE_POLYMORPHIC_IC_TAG;
105 DCHECK_EQ(Code::KEYED_STORE_IC, kind());
106 return code->ic_state() == MONOMORPHIC
107 ? Logger::KEYED_STORE_IC_TAG
108 : Logger::KEYED_STORE_POLYMORPHIC_IC_TAG;
112 const ExtraICState extra_ic_state_;
117 } // namespace v8::internal
119 #endif // V8_IC_IC_COMPILER_H_