Paste number 73045: quick patch

Paste number 73045: quick patch
Pasted by: weinig
When:5 months, 4 weeks ago
Share:Tweet this! | http://paste.lisp.org/+1KD1
Channel:#squirrelfish
Paste contents:
Raw Source | XML | Display As
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 39576)
+++ ChangeLog	(working copy)
@@ -1,3 +1,17 @@
+2009-01-03  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by NOBODY (OOPS!).
+
+        Change the pcVector from storing native code pointers to storing offsets
+        from the base pointer.  This will allow use to generate this on demand later.
+
+        * bytecode/CodeBlock.h:
+        (JSC::PC::PC):
+        (JSC::getNativePCOffset):
+        (JSC::CodeBlock::getBytecodeIndex):
+        * jit/JIT.cpp:
+        (JSC::JIT::privateCompile):
+
 2009-01-02  Oliver Hunt  <oliver@apple.com>
 
         Reviewed by NOBODY (Build fix).
Index: bytecode/CodeBlock.h
===================================================================
--- bytecode/CodeBlock.h	(revision 39564)
+++ bytecode/CodeBlock.h	(working copy)
@@ -151,13 +151,13 @@ namespace JSC {
     };
 
     struct PC {
-        PC(void* nativePC, unsigned bytecodeIndex)
-            : nativePC(nativePC)
+        PC(ptrdiff_t nativePCOffset, unsigned bytecodeIndex)
+            : nativePCOffset(nativePCOffset)
             , bytecodeIndex(bytecodeIndex)
         {
         }
-        
-        void* nativePC;
+
+        ptrdiff_t nativePCOffset;
         unsigned bytecodeIndex;
     };
 
@@ -173,9 +173,9 @@ namespace JSC {
         return callLinkInfo->callReturnLocation;
     }
 
-    inline void* getNativePC(PC* pc)
+    inline ptrdiff_t getNativePCOffset(PC* pc)
     {
-        return pc->nativePC;
+        return pc->nativePCOffset;
     }
 
     // Binary chop algorithm, calls valueAtPosition on pre-sorted elements in array,
@@ -299,7 +299,8 @@ namespace JSC {
 
         unsigned getBytecodeIndex(void* nativePC)
         {
-            return binaryChop<PC, void*, getNativePC>(m_pcVector.begin(), m_pcVector.size(), nativePC)->bytecodeIndex;
+            ptrdiff_t nativePCOffset = reinterpret_cast<void**>(nativePC) - reinterpret_cast<void**>(m_jitCode.code);
+            return binaryChop<PC, ptrdiff_t, getNativePCOffset>(m_pcVector.begin(), m_pcVector.size(), nativePCOffset)->bytecodeIndex;
         }
 
         bool functionRegisterForBytecodeOffset(unsigned bytecodeOffset, int& functionRegisterIndex);
Index: jit/JIT.cpp
===================================================================
--- jit/JIT.cpp	(revision 39564)
+++ jit/JIT.cpp	(working copy)
@@ -1638,7 +1638,7 @@ void JIT::privateCompile()
     for (Vector<CallRecord>::iterator iter = m_calls.begin(); iter != m_calls.end(); ++iter) {
         if (iter->to)
             patchBuffer.link(iter->from, iter->to);
-        m_codeBlock->pcVector().append(PC(patchBuffer.addressOf(iter->from), iter->bytecodeIndex));
+        m_codeBlock->pcVector().append(PC(reinterpret_cast<void**>(patchBuffer.addressOf(iter->from)) - reinterpret_cast<void**>(code), iter->bytecodeIndex));
     }
 
     // Link absolute addresses for jsr

This paste has no annotations.

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.