From 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 27 Jun 2017 06:07:23 +0000 Subject: webkitgtk-2.16.5 --- Source/JavaScriptCore/jit/JITThunks.h | 72 +++++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 21 deletions(-) (limited to 'Source/JavaScriptCore/jit/JITThunks.h') diff --git a/Source/JavaScriptCore/jit/JITThunks.h b/Source/JavaScriptCore/jit/JITThunks.h index 97e7ecd6b..addcf230c 100644 --- a/Source/JavaScriptCore/jit/JITThunks.h +++ b/Source/JavaScriptCore/jit/JITThunks.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012, 2013 Apple Inc. All rights reserved. + * Copyright (C) 2012, 2013, 2016 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,60 +23,90 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef JITThunks_h -#define JITThunks_h - -#include +#pragma once #if ENABLE(JIT) #include "CallData.h" #include "Intrinsic.h" -#include "LowLevelInterpreter.h" #include "MacroAssemblerCodeRef.h" #include "ThunkGenerator.h" #include "Weak.h" -#include "WeakInlines.h" +#include "WeakHandleOwner.h" +#include #include -#include -#include #include +#include namespace JSC { +namespace DOMJIT { +class Signature; +} class VM; class NativeExecutable; -class JITThunks { +class JITThunks final : private WeakHandleOwner { + WTF_MAKE_FAST_ALLOCATED; public: JITThunks(); - ~JITThunks(); + virtual ~JITThunks(); MacroAssemblerCodePtr ctiNativeCall(VM*); MacroAssemblerCodePtr ctiNativeConstruct(VM*); + MacroAssemblerCodePtr ctiNativeTailCall(VM*); + MacroAssemblerCodePtr ctiNativeTailCallWithoutSavedTags(VM*); MacroAssemblerCodeRef ctiStub(VM*, ThunkGenerator); - NativeExecutable* hostFunctionStub(VM*, NativeFunction, NativeFunction constructor); - NativeExecutable* hostFunctionStub(VM*, NativeFunction, ThunkGenerator, Intrinsic); + NativeExecutable* hostFunctionStub(VM*, NativeFunction, NativeFunction constructor, const String& name); + NativeExecutable* hostFunctionStub(VM*, NativeFunction, NativeFunction constructor, ThunkGenerator, Intrinsic, const DOMJIT::Signature*, const String& name); + NativeExecutable* hostFunctionStub(VM*, NativeFunction, ThunkGenerator, Intrinsic, const String& name); void clearHostFunctionStubs(); private: - // Main thread can hold this lock for a while, so use an adaptive mutex. - typedef Mutex Lock; - typedef MutexLocker Locker; + void finalize(Handle, void* context) override; typedef HashMap CTIStubMap; CTIStubMap m_ctiStubMap; - typedef HashMap, Weak> HostFunctionStubMap; - OwnPtr m_hostFunctionStubMap; + + typedef std::tuple HostFunctionKey; + + struct HostFunctionHash { + static unsigned hash(const HostFunctionKey& key) + { + unsigned hash = WTF::pairIntHash(hashPointer(std::get<0>(key)), hashPointer(std::get<1>(key))); + if (!std::get<2>(key).isNull()) + hash = WTF::pairIntHash(hash, DefaultHash::Hash::hash(std::get<2>(key))); + return hash; + } + static bool equal(const HostFunctionKey& a, const HostFunctionKey& b) + { + return (std::get<0>(a) == std::get<0>(b)) && (std::get<1>(a) == std::get<1>(b)) && (std::get<2>(a) == std::get<2>(b)); + } + static const bool safeToCompareToEmptyOrDeleted = true; + + private: + static inline unsigned hashPointer(NativeFunction p) + { + return DefaultHash::Hash::hash(p); + } + }; + + struct HostFunctionHashTrait : WTF::GenericHashTraits { + static const bool emptyValueIsZero = true; + static EmptyValueType emptyValue() { return std::make_tuple(nullptr, nullptr, String()); } + + static void constructDeletedValue(HostFunctionKey& slot) { std::get<0>(slot) = reinterpret_cast(-1); } + static bool isDeletedValue(const HostFunctionKey& value) { return std::get<0>(value) == reinterpret_cast(-1); } + }; + + typedef HashMap, HostFunctionHash, HostFunctionHashTrait> HostFunctionStubMap; + std::unique_ptr m_hostFunctionStubMap; Lock m_lock; }; } // namespace JSC #endif // ENABLE(JIT) - -#endif // JITThunks_h - -- cgit v1.2.1