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, ExtraICState extra_ic_state);
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 LanguageMode language_mode);
42 static Handle<Code> ComputeKeyedStorePolymorphic(
43 MapHandleList* receiver_maps, KeyedAccessStoreMode store_mode,
44 LanguageMode language_mode);
47 static Handle<Code> ComputeCompareNil(Handle<Map> receiver_map,
48 CompareNilICStub* stub);
51 // TODO(verwaest): Move all uses of these helpers to the PropertyICCompiler
52 // and make the helpers private.
53 static void GenerateRuntimeSetProperty(MacroAssembler* masm,
54 LanguageMode language_mode);
58 PropertyICCompiler(Isolate* isolate, Code::Kind kind,
59 ExtraICState extra_ic_state = kNoExtraICState,
60 CacheHolderFlag cache_holder = kCacheOnReceiver)
61 : PropertyAccessCompiler(isolate, kind, cache_holder),
62 extra_ic_state_(extra_ic_state) {}
64 static Handle<Code> Find(Handle<Name> name, Handle<Map> stub_holder_map,
66 ExtraICState extra_ic_state = kNoExtraICState,
67 CacheHolderFlag cache_holder = kCacheOnReceiver);
69 Handle<Code> CompileLoadInitialize(Code::Flags flags);
70 Handle<Code> CompileStoreInitialize(Code::Flags flags);
71 Handle<Code> CompileStorePreMonomorphic(Code::Flags flags);
72 Handle<Code> CompileStoreGeneric(Code::Flags flags);
73 Handle<Code> CompileStoreMegamorphic(Code::Flags flags);
75 Handle<Code> CompileMonomorphic(Handle<Map> map, Handle<Code> handler,
76 Handle<Name> name, IcCheckType check);
77 Handle<Code> CompilePolymorphic(MapHandleList* maps, CodeHandleList* handlers,
78 Handle<Name> name, Code::StubType type,
81 Handle<Code> CompileKeyedStoreMonomorphic(Handle<Map> receiver_map,
82 KeyedAccessStoreMode store_mode);
83 Handle<Code> CompileKeyedStorePolymorphic(MapHandleList* receiver_maps,
84 KeyedAccessStoreMode store_mode);
85 Handle<Code> CompileKeyedStorePolymorphic(MapHandleList* receiver_maps,
86 CodeHandleList* handler_stubs,
87 MapHandleList* transitioned_maps);
89 bool IncludesNumberMap(MapHandleList* maps);
91 Handle<Code> GetCode(Code::Kind kind, Code::StubType type, Handle<Name> name,
92 InlineCacheState state = MONOMORPHIC);
94 Logger::LogEventsAndTags log_kind(Handle<Code> code) {
95 if (kind() == Code::LOAD_IC) {
96 return code->ic_state() == MONOMORPHIC ? Logger::LOAD_IC_TAG
97 : Logger::LOAD_POLYMORPHIC_IC_TAG;
98 } else if (kind() == Code::KEYED_LOAD_IC) {
99 return code->ic_state() == MONOMORPHIC
100 ? Logger::KEYED_LOAD_IC_TAG
101 : Logger::KEYED_LOAD_POLYMORPHIC_IC_TAG;
102 } else if (kind() == Code::STORE_IC) {
103 return code->ic_state() == MONOMORPHIC ? Logger::STORE_IC_TAG
104 : Logger::STORE_POLYMORPHIC_IC_TAG;
106 DCHECK_EQ(Code::KEYED_STORE_IC, kind());
107 return code->ic_state() == MONOMORPHIC
108 ? Logger::KEYED_STORE_IC_TAG
109 : Logger::KEYED_STORE_POLYMORPHIC_IC_TAG;
113 const ExtraICState extra_ic_state_;
118 } // namespace v8::internal
120 #endif // V8_IC_IC_COMPILER_H_