]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - dfg/DFGOSREntry.cpp
JavaScriptCore-1218.tar.gz
[apple/javascriptcore.git] / dfg / DFGOSREntry.cpp
index 21c76c6fe67524d4a2bf1aae04ca4d14ff954680..5739593eef54e8f6d399004550468e8c66478aa9 100644 (file)
@@ -32,6 +32,7 @@
 #include "CodeBlock.h"
 #include "DFGNode.h"
 #include "JIT.h"
+#include "Operations.h"
 
 namespace JSC { namespace DFG {
 
@@ -42,15 +43,21 @@ void* prepareOSREntry(ExecState* exec, CodeBlock* codeBlock, unsigned bytecodeIn
     ASSERT(codeBlock->alternative());
     ASSERT(codeBlock->alternative()->getJITType() == JITCode::BaselineJIT);
     ASSERT(!codeBlock->jitCodeMap());
-    ASSERT(codeBlock->numberOfDFGOSREntries());
 
 #if ENABLE(JIT_VERBOSE_OSR)
-    dataLog("OSR in %p(%p) from bc#%u\n", codeBlock, codeBlock->alternative(), bytecodeIndex);
+    dataLog("OSR in ", *codeBlock->alternative(), " -> ", *codeBlock, " from bc#", bytecodeIndex, "\n");
 #endif
     
-    JSGlobalData* globalData = &exec->globalData();
+    VM* vm = &exec->vm();
     OSREntryData* entry = codeBlock->dfgOSREntryDataForBytecodeIndex(bytecodeIndex);
     
+    if (!entry) {
+#if ENABLE(JIT_VERBOSE_OSR)
+        dataLogF("    OSR failed because the entrypoint was optimized out.\n");
+#endif
+        return 0;
+    }
+    
     ASSERT(entry->m_bytecodeIndex == bytecodeIndex);
     
     // The code below checks if it is safe to perform OSR entry. It may find
@@ -80,9 +87,9 @@ void* prepareOSREntry(ExecState* exec, CodeBlock* codeBlock, unsigned bytecodeIn
     for (size_t argument = 0; argument < entry->m_expectedValues.numberOfArguments(); ++argument) {
         if (argument >= exec->argumentCountIncludingThis()) {
 #if ENABLE(JIT_VERBOSE_OSR)
-            dataLog("    OSR failed because argument %zu was not passed, expected ", argument);
+            dataLogF("    OSR failed because argument %zu was not passed, expected ", argument);
             entry->m_expectedValues.argument(argument).dump(WTF::dataFile());
-            dataLog(".\n");
+            dataLogF(".\n");
 #endif
             return 0;
         }
@@ -95,9 +102,7 @@ void* prepareOSREntry(ExecState* exec, CodeBlock* codeBlock, unsigned bytecodeIn
         
         if (!entry->m_expectedValues.argument(argument).validate(value)) {
 #if ENABLE(JIT_VERBOSE_OSR)
-            dataLog("    OSR failed because argument %zu is %s, expected ", argument, value.description());
-            entry->m_expectedValues.argument(argument).dump(WTF::dataFile());
-            dataLog(".\n");
+            dataLog("    OSR failed because argument ", argument, " is ", value, ", expected ", entry->m_expectedValues.argument(argument), ".\n");
 #endif
             return 0;
         }
@@ -107,7 +112,7 @@ void* prepareOSREntry(ExecState* exec, CodeBlock* codeBlock, unsigned bytecodeIn
         if (entry->m_localsForcedDouble.get(local)) {
             if (!exec->registers()[local].jsValue().isNumber()) {
 #if ENABLE(JIT_VERBOSE_OSR)
-                dataLog("    OSR failed because variable %zu is %s, expected number.\n", local, exec->registers()[local].jsValue().description());
+                dataLog("    OSR failed because variable ", local, " is ", exec->registers()[local].jsValue(), ", expected number.\n");
 #endif
                 return 0;
             }
@@ -115,9 +120,7 @@ void* prepareOSREntry(ExecState* exec, CodeBlock* codeBlock, unsigned bytecodeIn
         }
         if (!entry->m_expectedValues.local(local).validate(exec->registers()[local].jsValue())) {
 #if ENABLE(JIT_VERBOSE_OSR)
-            dataLog("    OSR failed because variable %zu is %s, expected ", local, exec->registers()[local].jsValue().description());
-            entry->m_expectedValues.local(local).dump(WTF::dataFile());
-            dataLog(".\n");
+            dataLog("    OSR failed because variable ", local, " is ", exec->registers()[local].jsValue(), ", expected ", entry->m_expectedValues.local(local), ".\n");
 #endif
             return 0;
         }
@@ -130,15 +133,15 @@ void* prepareOSREntry(ExecState* exec, CodeBlock* codeBlock, unsigned bytecodeIn
     //    it seems silly: you'd be diverting the program to error handling when it
     //    would have otherwise just kept running albeit less quickly.
     
-    if (!globalData->interpreter->registerFile().grow(&exec->registers()[codeBlock->m_numCalleeRegisters])) {
+    if (!vm->interpreter->stack().grow(&exec->registers()[codeBlock->m_numCalleeRegisters])) {
 #if ENABLE(JIT_VERBOSE_OSR)
-        dataLog("    OSR failed because stack growth failed.\n");
+        dataLogF("    OSR failed because stack growth failed.\n");
 #endif
         return 0;
     }
     
 #if ENABLE(JIT_VERBOSE_OSR)
-    dataLog("    OSR should succeed.\n");
+    dataLogF("    OSR should succeed.\n");
 #endif
     
     // 3) Perform data format conversions.
@@ -156,7 +159,7 @@ void* prepareOSREntry(ExecState* exec, CodeBlock* codeBlock, unsigned bytecodeIn
     void* result = codeBlock->getJITCode().executableAddressAtOffset(entry->m_machineCodeOffset);
     
 #if ENABLE(JIT_VERBOSE_OSR)
-    dataLog("    OSR returning machine code address %p.\n", result);
+    dataLogF("    OSR returning machine code address %p.\n", result);
 #endif
     
     return result;