summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/jit/JITThunks.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/jit/JITThunks.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/JavaScriptCore/jit/JITThunks.h')
-rw-r--r--Source/JavaScriptCore/jit/JITThunks.h72
1 files changed, 51 insertions, 21 deletions
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 <wtf/Platform.h>
+#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 <tuple>
#include <wtf/HashMap.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/RefPtr.h>
#include <wtf/ThreadingPrimitives.h>
+#include <wtf/text/StringHash.h>
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<Unknown>, void* context) override;
typedef HashMap<ThunkGenerator, MacroAssemblerCodeRef> CTIStubMap;
CTIStubMap m_ctiStubMap;
- typedef HashMap<std::pair<NativeFunction, NativeFunction>, Weak<NativeExecutable>> HostFunctionStubMap;
- OwnPtr<HostFunctionStubMap> m_hostFunctionStubMap;
+
+ typedef std::tuple<NativeFunction, NativeFunction, String> 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<String>::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<NativeFunction>::Hash::hash(p);
+ }
+ };
+
+ struct HostFunctionHashTrait : WTF::GenericHashTraits<HostFunctionKey> {
+ 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<NativeFunction>(-1); }
+ static bool isDeletedValue(const HostFunctionKey& value) { return std::get<0>(value) == reinterpret_cast<NativeFunction>(-1); }
+ };
+
+ typedef HashMap<HostFunctionKey, Weak<NativeExecutable>, HostFunctionHash, HostFunctionHashTrait> HostFunctionStubMap;
+ std::unique_ptr<HostFunctionStubMap> m_hostFunctionStubMap;
Lock m_lock;
};
} // namespace JSC
#endif // ENABLE(JIT)
-
-#endif // JITThunks_h
-