ソースを参照

fix oop jit debugger bugs

Michael Holman 9 年 前
コミット
16cb20eda7

+ 2 - 3
lib/Backend/Func.cpp

@@ -143,9 +143,8 @@ Func::Func(JitArenaAllocator *alloc, JITTimeWorkItem * workItem,
     if (this->IsTopFunc())
     {
         outputData->hasJittedStackClosure = false;
-        // TODO: (michhol) validate initial values
-        outputData->localVarSlotsOffset = 0;
-        outputData->localVarChangedOffset = 0;
+        outputData->localVarSlotsOffset = m_localVarSlotsOffset;
+        outputData->localVarChangedOffset = m_hasLocalVarChangedOffset;
     }
 
     if (this->IsInlined())

+ 34 - 27
lib/Backend/JITTimeFunctionBody.cpp

@@ -20,10 +20,6 @@ JITTimeFunctionBody::InitializeJITFunctionData(
 {
     Assert(functionBody != nullptr);
 
-    // bytecode
-    jitBody->byteCodeLength = functionBody->GetByteCode()->GetLength();
-    jitBody->byteCodeBuffer = functionBody->GetByteCode()->GetBuffer();
-
     // const table
     jitBody->constCount = functionBody->GetConstantCount();
     if (functionBody->GetConstantCount() > 0)
@@ -65,12 +61,44 @@ JITTimeFunctionBody::InitializeJITFunctionData(
             }
         }
     }
-    // statement map
+
     Js::SmallSpanSequence * statementMap = functionBody->GetStatementMapSpanSequence();
 
+    // REVIEW: OOP JIT, is it possible for this to not match with isJitInDebugMode?
+    if (functionBody->IsInDebugMode())
+    {
+        Assert(!statementMap);
+
+        jitBody->byteCodeLength = functionBody->GetOriginalByteCode()->GetLength();
+        jitBody->byteCodeBuffer = functionBody->GetOriginalByteCode()->GetBuffer();
+
+        auto fullStatementMaps = functionBody->GetStatementMaps();
+        jitBody->fullStatementMapCount = fullStatementMaps->Count();
+        jitBody->fullStatementMaps = RecyclerNewArrayZ(recycler, StatementMapIDL, jitBody->fullStatementMapCount);
+        fullStatementMaps->Map([jitBody](int index, Js::FunctionBody::StatementMap * map) {
+
+            jitBody->fullStatementMaps[index] = *(StatementMapIDL*)map;
+
+            Assert(jitBody->fullStatementMaps[index].byteCodeSpanBegin == map->byteCodeSpan.Begin());
+            Assert(jitBody->fullStatementMaps[index].byteCodeSpanEnd == map->byteCodeSpan.End());
+            Assert(jitBody->fullStatementMaps[index].sourceSpanBegin == map->sourceSpan.Begin());
+            Assert(jitBody->fullStatementMaps[index].sourceSpanEnd == map->sourceSpan.End());
+            Assert((jitBody->fullStatementMaps[index].isSubExpression != FALSE) == map->isSubexpression);
+        });
 
-    if (statementMap)
+        if (functionBody->GetPropertyIdOnRegSlotsContainer())
+        {
+            jitBody->propertyIdsForRegSlotsCount = functionBody->GetPropertyIdOnRegSlotsContainer()->length;
+            jitBody->propertyIdsForRegSlots = functionBody->GetPropertyIdOnRegSlotsContainer()->propertyIdsForRegSlots;
+        }
+    }
+    else
     {
+        Assert(statementMap);
+
+        jitBody->byteCodeLength = functionBody->GetByteCode()->GetLength();
+        jitBody->byteCodeBuffer = functionBody->GetByteCode()->GetBuffer();
+
         jitBody->statementMap = RecyclerNewStructZ(recycler, SmallSpanSequenceIDL);
         jitBody->statementMap->baseValue = statementMap->baseValue;
 
@@ -85,28 +113,7 @@ JITTimeFunctionBody::InitializeJITFunctionData(
             jitBody->statementMap->statementLength = statementMap->pStatementBuffer->Count();
             jitBody->statementMap->statementBuffer = statementMap->pStatementBuffer->GetBuffer();
         }
-    }
-
-    // REVIEW: OOP JIT, is it possible for this to not match with isJitInDebugMode?
-    if (functionBody->IsInDebugMode())
-    {
-        Assert(!statementMap);
-        auto fullStatementMaps = functionBody->GetStatementMaps();
-        jitBody->fullStatementMapCount = fullStatementMaps->Count();
-        jitBody->fullStatementMaps = RecyclerNewArrayZ(recycler, StatementMapIDL, jitBody->fullStatementMapCount);
-        fullStatementMaps->Map([jitBody](int index, Js::FunctionBody::StatementMap * map) {
-            jitBody->fullStatementMaps[index].byteCodeSpanBegin = map->byteCodeSpan.Begin();
-            jitBody->fullStatementMaps[index].byteCodeSpanEnd = map->byteCodeSpan.End();
-            jitBody->fullStatementMaps[index].sourceSpanBegin = map->sourceSpan.Begin();
-            jitBody->fullStatementMaps[index].sourceSpanEnd = map->sourceSpan.End();
-            jitBody->fullStatementMaps[index].isSubExpression = map->isSubexpression;
-        });
 
-        if (functionBody->GetPropertyIdOnRegSlotsContainer())
-        {
-            jitBody->propertyIdsForRegSlotsCount = functionBody->GetPropertyIdOnRegSlotsContainer()->length;
-            jitBody->propertyIdsForRegSlots = functionBody->GetPropertyIdOnRegSlotsContainer()->propertyIdsForRegSlots;
-        }
     }
 
     jitBody->inlineCacheCount = functionBody->GetInlineCacheCount();

+ 13 - 0
lib/Backend/JITTimeWorkItem.cpp

@@ -96,6 +96,19 @@ JITTimeWorkItem::InitializeReader(
     }
 #if DBG
     reader->Create(m_jitBody.GetByteCodeBuffer(), startOffset, m_jitBody.GetByteCodeLength());
+    if (!JITManager::GetJITManager()->IsOOPJITEnabled())
+    {
+        Js::FunctionBody::StatementMapList * runtimeMap = ((Js::FunctionBody*)m_jitBody.GetAddr())->GetStatementMaps();
+        Assert(!m_fullStatementList || ((int)m_jitBody.GetFullStatementMapCount() == runtimeMap->Count() && runtimeMap->Count() >= 0));
+        for (uint i = 0; i < m_jitBody.GetFullStatementMapCount(); ++i)
+        {
+            Assert(runtimeMap->Item(i)->byteCodeSpan.begin == m_fullStatementList->Item(i)->byteCodeSpan.begin);
+            Assert(runtimeMap->Item(i)->byteCodeSpan.end == m_fullStatementList->Item(i)->byteCodeSpan.end);
+            Assert(runtimeMap->Item(i)->sourceSpan.begin == m_fullStatementList->Item(i)->sourceSpan.begin);
+            Assert(runtimeMap->Item(i)->sourceSpan.end == m_fullStatementList->Item(i)->sourceSpan.end);
+            Assert(runtimeMap->Item(i)->isSubexpression == m_fullStatementList->Item(i)->isSubexpression);
+        }
+    }
 #else
     reader->Create(m_jitBody.GetByteCodeBuffer(), startOffset);
 #endif

+ 7 - 0
lib/Backend/NativeCodeGenerator.cpp

@@ -951,6 +951,13 @@ NativeCodeGenerator::CodeGen(PageAllocator * pageAllocator, CodeGenWorkItem* wor
 
     workItem->GetFunctionBody()->SetFrameHeight(workItem->GetEntryPoint(), jitWriteData.frameHeight);
 
+    if (workItem->Type() == JsFunctionType)
+    {
+        Js::FunctionEntryPointInfo * funcEP = (Js::FunctionEntryPointInfo*)workItem->GetEntryPoint();
+        funcEP->localVarSlotsOffset = jitWriteData.localVarSlotsOffset;
+        funcEP->localVarChangedOffset = jitWriteData.localVarChangedOffset;
+    }
+
     if (jitWriteData.hasJittedStackClosure != FALSE)
     {
         workItem->GetEntryPoint()->SetHasJittedStackClosure();

+ 3 - 3
lib/JITIDL/JITTypes.h

@@ -340,13 +340,13 @@ typedef struct JITLoopHeaderIDL
 
 typedef struct StatementMapIDL
 {
-    boolean isSubExpression;
-    IDL_PAD1(1)
-    IDL_PAD2(0)
     int sourceSpanBegin;
     int sourceSpanEnd;
     int byteCodeSpanBegin;
     int byteCodeSpanEnd;
+    boolean isSubExpression;
+    IDL_PAD1(1)
+    IDL_PAD2(0)
 } StatementMapIDL;
 
 typedef struct AsmJsDataIDL