summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/runtime/NativeExecutable.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/JavaScriptCore/runtime/NativeExecutable.h')
-rw-r--r--Source/JavaScriptCore/runtime/NativeExecutable.h96
1 files changed, 96 insertions, 0 deletions
diff --git a/Source/JavaScriptCore/runtime/NativeExecutable.h b/Source/JavaScriptCore/runtime/NativeExecutable.h
new file mode 100644
index 000000000..aa56cf4dc
--- /dev/null
+++ b/Source/JavaScriptCore/runtime/NativeExecutable.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2009, 2010, 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "ExecutableBase.h"
+
+namespace JSC {
+namespace DOMJIT {
+class Signature;
+}
+
+class NativeExecutable final : public ExecutableBase {
+ friend class JIT;
+ friend class LLIntOffsetsExtractor;
+public:
+ typedef ExecutableBase Base;
+ static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
+
+ static NativeExecutable* create(VM&, Ref<JITCode>&& callThunk, NativeFunction function, Ref<JITCode>&& constructThunk, NativeFunction constructor, Intrinsic, const DOMJIT::Signature*, const String& name);
+
+ static void destroy(JSCell*);
+
+ CodeBlockHash hashFor(CodeSpecializationKind) const;
+
+ NativeFunction function() { return m_function; }
+ NativeFunction constructor() { return m_constructor; }
+
+ NativeFunction nativeFunctionFor(CodeSpecializationKind kind)
+ {
+ if (kind == CodeForCall)
+ return function();
+ ASSERT(kind == CodeForConstruct);
+ return constructor();
+ }
+
+ static ptrdiff_t offsetOfNativeFunctionFor(CodeSpecializationKind kind)
+ {
+ if (kind == CodeForCall)
+ return OBJECT_OFFSETOF(NativeExecutable, m_function);
+ ASSERT(kind == CodeForConstruct);
+ return OBJECT_OFFSETOF(NativeExecutable, m_constructor);
+ }
+
+ static Structure* createStructure(VM&, JSGlobalObject*, JSValue proto);
+
+ DECLARE_INFO;
+
+ const String& name() const { return m_name; }
+ const DOMJIT::Signature* signature() const { return m_signature; }
+
+ const DOMJIT::Signature* signatureFor(CodeSpecializationKind kind) const
+ {
+ if (isCall(kind))
+ return signature();
+ return nullptr;
+ }
+
+protected:
+ void finishCreation(VM&, Ref<JITCode>&& callThunk, Ref<JITCode>&& constructThunk, const String& name);
+
+private:
+ friend class ExecutableBase;
+
+ NativeExecutable(VM&, NativeFunction function, NativeFunction constructor, Intrinsic, const DOMJIT::Signature*);
+
+ NativeFunction m_function;
+ NativeFunction m_constructor;
+ const DOMJIT::Signature* m_signature;
+
+ String m_name;
+};
+
+} // namespace JSC