diff options
Diffstat (limited to 'deps/v8/src/ic/ic-compiler.cc')
-rw-r--r-- | deps/v8/src/ic/ic-compiler.cc | 199 |
1 files changed, 7 insertions, 192 deletions
diff --git a/deps/v8/src/ic/ic-compiler.cc b/deps/v8/src/ic/ic-compiler.cc index d1e9416d41..2f0633e0d8 100644 --- a/deps/v8/src/ic/ic-compiler.cc +++ b/deps/v8/src/ic/ic-compiler.cc @@ -6,211 +6,39 @@ #include "src/ic/handler-compiler.h" #include "src/ic/ic-inl.h" -#include "src/profiler/cpu-profiler.h" - namespace v8 { namespace internal { - -Handle<Code> PropertyICCompiler::Find(Handle<Name> name, - Handle<Map> stub_holder, Code::Kind kind, - ExtraICState extra_state, - CacheHolderFlag cache_holder) { - Code::Flags flags = - Code::ComputeMonomorphicFlags(kind, extra_state, cache_holder); - Object* probe = stub_holder->FindInCodeCache(*name, flags); - if (probe->IsCode()) return handle(Code::cast(probe)); - return Handle<Code>::null(); -} - - -bool PropertyICCompiler::IncludesNumberMap(MapHandleList* maps) { - for (int i = 0; i < maps->length(); ++i) { - if (maps->at(i)->instance_type() == HEAP_NUMBER_TYPE) return true; - } - return false; -} - - -Handle<Code> PropertyICCompiler::ComputeKeyedLoadMonomorphicHandler( - Handle<Map> receiver_map, ExtraICState extra_ic_state) { - Isolate* isolate = receiver_map->GetIsolate(); - bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE; - ElementsKind elements_kind = receiver_map->elements_kind(); - - // No need to check for an elements-free prototype chain here, the generated - // stub code needs to check that dynamically anyway. - bool convert_hole_to_undefined = - is_js_array && elements_kind == FAST_HOLEY_ELEMENTS && - *receiver_map == isolate->get_initial_js_array_map(elements_kind); - Handle<Code> stub; - if (receiver_map->has_indexed_interceptor()) { - stub = LoadIndexedInterceptorStub(isolate).GetCode(); - } else if (receiver_map->IsStringMap()) { - stub = LoadIndexedStringStub(isolate).GetCode(); - } else if (receiver_map->has_sloppy_arguments_elements()) { - stub = KeyedLoadSloppyArgumentsStub(isolate).GetCode(); - } else if (receiver_map->has_fast_elements() || - receiver_map->has_fixed_typed_array_elements()) { - stub = LoadFastElementStub(isolate, is_js_array, elements_kind, - convert_hole_to_undefined).GetCode(); - } else { - DCHECK(receiver_map->has_dictionary_elements()); - stub = LoadDictionaryElementStub(isolate, LoadICState(extra_ic_state)) - .GetCode(); - } - return stub; -} - - Handle<Code> PropertyICCompiler::ComputeKeyedStoreMonomorphicHandler( - Handle<Map> receiver_map, LanguageMode language_mode, - KeyedAccessStoreMode store_mode) { + Handle<Map> receiver_map, KeyedAccessStoreMode store_mode) { Isolate* isolate = receiver_map->GetIsolate(); - ExtraICState extra_state = - KeyedStoreIC::ComputeExtraICState(language_mode, store_mode); DCHECK(store_mode == STANDARD_STORE || store_mode == STORE_AND_GROW_NO_TRANSITION || store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || store_mode == STORE_NO_TRANSITION_HANDLE_COW); - PropertyICCompiler compiler(isolate, Code::KEYED_STORE_IC, extra_state); + PropertyICCompiler compiler(isolate); Handle<Code> code = compiler.CompileKeyedStoreMonomorphicHandler(receiver_map, store_mode); return code; } - -Code* PropertyICCompiler::FindPreMonomorphic(Isolate* isolate, Code::Kind kind, - ExtraICState state) { - Code::Flags flags = Code::ComputeFlags(kind, PREMONOMORPHIC, state); - UnseededNumberDictionary* dictionary = - isolate->heap()->non_monomorphic_cache(); - int entry = dictionary->FindEntry(isolate, flags); - DCHECK(entry != -1); - Object* code = dictionary->ValueAt(entry); - // This might be called during the marking phase of the collector - // hence the unchecked cast. - return reinterpret_cast<Code*>(code); -} - - -static void FillCache(Isolate* isolate, Handle<Code> code) { - Handle<UnseededNumberDictionary> dictionary = UnseededNumberDictionary::Set( - isolate->factory()->non_monomorphic_cache(), code->flags(), code); - isolate->heap()->SetRootNonMonomorphicCache(*dictionary); -} - - -Handle<Code> PropertyICCompiler::ComputeStore(Isolate* isolate, - InlineCacheState ic_state, - ExtraICState extra_state) { - Code::Flags flags = Code::ComputeFlags(Code::STORE_IC, ic_state, extra_state); - Handle<UnseededNumberDictionary> cache = - isolate->factory()->non_monomorphic_cache(); - int entry = cache->FindEntry(isolate, flags); - if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); - - PropertyICCompiler compiler(isolate, Code::STORE_IC); - Handle<Code> code; - if (ic_state == UNINITIALIZED) { - code = compiler.CompileStoreInitialize(flags); - } else if (ic_state == PREMONOMORPHIC) { - code = compiler.CompileStorePreMonomorphic(flags); - } else if (ic_state == GENERIC) { - code = compiler.CompileStoreGeneric(flags); - } else if (ic_state == MEGAMORPHIC) { - code = compiler.CompileStoreMegamorphic(flags); - } else { - UNREACHABLE(); - } - - FillCache(isolate, code); - return code; -} - - void PropertyICCompiler::ComputeKeyedStorePolymorphicHandlers( MapHandleList* receiver_maps, MapHandleList* transitioned_maps, - CodeHandleList* handlers, KeyedAccessStoreMode store_mode, - LanguageMode language_mode) { + CodeHandleList* handlers, KeyedAccessStoreMode store_mode) { Isolate* isolate = receiver_maps->at(0)->GetIsolate(); DCHECK(store_mode == STANDARD_STORE || store_mode == STORE_AND_GROW_NO_TRANSITION || store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || store_mode == STORE_NO_TRANSITION_HANDLE_COW); - ExtraICState extra_state = - KeyedStoreIC::ComputeExtraICState(language_mode, store_mode); - PropertyICCompiler compiler(isolate, Code::KEYED_STORE_IC, extra_state); + PropertyICCompiler compiler(isolate); compiler.CompileKeyedStorePolymorphicHandlers( receiver_maps, transitioned_maps, handlers, store_mode); } -Handle<Code> PropertyICCompiler::CompileLoadInitialize(Code::Flags flags) { - LoadIC::GenerateInitialize(masm()); - Handle<Code> code = GetCodeWithFlags(flags, "CompileLoadInitialize"); - PROFILE(isolate(), CodeCreateEvent(Logger::LOAD_INITIALIZE_TAG, - AbstractCode::cast(*code), 0)); - return code; -} - - -Handle<Code> PropertyICCompiler::CompileStoreInitialize(Code::Flags flags) { - StoreIC::GenerateInitialize(masm()); - Handle<Code> code = GetCodeWithFlags(flags, "CompileStoreInitialize"); - PROFILE(isolate(), CodeCreateEvent(Logger::STORE_INITIALIZE_TAG, - AbstractCode::cast(*code), 0)); - return code; -} - - -Handle<Code> PropertyICCompiler::CompileStorePreMonomorphic(Code::Flags flags) { - StoreIC::GeneratePreMonomorphic(masm()); - Handle<Code> code = GetCodeWithFlags(flags, "CompileStorePreMonomorphic"); - PROFILE(isolate(), CodeCreateEvent(Logger::STORE_PREMONOMORPHIC_TAG, - AbstractCode::cast(*code), 0)); - return code; -} - - -Handle<Code> PropertyICCompiler::CompileStoreGeneric(Code::Flags flags) { - ExtraICState extra_state = Code::ExtractExtraICStateFromFlags(flags); - LanguageMode language_mode = StoreICState::GetLanguageMode(extra_state); - GenerateRuntimeSetProperty(masm(), language_mode); - Handle<Code> code = GetCodeWithFlags(flags, "CompileStoreGeneric"); - PROFILE(isolate(), CodeCreateEvent(Logger::STORE_GENERIC_TAG, - AbstractCode::cast(*code), 0)); - return code; -} - - -Handle<Code> PropertyICCompiler::CompileStoreMegamorphic(Code::Flags flags) { - StoreIC::GenerateMegamorphic(masm()); - Handle<Code> code = GetCodeWithFlags(flags, "CompileStoreMegamorphic"); - PROFILE(isolate(), CodeCreateEvent(Logger::STORE_MEGAMORPHIC_TAG, - AbstractCode::cast(*code), 0)); - return code; -} - - -Handle<Code> PropertyICCompiler::GetCode(Code::Kind kind, Code::StubType type, - Handle<Name> name, - InlineCacheState state) { - Code::Flags flags = - Code::ComputeFlags(kind, state, extra_ic_state_, type, cache_holder()); - Handle<Code> code = GetCodeWithFlags(flags, name); - PROFILE(isolate(), - CodeCreateEvent(log_kind(code), AbstractCode::cast(*code), *name)); -#ifdef DEBUG - code->VerifyEmbeddedObjects(); -#endif - return code; -} - - void PropertyICCompiler::CompileKeyedStorePolymorphicHandlers( MapHandleList* receiver_maps, MapHandleList* transitioned_maps, CodeHandleList* handlers, KeyedAccessStoreMode store_mode) { @@ -268,34 +96,21 @@ Handle<Code> PropertyICCompiler::CompileKeyedStoreMonomorphicHandler( bool is_jsarray = receiver_map->instance_type() == JS_ARRAY_TYPE; Handle<Code> stub; if (receiver_map->has_sloppy_arguments_elements()) { + TRACE_HANDLER_STATS(isolate(), KeyedStoreIC_KeyedStoreSloppyArgumentsStub); stub = KeyedStoreSloppyArgumentsStub(isolate(), store_mode).GetCode(); } else if (receiver_map->has_fast_elements() || receiver_map->has_fixed_typed_array_elements()) { + TRACE_HANDLER_STATS(isolate(), KeyedStoreIC_StoreFastElementStub); stub = StoreFastElementStub(isolate(), is_jsarray, elements_kind, store_mode).GetCode(); } else { + TRACE_HANDLER_STATS(isolate(), KeyedStoreIC_StoreElementStub); stub = StoreElementStub(isolate(), elements_kind, store_mode).GetCode(); } return stub; } -Handle<Code> PropertyICCompiler::CompileKeyedStoreMonomorphic( - Handle<Map> receiver_map, KeyedAccessStoreMode store_mode) { - Handle<Code> stub = - CompileKeyedStoreMonomorphicHandler(receiver_map, store_mode); - - Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map); - - __ DispatchWeakMap(receiver(), scratch1(), scratch2(), cell, stub, - DO_SMI_CHECK); - - TailCallBuiltin(masm(), Builtins::kKeyedStoreIC_Miss); - - return GetCode(kind(), Code::NORMAL, factory()->empty_string()); -} - - #undef __ } // namespace internal } // namespace v8 |