Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 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 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 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 |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 21 | static Handle<Code> ComputeStore(Isolate* isolate, InlineCacheState ic_state, |
| 22 | ExtraICState extra_state); |
| 23 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 24 | // Keyed |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 25 | static Handle<Code> ComputeKeyedLoadMonomorphicHandler( |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 26 | Handle<Map> receiver_map, ExtraICState extra_ic_state); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 27 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 28 | static Handle<Code> ComputeKeyedStoreMonomorphicHandler( |
| 29 | Handle<Map> receiver_map, LanguageMode language_mode, |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 30 | KeyedAccessStoreMode store_mode); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 31 | static void ComputeKeyedStorePolymorphicHandlers( |
| 32 | MapHandleList* receiver_maps, MapHandleList* transitioned_maps, |
| 33 | CodeHandleList* handlers, KeyedAccessStoreMode store_mode, |
| 34 | LanguageMode language_mode); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 35 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 36 | // Helpers |
| 37 | // TODO(verwaest): Move all uses of these helpers to the PropertyICCompiler |
| 38 | // and make the helpers private. |
| 39 | static void GenerateRuntimeSetProperty(MacroAssembler* masm, |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 40 | LanguageMode language_mode); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 41 | |
| 42 | |
| 43 | private: |
| 44 | PropertyICCompiler(Isolate* isolate, Code::Kind kind, |
| 45 | ExtraICState extra_ic_state = kNoExtraICState, |
| 46 | CacheHolderFlag cache_holder = kCacheOnReceiver) |
| 47 | : PropertyAccessCompiler(isolate, kind, cache_holder), |
| 48 | extra_ic_state_(extra_ic_state) {} |
| 49 | |
| 50 | static Handle<Code> Find(Handle<Name> name, Handle<Map> stub_holder_map, |
| 51 | Code::Kind kind, |
| 52 | ExtraICState extra_ic_state = kNoExtraICState, |
| 53 | CacheHolderFlag cache_holder = kCacheOnReceiver); |
| 54 | |
| 55 | Handle<Code> CompileLoadInitialize(Code::Flags flags); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 56 | Handle<Code> CompileStoreInitialize(Code::Flags flags); |
| 57 | Handle<Code> CompileStorePreMonomorphic(Code::Flags flags); |
| 58 | Handle<Code> CompileStoreGeneric(Code::Flags flags); |
| 59 | Handle<Code> CompileStoreMegamorphic(Code::Flags flags); |
| 60 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 61 | Handle<Code> CompileKeyedStoreMonomorphicHandler( |
| 62 | Handle<Map> receiver_map, KeyedAccessStoreMode store_mode); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 63 | Handle<Code> CompileKeyedStoreMonomorphic(Handle<Map> receiver_map, |
| 64 | KeyedAccessStoreMode store_mode); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 65 | void CompileKeyedStorePolymorphicHandlers(MapHandleList* receiver_maps, |
| 66 | MapHandleList* transitioned_maps, |
| 67 | CodeHandleList* handlers, |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 68 | KeyedAccessStoreMode store_mode); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 69 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 70 | bool IncludesNumberMap(MapHandleList* maps); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 71 | |
| 72 | Handle<Code> GetCode(Code::Kind kind, Code::StubType type, Handle<Name> name, |
| 73 | InlineCacheState state = MONOMORPHIC); |
| 74 | |
| 75 | Logger::LogEventsAndTags log_kind(Handle<Code> code) { |
| 76 | if (kind() == Code::LOAD_IC) { |
| 77 | return code->ic_state() == MONOMORPHIC ? Logger::LOAD_IC_TAG |
| 78 | : Logger::LOAD_POLYMORPHIC_IC_TAG; |
| 79 | } else if (kind() == Code::KEYED_LOAD_IC) { |
| 80 | return code->ic_state() == MONOMORPHIC |
| 81 | ? Logger::KEYED_LOAD_IC_TAG |
| 82 | : Logger::KEYED_LOAD_POLYMORPHIC_IC_TAG; |
| 83 | } else if (kind() == Code::STORE_IC) { |
| 84 | return code->ic_state() == MONOMORPHIC ? Logger::STORE_IC_TAG |
| 85 | : Logger::STORE_POLYMORPHIC_IC_TAG; |
| 86 | } else { |
| 87 | DCHECK_EQ(Code::KEYED_STORE_IC, kind()); |
| 88 | return code->ic_state() == MONOMORPHIC |
| 89 | ? Logger::KEYED_STORE_IC_TAG |
| 90 | : Logger::KEYED_STORE_POLYMORPHIC_IC_TAG; |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | const ExtraICState extra_ic_state_; |
| 95 | }; |
| 96 | |
| 97 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 98 | } // namespace internal |
| 99 | } // namespace v8 |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 100 | |
| 101 | #endif // V8_IC_IC_COMPILER_H_ |