Revert relanded strong property access CL
[platform/upstream/v8.git] / src / ic / ic-compiler.h
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.
4
5 #ifndef V8_IC_IC_COMPILER_H_
6 #define V8_IC_IC_COMPILER_H_
7
8 #include "src/ic/access-compiler.h"
9
10 namespace v8 {
11 namespace internal {
12
13
14 class PropertyICCompiler : public PropertyAccessCompiler {
15  public:
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);
19
20   // Named
21   static Handle<Code> ComputeStore(Isolate* isolate, InlineCacheState ic_state,
22                                    ExtraICState extra_state);
23
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,
30                                          Handle<Name> name,
31                                          ExtraICState extra_ic_state);
32
33   // Keyed
34   static Handle<Code> ComputeKeyedLoadMonomorphicHandler(
35       Handle<Map> receiver_map);
36
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);
44
45   // Compare nil
46   static Handle<Code> ComputeCompareNil(Handle<Map> receiver_map,
47                                         CompareNilICStub* stub);
48
49   // Helpers
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);
54
55
56  private:
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) {}
62
63   static Handle<Code> Find(Handle<Name> name, Handle<Map> stub_holder_map,
64                            Code::Kind kind,
65                            ExtraICState extra_ic_state = kNoExtraICState,
66                            CacheHolderFlag cache_holder = kCacheOnReceiver);
67
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);
73
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,
78                                   IcCheckType check);
79
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);
87
88   bool IncludesNumberMap(MapHandleList* maps);
89
90   Handle<Code> GetCode(Code::Kind kind, Code::StubType type, Handle<Name> name,
91                        InlineCacheState state = MONOMORPHIC);
92
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;
104     } else {
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;
109     }
110   }
111
112   const ExtraICState extra_ic_state_;
113 };
114
115
116 }
117 }  // namespace v8::internal
118
119 #endif  // V8_IC_IC_COMPILER_H_