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> ComputeLoad(Isolate* isolate, InlineCacheState ic_state,
22 ExtraICState extra_state);
23 static Handle<Code> ComputeStore(Isolate* isolate, InlineCacheState ic_state,
24 ExtraICState extra_state);
26 static Handle<Code> ComputeMonomorphic(Code::Kind kind, Handle<Name> name,
27 Handle<HeapType> type,
29 ExtraICState extra_ic_state);
30 static Handle<Code> ComputePolymorphic(Code::Kind kind, TypeHandleList* types,
31 CodeHandleList* handlers,
32 int number_of_valid_maps,
34 ExtraICState extra_ic_state);
37 static Handle<Code> ComputeKeyedLoadMonomorphicHandler(
38 Handle<Map> receiver_map);
39 static Handle<Code> ComputeKeyedLoadMonomorphic(Handle<Map> receiver_map);
41 static Handle<Code> ComputeKeyedStoreMonomorphic(
42 Handle<Map> receiver_map, StrictMode strict_mode,
43 KeyedAccessStoreMode store_mode);
44 static Handle<Code> ComputeKeyedLoadPolymorphic(MapHandleList* receiver_maps);
45 static Handle<Code> ComputeKeyedStorePolymorphic(
46 MapHandleList* receiver_maps, KeyedAccessStoreMode store_mode,
47 StrictMode strict_mode);
50 static Handle<Code> ComputeCompareNil(Handle<Map> receiver_map,
51 CompareNilICStub* stub);
54 // TODO(verwaest): Move all uses of these helpers to the PropertyICCompiler
55 // and make the helpers private.
56 static void GenerateRuntimeSetProperty(MacroAssembler* masm,
57 StrictMode strict_mode);
61 PropertyICCompiler(Isolate* isolate, Code::Kind kind,
62 ExtraICState extra_ic_state = kNoExtraICState,
63 CacheHolderFlag cache_holder = kCacheOnReceiver)
64 : PropertyAccessCompiler(isolate, kind, cache_holder),
65 extra_ic_state_(extra_ic_state) {}
67 static Handle<Code> Find(Handle<Name> name, Handle<Map> stub_holder_map,
69 ExtraICState extra_ic_state = kNoExtraICState,
70 CacheHolderFlag cache_holder = kCacheOnReceiver);
72 Handle<Code> CompileLoadInitialize(Code::Flags flags);
73 Handle<Code> CompileLoadPreMonomorphic(Code::Flags flags);
74 Handle<Code> CompileStoreInitialize(Code::Flags flags);
75 Handle<Code> CompileStorePreMonomorphic(Code::Flags flags);
76 Handle<Code> CompileStoreGeneric(Code::Flags flags);
77 Handle<Code> CompileStoreMegamorphic(Code::Flags flags);
79 Handle<Code> CompileMonomorphic(Handle<HeapType> type, Handle<Code> handler,
80 Handle<Name> name, IcCheckType check);
81 Handle<Code> CompilePolymorphic(TypeHandleList* types,
82 CodeHandleList* handlers, Handle<Name> name,
83 Code::StubType type, IcCheckType check);
85 Handle<Code> CompileKeyedStoreMonomorphic(Handle<Map> receiver_map,
86 KeyedAccessStoreMode store_mode);
87 Handle<Code> CompileKeyedStorePolymorphic(MapHandleList* receiver_maps,
88 KeyedAccessStoreMode store_mode);
89 Handle<Code> CompileKeyedStorePolymorphic(MapHandleList* receiver_maps,
90 CodeHandleList* handler_stubs,
91 MapHandleList* transitioned_maps);
93 bool IncludesNumberType(TypeHandleList* types);
95 Handle<Code> GetCode(Code::Kind kind, Code::StubType type, Handle<Name> name,
96 InlineCacheState state = MONOMORPHIC);
98 Logger::LogEventsAndTags log_kind(Handle<Code> code) {
99 if (kind() == Code::LOAD_IC) {
100 return code->ic_state() == MONOMORPHIC ? Logger::LOAD_IC_TAG
101 : Logger::LOAD_POLYMORPHIC_IC_TAG;
102 } else if (kind() == Code::KEYED_LOAD_IC) {
103 return code->ic_state() == MONOMORPHIC
104 ? Logger::KEYED_LOAD_IC_TAG
105 : Logger::KEYED_LOAD_POLYMORPHIC_IC_TAG;
106 } else if (kind() == Code::STORE_IC) {
107 return code->ic_state() == MONOMORPHIC ? Logger::STORE_IC_TAG
108 : Logger::STORE_POLYMORPHIC_IC_TAG;
110 DCHECK_EQ(Code::KEYED_STORE_IC, kind());
111 return code->ic_state() == MONOMORPHIC
112 ? Logger::KEYED_STORE_IC_TAG
113 : Logger::KEYED_STORE_POLYMORPHIC_IC_TAG;
117 const ExtraICState extra_ic_state_;
122 } // namespace v8::internal
124 #endif // V8_IC_IC_COMPILER_H_