]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - assembler/MacroAssemblerCodeRef.h
JavaScriptCore-1218.0.1.tar.gz
[apple/javascriptcore.git] / assembler / MacroAssemblerCodeRef.h
index ac62c422103323bb0d6ebea72a62ff1614703a46..ec16659d5a729938c443a60fac365cf699573bf4 100644 (file)
@@ -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
 #ifndef MacroAssemblerCodeRef_h
 #define MacroAssemblerCodeRef_h
 
+#include "Disassembler.h"
 #include "ExecutableAllocator.h"
+#include "LLIntData.h"
+#include <wtf/DataLog.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
-#include <wtf/UnusedParam.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).
@@ -124,6 +126,13 @@ public:
         ASSERT_VALID_CODE_POINTER(m_value);
     }
 
+    template<typename returnType, typename argType1, typename argType2, typename argType3, typename argType4, typename argType5>
+    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<void*>(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<void*>(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: