diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/assembler/MacroAssemblerCodeRef.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/JavaScriptCore/assembler/MacroAssemblerCodeRef.h')
-rw-r--r-- | Source/JavaScriptCore/assembler/MacroAssemblerCodeRef.h | 107 |
1 files changed, 32 insertions, 75 deletions
diff --git a/Source/JavaScriptCore/assembler/MacroAssemblerCodeRef.h b/Source/JavaScriptCore/assembler/MacroAssemblerCodeRef.h index 5f8ba8a92..c31cf8526 100644 --- a/Source/JavaScriptCore/assembler/MacroAssemblerCodeRef.h +++ b/Source/JavaScriptCore/assembler/MacroAssemblerCodeRef.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009, 2012 Apple Inc. All rights reserved. + * Copyright (C) 2009, 2012, 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,20 +23,17 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef MacroAssemblerCodeRef_h -#define MacroAssemblerCodeRef_h +#pragma once -#include "Disassembler.h" #include "ExecutableAllocator.h" -#include "LLIntData.h" #include <wtf/DataLog.h> -#include <wtf/PassRefPtr.h> #include <wtf/PrintStream.h> #include <wtf/RefPtr.h> +#include <wtf/text/CString.h> // ASSERT_VALID_CODE_POINTER checks that ptr is a non-null pointer, and that it is a valid // instruction address on the platform (for example, check any alignment requirements). -#if CPU(ARM_THUMB2) && !ENABLE(LLINT_C_LOOP) +#if CPU(ARM_THUMB2) && ENABLE(JIT) // ARM instructions must be 16-bit aligned. Thumb2 code pointers to be loaded into // into the processor are decorated with the bottom bit set, while traditional ARM has // the lower bit clear. Since we don't know what kind of pointer, we check for both @@ -51,34 +48,10 @@ #define ASSERT_VALID_CODE_OFFSET(offset) // Anything goes! #endif -#if CPU(X86) && OS(WINDOWS) -#define CALLING_CONVENTION_IS_STDCALL 1 -#ifndef CDECL -#if COMPILER(MSVC) -#define CDECL __cdecl -#else -#define CDECL __attribute__ ((__cdecl)) -#endif // COMPILER(MSVC) -#endif // CDECL -#else -#define CALLING_CONVENTION_IS_STDCALL 0 -#endif - -#if CPU(X86) -#define HAS_FASTCALL_CALLING_CONVENTION 1 -#ifndef FASTCALL -#if COMPILER(MSVC) -#define FASTCALL __fastcall -#else -#define FASTCALL __attribute__ ((fastcall)) -#endif // COMPILER(MSVC) -#endif // FASTCALL -#else -#define HAS_FASTCALL_CALLING_CONVENTION 0 -#endif // CPU(X86) - namespace JSC { +enum OpcodeID : unsigned; + // FunctionPtr: // // FunctionPtr should be used to wrap pointers to C/C++ functions in JSC @@ -132,6 +105,12 @@ public: ASSERT_VALID_CODE_POINTER(m_value); } + template<typename returnType, typename argType1, typename argType2, typename argType3, typename argType4, typename argType5, typename argType6> + FunctionPtr(returnType(*value)(argType1, argType2, argType3, argType4, argType5, argType6)) + : m_value((void*)value) + { + ASSERT_VALID_CODE_POINTER(m_value); + } // MSVC doesn't seem to treat functions with different calling conventions as // different types; these methods already defined for fastcall, below. #if CALLING_CONVENTION_IS_STDCALL && !OS(WINDOWS) @@ -172,7 +151,7 @@ public: } #endif -#if HAS_FASTCALL_CALLING_CONVENTION +#if COMPILER_SUPPORTS(FASTCALL_CALLING_CONVENTION) template<typename returnType> FunctionPtr(returnType (FASTCALL *value)()) @@ -254,6 +233,11 @@ public: } void* value() const { return m_value; } + + void dump(PrintStream& out) const + { + out.print(RawPointer(m_value)); + } private: void* m_value; @@ -288,12 +272,7 @@ public: return result; } -#if ENABLE(LLINT) - static MacroAssemblerCodePtr createLLIntCodePtr(LLIntCode codeId) - { - return createFromExecutableAddress(LLInt::getCodePtr(codeId)); - } -#endif + static MacroAssemblerCodePtr createLLIntCodePtr(OpcodeID codeId); explicit MacroAssemblerCodePtr(ReturnAddressPtr ra) : m_value(ra.value()) @@ -309,29 +288,16 @@ public: void* dataLocation() const { ASSERT_VALID_CODE_POINTER(m_value); return m_value; } #endif - bool operator!() const - { - return !m_value; - } + explicit operator bool() const { return m_value; } bool operator==(const MacroAssemblerCodePtr& other) const { return m_value == other.m_value; } - void dumpWithName(const char* name, PrintStream& out) const - { - if (executableAddress() == dataLocation()) { - out.print(name, "(", RawPointer(executableAddress()), ")"); - return; - } - out.print(name, "(executable = ", RawPointer(executableAddress()), ", dataLocation = ", RawPointer(dataLocation()), ")"); - } + void dumpWithName(const char* name, PrintStream& out) const; - void dump(PrintStream& out) const - { - dumpWithName("CodePtr", out); - } + void dump(PrintStream& out) const; enum EmptyValueTag { EmptyValue }; enum DeletedValueTag { DeletedValue }; @@ -387,9 +353,9 @@ public: { } - MacroAssemblerCodeRef(PassRefPtr<ExecutableMemoryHandle> executableMemory) + MacroAssemblerCodeRef(Ref<ExecutableMemoryHandle>&& executableMemory) : m_codePtr(executableMemory->start()) - , m_executableMemory(executableMemory) + , m_executableMemory(WTFMove(executableMemory)) { ASSERT(m_executableMemory->isManaged()); ASSERT(m_executableMemory->start()); @@ -404,13 +370,8 @@ public: return MacroAssemblerCodeRef(codePtr); } -#if ENABLE(LLINT) // Helper for creating self-managed code refs from LLInt. - static MacroAssemblerCodeRef createLLIntCodeRef(LLIntCode codeId) - { - return createSelfManagedCodeRef(MacroAssemblerCodePtr::createFromExecutableAddress(LLInt::getCodePtr(codeId))); - } -#endif + static MacroAssemblerCodeRef createLLIntCodeRef(OpcodeID codeId); ExecutableMemoryHandle* executableMemory() const { @@ -428,18 +389,16 @@ public: return 0; return m_executableMemory->sizeInBytes(); } + + bool tryToDisassemble(PrintStream& out, const char* prefix = "") const; - bool tryToDisassemble(const char* prefix) const - { - return JSC::tryToDisassemble(m_codePtr, size(), prefix, WTF::dataFile()); - } + bool tryToDisassemble(const char* prefix = "") const; - bool operator!() const { return !m_codePtr; } + JS_EXPORT_PRIVATE CString disassembly() const; - void dump(PrintStream& out) const - { - m_codePtr.dumpWithName("CodeRef", out); - } + explicit operator bool() const { return !!m_codePtr; } + + void dump(PrintStream& out) const; private: MacroAssemblerCodePtr m_codePtr; @@ -459,5 +418,3 @@ template<typename T> struct HashTraits; template<> struct HashTraits<JSC::MacroAssemblerCodePtr> : public CustomHashTraits<JSC::MacroAssemblerCodePtr> { }; } // namespace WTF - -#endif // MacroAssemblerCodeRef_h |