| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/ic/ic-compiler.h" | 5 #include "src/ic/ic-compiler.h" |
| 6 | 6 |
| 7 #include "src/ic/handler-compiler.h" | 7 #include "src/ic/handler-compiler.h" |
| 8 #include "src/ic/ic-inl.h" | 8 #include "src/ic/ic-inl.h" |
| 9 #include "src/profiler/cpu-profiler.h" | 9 #include "src/profiler/cpu-profiler.h" |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 stub = LoadFastElementStub(isolate, is_js_array, elements_kind, | 36 stub = LoadFastElementStub(isolate, is_js_array, elements_kind, |
| 37 convert_hole_to_undefined).GetCode(); | 37 convert_hole_to_undefined).GetCode(); |
| 38 } else { | 38 } else { |
| 39 DCHECK(receiver_map->has_dictionary_elements()); | 39 DCHECK(receiver_map->has_dictionary_elements()); |
| 40 stub = LoadDictionaryElementStub(isolate, LoadICState(extra_ic_state)) | 40 stub = LoadDictionaryElementStub(isolate, LoadICState(extra_ic_state)) |
| 41 .GetCode(); | 41 .GetCode(); |
| 42 } | 42 } |
| 43 return stub; | 43 return stub; |
| 44 } | 44 } |
| 45 | 45 |
| 46 |
| 46 Handle<Code> PropertyICCompiler::ComputeKeyedStoreMonomorphicHandler( | 47 Handle<Code> PropertyICCompiler::ComputeKeyedStoreMonomorphicHandler( |
| 47 Handle<Map> receiver_map, KeyedAccessStoreMode store_mode) { | 48 Handle<Map> receiver_map, LanguageMode language_mode, |
| 49 KeyedAccessStoreMode store_mode) { |
| 48 Isolate* isolate = receiver_map->GetIsolate(); | 50 Isolate* isolate = receiver_map->GetIsolate(); |
| 51 ExtraICState extra_state = |
| 52 KeyedStoreIC::ComputeExtraICState(language_mode, store_mode); |
| 49 | 53 |
| 50 DCHECK(store_mode == STANDARD_STORE || | 54 DCHECK(store_mode == STANDARD_STORE || |
| 51 store_mode == STORE_AND_GROW_NO_TRANSITION || | 55 store_mode == STORE_AND_GROW_NO_TRANSITION || |
| 52 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || | 56 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || |
| 53 store_mode == STORE_NO_TRANSITION_HANDLE_COW); | 57 store_mode == STORE_NO_TRANSITION_HANDLE_COW); |
| 54 | 58 |
| 55 PropertyICCompiler compiler(isolate); | 59 PropertyICCompiler compiler(isolate, Code::KEYED_STORE_IC, extra_state); |
| 56 Handle<Code> code = | 60 Handle<Code> code = |
| 57 compiler.CompileKeyedStoreMonomorphicHandler(receiver_map, store_mode); | 61 compiler.CompileKeyedStoreMonomorphicHandler(receiver_map, store_mode); |
| 58 return code; | 62 return code; |
| 59 } | 63 } |
| 60 | 64 |
| 65 |
| 66 static void FillCache(Isolate* isolate, Handle<Code> code) { |
| 67 Handle<UnseededNumberDictionary> dictionary = UnseededNumberDictionary::Set( |
| 68 isolate->factory()->non_monomorphic_cache(), code->flags(), code); |
| 69 isolate->heap()->SetRootNonMonomorphicCache(*dictionary); |
| 70 } |
| 71 |
| 72 |
| 73 Handle<Code> PropertyICCompiler::ComputeStore(Isolate* isolate, |
| 74 InlineCacheState ic_state, |
| 75 ExtraICState extra_state) { |
| 76 DCHECK_EQ(MEGAMORPHIC, ic_state); |
| 77 Code::Flags flags = Code::ComputeFlags(Code::STORE_IC, ic_state, extra_state); |
| 78 Handle<UnseededNumberDictionary> cache = |
| 79 isolate->factory()->non_monomorphic_cache(); |
| 80 int entry = cache->FindEntry(isolate, flags); |
| 81 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); |
| 82 |
| 83 PropertyICCompiler compiler(isolate, Code::STORE_IC); |
| 84 Handle<Code> code = compiler.CompileStoreMegamorphic(flags); |
| 85 |
| 86 FillCache(isolate, code); |
| 87 return code; |
| 88 } |
| 89 |
| 90 |
| 61 void PropertyICCompiler::ComputeKeyedStorePolymorphicHandlers( | 91 void PropertyICCompiler::ComputeKeyedStorePolymorphicHandlers( |
| 62 MapHandleList* receiver_maps, MapHandleList* transitioned_maps, | 92 MapHandleList* receiver_maps, MapHandleList* transitioned_maps, |
| 63 CodeHandleList* handlers, KeyedAccessStoreMode store_mode) { | 93 CodeHandleList* handlers, KeyedAccessStoreMode store_mode, |
| 94 LanguageMode language_mode) { |
| 64 Isolate* isolate = receiver_maps->at(0)->GetIsolate(); | 95 Isolate* isolate = receiver_maps->at(0)->GetIsolate(); |
| 65 DCHECK(store_mode == STANDARD_STORE || | 96 DCHECK(store_mode == STANDARD_STORE || |
| 66 store_mode == STORE_AND_GROW_NO_TRANSITION || | 97 store_mode == STORE_AND_GROW_NO_TRANSITION || |
| 67 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || | 98 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || |
| 68 store_mode == STORE_NO_TRANSITION_HANDLE_COW); | 99 store_mode == STORE_NO_TRANSITION_HANDLE_COW); |
| 69 PropertyICCompiler compiler(isolate); | 100 ExtraICState extra_state = |
| 101 KeyedStoreIC::ComputeExtraICState(language_mode, store_mode); |
| 102 PropertyICCompiler compiler(isolate, Code::KEYED_STORE_IC, extra_state); |
| 70 compiler.CompileKeyedStorePolymorphicHandlers( | 103 compiler.CompileKeyedStorePolymorphicHandlers( |
| 71 receiver_maps, transitioned_maps, handlers, store_mode); | 104 receiver_maps, transitioned_maps, handlers, store_mode); |
| 72 } | 105 } |
| 73 | 106 |
| 74 | 107 |
| 108 Handle<Code> PropertyICCompiler::CompileStoreMegamorphic(Code::Flags flags) { |
| 109 StoreIC::GenerateMegamorphic(masm()); |
| 110 Handle<Code> code = GetCodeWithFlags(flags, "CompileStoreMegamorphic"); |
| 111 PROFILE(isolate(), CodeCreateEvent(Logger::STORE_MEGAMORPHIC_TAG, |
| 112 AbstractCode::cast(*code), 0)); |
| 113 return code; |
| 114 } |
| 115 |
| 116 Handle<Code> PropertyICCompiler::GetCode(Code::Kind kind, Handle<Name> name, |
| 117 InlineCacheState state) { |
| 118 Code::Flags flags = |
| 119 Code::ComputeFlags(kind, state, extra_ic_state_, cache_holder()); |
| 120 Handle<Code> code = GetCodeWithFlags(flags, name); |
| 121 PROFILE(isolate(), |
| 122 CodeCreateEvent(log_kind(code), AbstractCode::cast(*code), *name)); |
| 123 #ifdef DEBUG |
| 124 code->VerifyEmbeddedObjects(); |
| 125 #endif |
| 126 return code; |
| 127 } |
| 128 |
| 129 |
| 75 void PropertyICCompiler::CompileKeyedStorePolymorphicHandlers( | 130 void PropertyICCompiler::CompileKeyedStorePolymorphicHandlers( |
| 76 MapHandleList* receiver_maps, MapHandleList* transitioned_maps, | 131 MapHandleList* receiver_maps, MapHandleList* transitioned_maps, |
| 77 CodeHandleList* handlers, KeyedAccessStoreMode store_mode) { | 132 CodeHandleList* handlers, KeyedAccessStoreMode store_mode) { |
| 78 for (int i = 0; i < receiver_maps->length(); ++i) { | 133 for (int i = 0; i < receiver_maps->length(); ++i) { |
| 79 Handle<Map> receiver_map(receiver_maps->at(i)); | 134 Handle<Map> receiver_map(receiver_maps->at(i)); |
| 80 Handle<Code> cached_stub; | 135 Handle<Code> cached_stub; |
| 81 Handle<Map> transitioned_map = | 136 Handle<Map> transitioned_map = |
| 82 Map::FindTransitionedMap(receiver_map, receiver_maps); | 137 Map::FindTransitionedMap(receiver_map, receiver_maps); |
| 83 | 138 |
| 84 // TODO(mvstanton): The code below is doing pessimistic elements | 139 // TODO(mvstanton): The code below is doing pessimistic elements |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } else { | 189 } else { |
| 135 stub = StoreElementStub(isolate(), elements_kind, store_mode).GetCode(); | 190 stub = StoreElementStub(isolate(), elements_kind, store_mode).GetCode(); |
| 136 } | 191 } |
| 137 return stub; | 192 return stub; |
| 138 } | 193 } |
| 139 | 194 |
| 140 | 195 |
| 141 #undef __ | 196 #undef __ |
| 142 } // namespace internal | 197 } // namespace internal |
| 143 } // namespace v8 | 198 } // namespace v8 |
| OLD | NEW |