X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/6fe7ccc865dc7d7541b93c5bcaf6368d2c98a174..8b637bb680022adfddad653280734877951535a9:/assembler/MacroAssemblerCodeRef.h?ds=sidebyside diff --git a/assembler/MacroAssemblerCodeRef.h b/assembler/MacroAssemblerCodeRef.h index ac62c42..ec16659 100644 --- a/assembler/MacroAssemblerCodeRef.h +++ b/assembler/MacroAssemblerCodeRef.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Apple Inc. All rights reserved. + * Copyright (C) 2009, 2012 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,10 +26,12 @@ #ifndef MacroAssemblerCodeRef_h #define MacroAssemblerCodeRef_h +#include "Disassembler.h" #include "ExecutableAllocator.h" +#include "LLIntData.h" +#include #include #include -#include // 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). @@ -124,6 +126,13 @@ public: ASSERT_VALID_CODE_POINTER(m_value); } + template + FunctionPtr(returnType(*value)(argType1, argType2, argType3, argType4, argType5)) + : 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) @@ -280,10 +289,13 @@ public: return result; } - static MacroAssemblerCodePtr createLLIntCodePtr(void (*function)()) +#if ENABLE(LLINT) + static MacroAssemblerCodePtr createLLIntCodePtr(LLIntCode codeId) { - return createFromExecutableAddress(bitwise_cast(function)); + return createFromExecutableAddress(LLInt::getCodePtr(codeId)); } +#endif + explicit MacroAssemblerCodePtr(ReturnAddressPtr ra) : m_value(ra.value()) { @@ -344,12 +356,14 @@ public: return MacroAssemblerCodeRef(codePtr); } +#if ENABLE(LLINT) // Helper for creating self-managed code refs from LLInt. - static MacroAssemblerCodeRef createLLIntCodeRef(void (*function)()) + static MacroAssemblerCodeRef createLLIntCodeRef(LLIntCode codeId) { - return createSelfManagedCodeRef(MacroAssemblerCodePtr::createFromExecutableAddress(bitwise_cast(function))); + return createSelfManagedCodeRef(MacroAssemblerCodePtr::createFromExecutableAddress(LLInt::getCodePtr(codeId))); } - +#endif + ExecutableMemoryHandle* executableMemory() const { return m_executableMemory.get(); @@ -367,6 +381,11 @@ public: return m_executableMemory->sizeInBytes(); } + bool tryToDisassemble(const char* prefix) const + { + return JSC::tryToDisassemble(m_codePtr, size(), prefix, WTF::dataFile()); + } + bool operator!() const { return !m_codePtr; } private: