Browse Source

Merge remote-tracking branch 'master' into linux

Jianchun Xu 10 years ago
parent
commit
9d2a3c71fa
100 changed files with 106 additions and 87 deletions
  1. 2 2
      CMakeLists.txt
  2. 0 0
      Lib/Backend/AgenPeeps.cpp
  3. 0 0
      Lib/Backend/AgenPeeps.h
  4. 0 0
      Lib/Backend/Backend.cpp
  5. 0 0
      Lib/Backend/Backend.h
  6. 0 0
      Lib/Backend/BackendOpCodeAttrAsmJs.cpp
  7. 0 0
      Lib/Backend/BackendOpCodeAttrAsmJs.h
  8. 0 0
      Lib/Backend/BackendOpCodeList.h
  9. 0 0
      Lib/Backend/BackwardPass.cpp
  10. 0 0
      Lib/Backend/BackwardPass.h
  11. 0 0
      Lib/Backend/BailOut.cpp
  12. 0 0
      Lib/Backend/BailOut.h
  13. 0 0
      Lib/Backend/BailOutKind.h
  14. 0 0
      Lib/Backend/CaseNode.cpp
  15. 0 0
      Lib/Backend/CaseNode.h
  16. 0 0
      Lib/Backend/Chakra.Backend.vcxproj
  17. 0 0
      Lib/Backend/Chakra.Backend.vcxproj.filters
  18. 0 0
      Lib/Backend/CodeGenAllocators.cpp
  19. 0 0
      Lib/Backend/CodeGenAllocators.h
  20. 0 0
      Lib/Backend/CodeGenNumberAllocator.cpp
  21. 0 0
      Lib/Backend/CodeGenNumberAllocator.h
  22. 7 1
      Lib/Backend/CodeGenWorkItem.cpp
  23. 0 0
      Lib/Backend/CodeGenWorkItem.h
  24. 0 0
      Lib/Backend/CodeGenWorkItemType.h
  25. 0 0
      Lib/Backend/DbCheckPostLower.cpp
  26. 0 0
      Lib/Backend/DbCheckPostLower.h
  27. 0 0
      Lib/Backend/Debug.cpp
  28. 24 16
      Lib/Backend/EmitBuffer.cpp
  29. 3 2
      Lib/Backend/EmitBuffer.h
  30. 0 0
      Lib/Backend/Encoder.cpp
  31. 0 0
      Lib/Backend/Encoder.h
  32. 0 0
      Lib/Backend/ExternalLowerer.h
  33. 0 0
      Lib/Backend/FlowGraph.cpp
  34. 0 0
      Lib/Backend/FlowGraph.h
  35. 0 0
      Lib/Backend/Func.cpp
  36. 0 0
      Lib/Backend/Func.h
  37. 0 0
      Lib/Backend/GlobHashTable.h
  38. 0 0
      Lib/Backend/GlobOpt.cpp
  39. 0 0
      Lib/Backend/GlobOpt.h
  40. 0 0
      Lib/Backend/GlobOptBailOut.cpp
  41. 0 0
      Lib/Backend/GlobOptExpr.cpp
  42. 0 0
      Lib/Backend/GlobOptFields.cpp
  43. 0 0
      Lib/Backend/GlobOptIntBounds.cpp
  44. 0 0
      Lib/Backend/GlobOptIntBounds.h
  45. 0 0
      Lib/Backend/GlobOptSimd128.cpp
  46. 0 0
      Lib/Backend/IR.cpp
  47. 0 0
      Lib/Backend/IR.h
  48. 0 0
      Lib/Backend/IR.inl
  49. 0 0
      Lib/Backend/IRBaseTypeList.h
  50. 0 0
      Lib/Backend/IRBuilder.cpp
  51. 0 0
      Lib/Backend/IRBuilder.h
  52. 2 2
      Lib/Backend/IRBuilderAsmJs.cpp
  53. 0 0
      Lib/Backend/IRBuilderAsmJs.h
  54. 0 0
      Lib/Backend/IRType.cpp
  55. 0 0
      Lib/Backend/IRType.h
  56. 0 0
      Lib/Backend/IRTypeList.h
  57. 0 0
      Lib/Backend/IRViewer.cpp
  58. 0 0
      Lib/Backend/IRViewer.h
  59. 0 0
      Lib/Backend/InductionVariable.cpp
  60. 0 0
      Lib/Backend/InductionVariable.h
  61. 0 0
      Lib/Backend/Inline.cpp
  62. 0 0
      Lib/Backend/Inline.h
  63. 0 0
      Lib/Backend/InlineeFrameInfo.cpp
  64. 0 0
      Lib/Backend/InlineeFrameInfo.h
  65. 0 0
      Lib/Backend/InliningDecider.cpp
  66. 0 0
      Lib/Backend/InliningDecider.h
  67. 0 0
      Lib/Backend/InliningHeuristics.cpp
  68. 0 0
      Lib/Backend/InliningHeuristics.h
  69. 0 0
      Lib/Backend/IntBounds.cpp
  70. 0 0
      Lib/Backend/IntBounds.h
  71. 0 0
      Lib/Backend/IntConstantBounds.h
  72. 0 0
      Lib/Backend/IntOverflowDoesNotMatterRange.h
  73. 6 1
      Lib/Backend/InterpreterThunkEmitter.cpp
  74. 0 0
      Lib/Backend/InterpreterThunkEmitter.h
  75. 0 0
      Lib/Backend/JnHelperMethod.cpp
  76. 0 0
      Lib/Backend/JnHelperMethod.h
  77. 0 0
      Lib/Backend/JnHelperMethodList.h
  78. 0 0
      Lib/Backend/Lifetime.h
  79. 0 0
      Lib/Backend/LinearScan.cpp
  80. 0 0
      Lib/Backend/LinearScan.h
  81. 0 0
      Lib/Backend/LinearScanMDShared.h
  82. 0 17
      Lib/Backend/Lower.cpp
  83. 0 0
      Lib/Backend/Lower.h
  84. 62 46
      Lib/Backend/LowerMDShared.cpp
  85. 0 0
      Lib/Backend/LowerMDShared.h
  86. 0 0
      Lib/Backend/LowerMDSharedSimd128.cpp
  87. 0 0
      Lib/Backend/NativeCodeData.cpp
  88. 0 0
      Lib/Backend/NativeCodeData.h
  89. 0 0
      Lib/Backend/NativeCodeGenerator.cpp
  90. 0 0
      Lib/Backend/NativeCodeGenerator.h
  91. 0 0
      Lib/Backend/Opnd.cpp
  92. 0 0
      Lib/Backend/Opnd.h
  93. 0 0
      Lib/Backend/Opnd.inl
  94. 0 0
      Lib/Backend/PDataManager.cpp
  95. 0 0
      Lib/Backend/PDataManager.h
  96. 0 0
      Lib/Backend/Peeps.cpp
  97. 0 0
      Lib/Backend/Peeps.h
  98. 0 0
      Lib/Backend/PreLowerPeeps.cpp
  99. 0 0
      Lib/Backend/PrologEncoder.cpp
  100. 0 0
      Lib/Backend/PrologEncoder.h

+ 2 - 2
CMakeLists.txt

@@ -107,5 +107,5 @@ endif(CLR_CMAKE_PLATFORM_UNIX)
 include_directories("pal")
 include_directories("pal/inc")
 include_directories("pal/inc/rt")
-include_directories(lib/common)
-add_subdirectory (lib)
+include_directories(Lib/Common)
+add_subdirectory (Lib)

+ 0 - 0
lib/Backend/AgenPeeps.cpp → Lib/Backend/AgenPeeps.cpp


+ 0 - 0
lib/Backend/AgenPeeps.h → Lib/Backend/AgenPeeps.h


+ 0 - 0
lib/Backend/BackEnd.cpp → Lib/Backend/Backend.cpp


+ 0 - 0
lib/Backend/BackEnd.h → Lib/Backend/Backend.h


+ 0 - 0
lib/Backend/BackEndOpcodeAttrAsmJs.cpp → Lib/Backend/BackendOpCodeAttrAsmJs.cpp


+ 0 - 0
lib/Backend/BackEndOpcodeAttrAsmJs.h → Lib/Backend/BackendOpCodeAttrAsmJs.h


+ 0 - 0
lib/Backend/BackEndOpCodeList.h → Lib/Backend/BackendOpCodeList.h


+ 0 - 0
lib/Backend/BackwardPass.cpp → Lib/Backend/BackwardPass.cpp


+ 0 - 0
lib/Backend/BackwardPass.h → Lib/Backend/BackwardPass.h


+ 0 - 0
lib/Backend/BailOut.cpp → Lib/Backend/BailOut.cpp


+ 0 - 0
lib/Backend/BailOut.h → Lib/Backend/BailOut.h


+ 0 - 0
lib/Backend/BailOutKind.h → Lib/Backend/BailOutKind.h


+ 0 - 0
lib/Backend/CaseNode.cpp → Lib/Backend/CaseNode.cpp


+ 0 - 0
lib/Backend/CaseNode.h → Lib/Backend/CaseNode.h


+ 0 - 0
lib/Backend/Chakra.Backend.vcxproj → Lib/Backend/Chakra.Backend.vcxproj


+ 0 - 0
lib/Backend/Chakra.Backend.vcxproj.filters → Lib/Backend/Chakra.Backend.vcxproj.filters


+ 0 - 0
lib/Backend/CodeGenAllocators.cpp → Lib/Backend/CodeGenAllocators.cpp


+ 0 - 0
lib/Backend/CodeGenAllocators.h → Lib/Backend/CodeGenAllocators.h


+ 0 - 0
lib/Backend/CodegenNumberAllocator.cpp → Lib/Backend/CodeGenNumberAllocator.cpp


+ 0 - 0
lib/Backend/CodeGenNumberAllocator.h → Lib/Backend/CodeGenNumberAllocator.h


+ 7 - 1
lib/Backend/CodeGenWorkItem.cpp → Lib/Backend/CodeGenWorkItem.cpp

@@ -205,7 +205,13 @@ void CodeGenWorkItem::RecordNativeCodeSize(Func *func, size_t bytes, ushort pdat
 #else
     bool canAllocInPreReservedHeapPageSegment = func->CanAllocInPreReservedHeapPageSegment();
 #endif
-    EmitBufferAllocation *allocation = func->GetEmitBufferManager()->AllocateBuffer(bytes, &buffer, false, pdataCount, xdataSize, canAllocInPreReservedHeapPageSegment, true);
+    EmitBufferAllocation *allocation = func->GetEmitBufferManager()->AllocateBuffer(bytes, &buffer, pdataCount, xdataSize, canAllocInPreReservedHeapPageSegment, true);
+
+#if DBG
+    MEMORY_BASIC_INFORMATION memBasicInfo;
+    size_t resultBytes = VirtualQuery(allocation->allocation->address, &memBasicInfo, sizeof(memBasicInfo));
+    Assert(resultBytes != 0 && memBasicInfo.Protect == PAGE_EXECUTE);
+#endif
 
     Assert(allocation != nullptr);
     if (buffer == nullptr)

+ 0 - 0
lib/Backend/CodeGenWorkItem.h → Lib/Backend/CodeGenWorkItem.h


+ 0 - 0
lib/Backend/CodeGenWorkItemType.h → Lib/Backend/CodeGenWorkItemType.h


+ 0 - 0
lib/Backend/DbCheckPostLower.cpp → Lib/Backend/DbCheckPostLower.cpp


+ 0 - 0
lib/Backend/DbCheckPostLower.h → Lib/Backend/DbCheckPostLower.h


+ 0 - 0
lib/Backend/Debug.cpp → Lib/Backend/Debug.cpp


+ 24 - 16
lib/Backend/EmitBuffer.cpp → Lib/Backend/EmitBuffer.cpp

@@ -246,8 +246,8 @@ bool EmitBufferManager<SyncObject>::FinalizeAllocation(EmitBufferAllocation *all
     DWORD bytes = allocation->BytesFree();
     if(bytes > 0)
     {
-        BYTE* buffer;
-        this->GetBuffer(allocation, bytes, &buffer, false /*readWrite*/);
+        BYTE* buffer = nullptr;
+        this->GetBuffer(allocation, bytes, &buffer);
         if (!this->CommitBuffer(allocation, buffer, 0, /*sourceBuffer=*/ nullptr, /*alignPad=*/ bytes))
         {
             return false;
@@ -262,11 +262,10 @@ bool EmitBufferManager<SyncObject>::FinalizeAllocation(EmitBufferAllocation *all
 }
 
 template <typename SyncObject>
-EmitBufferAllocation* EmitBufferManager<SyncObject>::GetBuffer(EmitBufferAllocation *allocation, __in size_t bytes, __deref_bcount(bytes) BYTE** ppBuffer, bool readWrite)
+EmitBufferAllocation* EmitBufferManager<SyncObject>::GetBuffer(EmitBufferAllocation *allocation, __in size_t bytes, __deref_bcount(bytes) BYTE** ppBuffer)
 {
     Assert(this->criticalSection.IsLocked());
 
-    this->allocationHeap.EnsureAllocationProtection(allocation->allocation, readWrite);
     Assert(allocation->BytesFree() >= bytes);
 
     // In case of ThunkEmitter the script context would be null and we don't want to track that as code size.
@@ -288,7 +287,7 @@ EmitBufferAllocation* EmitBufferManager<SyncObject>::GetBuffer(EmitBufferAllocat
 //      to modify this buffer one page at a time.
 //----------------------------------------------------------------------------
 template <typename SyncObject>
-EmitBufferAllocation* EmitBufferManager<SyncObject>::AllocateBuffer(__in size_t bytes, __deref_bcount(bytes) BYTE** ppBuffer, bool readWrite /*= false*/, ushort pdataCount /*=0*/, ushort xdataSize  /*=0*/, bool canAllocInPreReservedHeapPageSegment /*=false*/,
+EmitBufferAllocation* EmitBufferManager<SyncObject>::AllocateBuffer(__in size_t bytes, __deref_bcount(bytes) BYTE** ppBuffer, ushort pdataCount /*=0*/, ushort xdataSize  /*=0*/, bool canAllocInPreReservedHeapPageSegment /*=false*/,
     bool isAnyJittedCode /* = false*/)
 {
     AutoRealOrFakeCriticalSection<SyncObject> autoCs(&this->criticalSection);
@@ -297,7 +296,13 @@ EmitBufferAllocation* EmitBufferManager<SyncObject>::AllocateBuffer(__in size_t
 
     EmitBufferAllocation * allocation = this->NewAllocation(bytes, pdataCount, xdataSize, canAllocInPreReservedHeapPageSegment, isAnyJittedCode);
 
-    GetBuffer(allocation, bytes, ppBuffer, readWrite);
+    GetBuffer(allocation, bytes, ppBuffer);
+
+#if DBG
+    MEMORY_BASIC_INFORMATION memBasicInfo;
+    size_t resultBytes = VirtualQuery(allocation->allocation->address, &memBasicInfo, sizeof(memBasicInfo));
+    Assert(resultBytes != 0 && memBasicInfo.Protect == PAGE_EXECUTE);
+#endif
 
     return allocation;
 }
@@ -327,6 +332,14 @@ bool EmitBufferManager<SyncObject>::CheckCommitFaultInjection()
 
 #endif
 
+template <typename SyncObject>
+bool EmitBufferManager<SyncObject>::ProtectBufferWithExecuteReadWriteForInterpreter(EmitBufferAllocation* allocation)
+{
+    Assert(this->criticalSection.IsLocked());
+    Assert(allocation != nullptr);
+    return (this->allocationHeap.ProtectAllocationWithExecuteReadWrite(allocation->allocation) == TRUE);
+}
+
 // Returns true if we successfully commit the buffer
 // Returns false if we OOM
 template <typename SyncObject>
@@ -340,8 +353,6 @@ bool EmitBufferManager<SyncObject>::CommitReadWriteBufferForInterpreter(EmitBuff
     this->totalBytesCode += bufferSize;
 #endif
 
-    DWORD oldProtect;
-
     VerboseHeapTrace(L"Setting execute permissions on 0x%p, allocation: 0x%p\n", pBuffer, allocation->allocation->address);
 
 #ifdef ENABLE_DEBUG_CONFIG_OPTIONS
@@ -351,14 +362,13 @@ bool EmitBufferManager<SyncObject>::CommitReadWriteBufferForInterpreter(EmitBuff
     }
 #endif
 
-    if (!this->allocationHeap.ProtectAllocation(allocation->allocation, PAGE_EXECUTE, &oldProtect, PAGE_READWRITE))
+    if (!this->allocationHeap.ProtectAllocationWithExecuteReadOnly(allocation->allocation))
     {
         return false;
     }
 
     FlushInstructionCache(AutoSystemInfo::Data.GetProcessHandle(), pBuffer, bufferSize);
 
-    Assert(oldProtect == PAGE_READWRITE);
     return true;
 }
 
@@ -378,8 +388,6 @@ EmitBufferManager<SyncObject>::CommitBuffer(EmitBufferAllocation* allocation, __
     Assert(destBuffer != nullptr);
     Assert(allocation != nullptr);
 
-    DWORD oldProtect;
-
     BYTE *currentDestBuffer = allocation->GetUnused();
     BYTE *bufferToFlush = currentDestBuffer;
     Assert(allocation->BytesFree() >= bytes + alignPad);
@@ -404,11 +412,11 @@ EmitBufferManager<SyncObject>::CommitBuffer(EmitBufferAllocation* allocation, __
             return false;
         }
 #endif
-        if (!this->allocationHeap.ProtectAllocationPage(allocation->allocation, (char*)readWriteBuffer, PAGE_EXECUTE_READWRITE, &oldProtect, PAGE_EXECUTE))
+
+        if (!this->allocationHeap.ProtectAllocationWithExecuteReadWrite(allocation->allocation, (char*)readWriteBuffer))
         {
             return false;
         }
-        Assert(oldProtect == PAGE_EXECUTE);
 
         if (alignPad != 0)
         {
@@ -440,11 +448,11 @@ EmitBufferManager<SyncObject>::CommitBuffer(EmitBufferAllocation* allocation, __
         }
 
         Assert(readWriteBuffer + readWriteBytes == currentDestBuffer);
-        if (!this->allocationHeap.ProtectAllocationPage(allocation->allocation, (char*)readWriteBuffer, PAGE_EXECUTE, &oldProtect, PAGE_EXECUTE_READWRITE))
+
+        if (!this->allocationHeap.ProtectAllocationWithExecuteReadOnly(allocation->allocation, (char*)readWriteBuffer))
         {
             return false;
         }
-        Assert(oldProtect == PAGE_EXECUTE_READWRITE);
     }
 
     FlushInstructionCache(AutoSystemInfo::Data.GetProcessHandle(), bufferToFlush, sizeToFlush);

+ 3 - 2
lib/Backend/EmitBuffer.h → Lib/Backend/EmitBuffer.h

@@ -37,8 +37,9 @@ public:
     void Decommit();
     void Clear();
 
-    EmitBufferAllocation* AllocateBuffer(__in size_t bytes, __deref_bcount(bytes) BYTE** ppBuffer, bool readWrite = false, ushort pdataCount = 0, ushort xdataSize = 0, bool canAllocInPreReservedHeapPageSegment = false, bool isAnyJittedCode = false);
+    EmitBufferAllocation* AllocateBuffer(__in size_t bytes, __deref_bcount(bytes) BYTE** ppBuffer, ushort pdataCount = 0, ushort xdataSize = 0, bool canAllocInPreReservedHeapPageSegment = false, bool isAnyJittedCode = false);
     bool CommitBuffer(EmitBufferAllocation* allocation, __out_bcount(bytes) BYTE* destBuffer, __in size_t bytes, __in_bcount(bytes) const BYTE* sourceBuffer, __in DWORD alignPad = 0);
+    bool ProtectBufferWithExecuteReadWriteForInterpreter(EmitBufferAllocation* allocation);
     bool CommitReadWriteBufferForInterpreter(EmitBufferAllocation* allocation, _In_reads_bytes_(bufferSize) BYTE* pBuffer, _In_ size_t bufferSize);
     void CompletePreviousAllocation(EmitBufferAllocation* allocation);
     bool FreeAllocation(void* address);
@@ -119,7 +120,7 @@ private:
     Js::ScriptContext * scriptContext;
 
     EmitBufferAllocation * NewAllocation(size_t bytes, ushort pdataCount, ushort xdataSize, bool canAllocInPreReservedHeapPageSegment, bool isAnyJittedCode);
-    EmitBufferAllocation* GetBuffer(EmitBufferAllocation *allocation, __in size_t bytes, __deref_bcount(bytes) BYTE** ppBuffer, bool readWrite);
+    EmitBufferAllocation* GetBuffer(EmitBufferAllocation *allocation, __in size_t bytes, __deref_bcount(bytes) BYTE** ppBuffer);
 
     bool FinalizeAllocation(EmitBufferAllocation *allocation);
     CustomHeap::Heap allocationHeap;

+ 0 - 0
lib/Backend/Encoder.cpp → Lib/Backend/Encoder.cpp


+ 0 - 0
lib/Backend/Encoder.h → Lib/Backend/Encoder.h


+ 0 - 0
lib/Backend/ExternalLowerer.h → Lib/Backend/ExternalLowerer.h


+ 0 - 0
lib/Backend/FlowGraph.cpp → Lib/Backend/FlowGraph.cpp


+ 0 - 0
lib/Backend/FlowGraph.h → Lib/Backend/FlowGraph.h


+ 0 - 0
lib/Backend/Func.cpp → Lib/Backend/Func.cpp


+ 0 - 0
lib/Backend/Func.h → Lib/Backend/Func.h


+ 0 - 0
lib/Backend/GlobHashTable.h → Lib/Backend/GlobHashTable.h


+ 0 - 0
lib/Backend/GlobOpt.cpp → Lib/Backend/GlobOpt.cpp


+ 0 - 0
lib/Backend/GlobOpt.h → Lib/Backend/GlobOpt.h


+ 0 - 0
lib/Backend/GlobOptBailout.cpp → Lib/Backend/GlobOptBailOut.cpp


+ 0 - 0
lib/Backend/GlobOptExpr.cpp → Lib/Backend/GlobOptExpr.cpp


+ 0 - 0
lib/Backend/GlobOptFields.cpp → Lib/Backend/GlobOptFields.cpp


+ 0 - 0
lib/Backend/GlobOptIntBounds.cpp → Lib/Backend/GlobOptIntBounds.cpp


+ 0 - 0
lib/Backend/GlobOptIntBounds.h → Lib/Backend/GlobOptIntBounds.h


+ 0 - 0
lib/Backend/GlobOptSimd128.cpp → Lib/Backend/GlobOptSimd128.cpp


+ 0 - 0
lib/Backend/IR.cpp → Lib/Backend/IR.cpp


+ 0 - 0
lib/Backend/IR.h → Lib/Backend/IR.h


+ 0 - 0
lib/Backend/IR.inl → Lib/Backend/IR.inl


+ 0 - 0
lib/Backend/IRBaseTypeList.h → Lib/Backend/IRBaseTypeList.h


+ 0 - 0
lib/Backend/IRBuilder.cpp → Lib/Backend/IRBuilder.cpp


+ 0 - 0
lib/Backend/IRBuilder.h → Lib/Backend/IRBuilder.h


+ 2 - 2
lib/Backend/IRBuilderAsmJs.cpp → Lib/Backend/IRBuilderAsmJs.cpp

@@ -331,7 +331,7 @@ IRBuilderAsmJs::BuildSrcOpnd(Js::RegSlot srcRegSlot, IRType type)
 IR::RegOpnd *
 IRBuilderAsmJs::BuildIntConstOpnd(Js::RegSlot regSlot)
 {
-    Js::Var * constTable = static_cast<Js::Var *>(m_func->GetJnFunction()->GetConstTable());
+    Js::Var * constTable = m_func->GetJnFunction()->GetConstTable();
     int * intConstTable = reinterpret_cast<int *>(constTable + Js::AsmJsFunctionMemory::RequiredVarConstants - 1);
     uint32 intConstCount = m_func->GetJnFunction()->GetAsmJsFunctionInfo()->GetIntConstCount();
 
@@ -695,7 +695,7 @@ IRBuilderAsmJs::BuildConstantLoads()
     uint32 intConstCount = m_func->GetJnFunction()->GetAsmJsFunctionInfo()->GetIntConstCount();
     uint32 floatConstCount = m_func->GetJnFunction()->GetAsmJsFunctionInfo()->GetFloatConstCount();
     uint32 doubleConstCount = m_func->GetJnFunction()->GetAsmJsFunctionInfo()->GetDoubleConstCount();
-    Js::Var * constTable = static_cast<Js::Var *>(m_func->GetJnFunction()->GetConstTable());
+    Js::Var * constTable = m_func->GetJnFunction()->GetConstTable();
 
     // Load FrameDisplay
     IR::RegOpnd * dstOpnd = BuildDstOpnd(AsmJsRegSlots::ModuleMemReg, TyVar);

+ 0 - 0
lib/Backend/IRBuilderAsmJs.h → Lib/Backend/IRBuilderAsmJs.h


+ 0 - 0
lib/Backend/IRType.cpp → Lib/Backend/IRType.cpp


+ 0 - 0
lib/Backend/IRType.h → Lib/Backend/IRType.h


+ 0 - 0
lib/Backend/IRTypeList.h → Lib/Backend/IRTypeList.h


+ 0 - 0
lib/Backend/IRViewer.cpp → Lib/Backend/IRViewer.cpp


+ 0 - 0
lib/Backend/IRViewer.h → Lib/Backend/IRViewer.h


+ 0 - 0
lib/Backend/InductionVariable.cpp → Lib/Backend/InductionVariable.cpp


+ 0 - 0
lib/Backend/InductionVariable.h → Lib/Backend/InductionVariable.h


+ 0 - 0
lib/Backend/Inline.cpp → Lib/Backend/Inline.cpp


+ 0 - 0
lib/Backend/Inline.h → Lib/Backend/Inline.h


+ 0 - 0
lib/Backend/InlineeFrameInfo.cpp → Lib/Backend/InlineeFrameInfo.cpp


+ 0 - 0
lib/Backend/InlineeFrameInfo.h → Lib/Backend/InlineeFrameInfo.h


+ 0 - 0
lib/Backend/InliningDecider.cpp → Lib/Backend/InliningDecider.cpp


+ 0 - 0
lib/Backend/InliningDecider.h → Lib/Backend/InliningDecider.h


+ 0 - 0
lib/Backend/InliningHeuristics.cpp → Lib/Backend/InliningHeuristics.cpp


+ 0 - 0
lib/Backend/InliningHeuristics.h → Lib/Backend/InliningHeuristics.h


+ 0 - 0
lib/Backend/IntBounds.cpp → Lib/Backend/IntBounds.cpp


+ 0 - 0
lib/Backend/IntBounds.h → Lib/Backend/IntBounds.h


+ 0 - 0
lib/Backend/IntConstantBounds.h → Lib/Backend/IntConstantBounds.h


+ 0 - 0
lib/Backend/IntOverflowDoesNotMatterRange.h → Lib/Backend/IntOverflowDoesNotMatterRange.h


+ 6 - 1
lib/Backend/InterpreterThunkEmitter.cpp → Lib/Backend/InterpreterThunkEmitter.cpp

@@ -253,7 +253,12 @@ void InterpreterThunkEmitter::NewThunkBlock()
     DWORD bufferSize = BlockSize;
     DWORD thunkCount = 0;
 
-    allocation = emitBufferManager.AllocateBuffer(bufferSize, &buffer, /*readWrite*/ true);
+    allocation = emitBufferManager.AllocateBuffer(bufferSize, &buffer);
+    if (!emitBufferManager.ProtectBufferWithExecuteReadWriteForInterpreter(allocation))
+    {
+        Js::Throw::OutOfMemory();
+    }
+
     currentBuffer = buffer;
 
 #ifdef _M_X64

+ 0 - 0
lib/Backend/InterpreterThunkEmitter.h → Lib/Backend/InterpreterThunkEmitter.h


+ 0 - 0
lib/Backend/JnHelperMethod.cpp → Lib/Backend/JnHelperMethod.cpp


+ 0 - 0
lib/Backend/JnHelperMethod.h → Lib/Backend/JnHelperMethod.h


+ 0 - 0
lib/Backend/JnHelperMethodList.h → Lib/Backend/JnHelperMethodList.h


+ 0 - 0
lib/Backend/Lifetime.h → Lib/Backend/Lifetime.h


+ 0 - 0
lib/Backend/LinearScan.cpp → Lib/Backend/LinearScan.cpp


+ 0 - 0
lib/Backend/LinearScan.h → Lib/Backend/LinearScan.h


+ 0 - 0
lib/Backend/LinearScanMDShared.h → Lib/Backend/LinearScanMDShared.h


+ 0 - 17
lib/Backend/Lower.cpp → Lib/Backend/Lower.cpp

@@ -8145,14 +8145,7 @@ Lowerer::LowerStElemI(IR::Instr * instr, Js::PropertyOperationFlags flags, bool
 
     if (srcType == TyFloat64)
     {
-        // We don't support the X64 floating-point calling convention. So put this parameter on the end
-        // and save directly to the stack slot.
-#if _M_X64
-        IR::Opnd *argOpnd = IR::SymOpnd::New(m_func->m_symTable->GetArgSlotSym(5), TyFloat64, m_func);
-        m_lowererMD.CreateAssign(argOpnd, src1, instr);
-#else
         m_lowererMD.LoadDoubleHelperArgument(instr, src1);
-#endif
     }
     m_lowererMD.LoadHelperArgument(instr,
         IR::IntConstOpnd::New(static_cast<IntConstType>(flags), IRType::TyInt32, m_func, true));
@@ -10439,17 +10432,7 @@ Lowerer::GenerateHelperToArrayPushFastPath(IR::Instr * instr, IR::LabelInstr * b
         Assert(arrayHelperOpnd->GetValueType().IsLikelyNativeFloatArray());
         helperMethod = IR::HelperArray_NativeFloatPush;
 
-    //Currently, X64 floating-point calling convention is not supported. Hence store the
-    // float value explicitly in RegXMM2 (RegXMM0 and RegXMM1 will be filled with ScriptContext and Var respectively)
-#if _M_X64
-        IR::RegOpnd* regXMM2 = IR::RegOpnd::New(nullptr, (RegNum)RegXMM2, TyMachDouble, this->m_func);
-        regXMM2->m_isCallArg = true;
-        IR::Instr * movInstr = IR::Instr::New(Js::OpCode::MOVSD, regXMM2, elementHelperOpnd, this->m_func);
-        instr->InsertBefore(movInstr);
-#else
         m_lowererMD.LoadDoubleHelperArgument(instr, elementHelperOpnd);
-#endif
-
     }
     else
     {

+ 0 - 0
lib/Backend/Lower.h → Lib/Backend/Lower.h


+ 62 - 46
lib/Backend/LowerMDShared.cpp → Lib/Backend/LowerMDShared.cpp

@@ -6018,11 +6018,57 @@ LowererMD::SaveDoubleToVar(IR::RegOpnd * dstOpnd, IR::RegOpnd *opndFloat, IR::In
 #else
 
     // s1 = MOVD opndFloat
+    IR::RegOpnd *s1 = IR::RegOpnd::New(TyMachReg, m_func);
+    IR::Instr *movd = IR::Instr::New(Js::OpCode::MOVD, s1, opndFloat, m_func);
+    instrInsert->InsertBefore(movd);
+
+    if (m_func->GetJnFunction()->GetIsAsmjsMode())
+    {
+        // s1 = MOVD src
+        // tmp = NOT s1
+        // tmp = AND tmp, 0x7FF0000000000000ull
+        // test tmp, tmp
+        // je helper
+        // jmp done
+        // helper:
+        // tmp2 = AND s1, 0x000FFFFFFFFFFFFFull
+        // test tmp2, tmp2
+        // je done
+        // s1 = JavascriptNumber::k_Nan
+        // done:
+
+        IR::RegOpnd *tmp = IR::RegOpnd::New(TyMachReg, m_func);
+        IR::Instr * newInstr = IR::Instr::New(Js::OpCode::NOT, tmp, s1, m_func);
+        instrInsert->InsertBefore(newInstr);
+        LowererMD::MakeDstEquSrc1(newInstr);
+
+        newInstr = IR::Instr::New(Js::OpCode::AND, tmp, tmp, IR::AddrOpnd::New((Js::Var)0x7FF0000000000000, IR::AddrOpndKindConstantVar, m_func, true), m_func);
+        instrInsert->InsertBefore(newInstr);
+        LowererMD::Legalize(newInstr);
+
+        IR::LabelInstr* helper = Lowerer::InsertLabel(true, instrInsert);
+
+        Lowerer::InsertTestBranch(tmp, tmp, Js::OpCode::BrEq_A, helper, helper);
+
+        IR::LabelInstr* done = Lowerer::InsertLabel(isHelper, instrInsert);
+
+        Lowerer::InsertBranch(Js::OpCode::Br, done, helper);
+
+        IR::RegOpnd *tmp2 = IR::RegOpnd::New(TyMachReg, m_func);
+
+        newInstr = IR::Instr::New(Js::OpCode::AND, tmp2, s1, IR::AddrOpnd::New((Js::Var)0x000FFFFFFFFFFFFFull, IR::AddrOpndKindConstantVar, m_func, true), m_func);
+        done->InsertBefore(newInstr);
+        LowererMD::Legalize(newInstr);
+
+        Lowerer::InsertTestBranch(tmp2, tmp2, Js::OpCode::BrEq_A, done, done);
+
+        IR::Opnd * opndNaN = IR::AddrOpnd::New((Js::Var)Js::JavascriptNumber::k_Nan, IR::AddrOpndKindConstantVar, m_func, true);
+        Lowerer::InsertMove(s1, opndNaN, done);
+    }
+
     // s1 = XOR s1, FloatTag_Value
     // dst = s1
-
-    IR::RegOpnd *s1 = IR::RegOpnd::New(TyMachReg, this->m_func);
-    IR::Instr *movd = IR::Instr::New(Js::OpCode::MOVD, s1, opndFloat, this->m_func);
+    
     IR::Instr *setTag = IR::Instr::New(Js::OpCode::XOR,
                                        s1,
                                        s1,
@@ -6033,7 +6079,6 @@ LowererMD::SaveDoubleToVar(IR::RegOpnd * dstOpnd, IR::RegOpnd *opndFloat, IR::In
                                        this->m_func);
     IR::Instr *movDst = IR::Instr::New(Js::OpCode::MOV, dstOpnd, s1, this->m_func);
 
-    instrInsert->InsertBefore(movd);
     instrInsert->InsertBefore(setTag);
     instrInsert->InsertBefore(movDst);
     LowererMD::Legalize(setTag);
@@ -7752,6 +7797,11 @@ LowererMD::InsertConvertFloat64ToInt32(const RoundMode roundMode, IR::Opnd *cons
 void
 LowererMD::EmitFloatToInt(IR::Opnd *dst, IR::Opnd *src, IR::Instr *instrInsert)
 {
+#ifdef _M_IX86
+    // We should only generate this if sse2 is available
+    Assert(AutoSystemInfo::Data.SSE2Available());
+#endif
+
     IR::LabelInstr *labelDone = IR::LabelInstr::New(Js::OpCode::Label, this->m_func);
     IR::LabelInstr *labelHelper = IR::LabelInstr::New(Js::OpCode::Label, this->m_func, true);
     IR::Instr *instr;
@@ -7761,37 +7811,20 @@ LowererMD::EmitFloatToInt(IR::Opnd *dst, IR::Opnd *src, IR::Instr *instrInsert)
     // $Helper
     instrInsert->InsertBefore(labelHelper);
 
-#ifdef _M_X64
-    // On x64, we can simply pass the var, this way we don't have to worry having to
-    // pass a double in a param reg
-
-    // s1 = MOVD src
-    IR::RegOpnd *s1 = IR::RegOpnd::New(TyMachReg, this->m_func);
-    instr = IR::Instr::New(Js::OpCode::MOVD, s1, src, this->m_func);
-    instrInsert->InsertBefore(instr);
-
-    // s1 = XOR s1, FloatTag_Value
-    instr = IR::Instr::New(Js::OpCode::XOR, s1, s1,
-                           IR::AddrOpnd::New((Js::Var)Js::FloatTag_Value, IR::AddrOpndKindConstantVar, this->m_func, /* dontEncode = */ true),
-                           this->m_func);
-    instrInsert->InsertBefore(instr);
-    LowererMD::Legalize(instr);
-
-    // dst = ToInt32_Full(s1, scriptContext);
-    m_lowerer->LoadScriptContext(instrInsert);
-    LoadHelperArgument(instrInsert, s1);
+    IR::Opnd * arg = src;
+    if (src->IsFloat32())
+    {
+        arg = IR::RegOpnd::New(TyFloat64, m_func);
 
-    instr = IR::Instr::New(Js::OpCode::CALL, dst, this->m_func);
-    instrInsert->InsertBefore(instr);
-    this->ChangeToHelperCall(instr, IR::HelperConv_ToInt32_Full);
-#else
+        EmitFloat32ToFloat64(arg, src, instrInsert);
+    }
     // dst = ToInt32Core(src);
-    LoadDoubleHelperArgument(instrInsert, src);
+    LoadDoubleHelperArgument(instrInsert, arg);
 
     instr = IR::Instr::New(Js::OpCode::CALL, dst, this->m_func);
     instrInsert->InsertBefore(instr);
     this->ChangeToHelperCall(instr, IR::HelperConv_ToInt32Core);
-#endif
+
     // $Done
     instrInsert->InsertBefore(labelDone);
 }
@@ -9116,28 +9149,11 @@ IR::Opnd* LowererMD::IsOpndNegZero(IR::Opnd* opnd, IR::Instr* instr)
 {
     IR::Opnd * isNegZero = IR::RegOpnd::New(TyInt32, this->m_func);
 
-#if defined(_M_IX86)
     LoadDoubleHelperArgument(instr, opnd);
     IR::Instr * helperCallInstr = IR::Instr::New(Js::OpCode::CALL, isNegZero, this->m_func);
     instr->InsertBefore(helperCallInstr);
     this->ChangeToHelperCall(helperCallInstr, IR::HelperIsNegZero);
 
-#else
-    IR::RegOpnd* regXMM0 = IR::RegOpnd::New(nullptr, (RegNum)FIRST_FLOAT_ARG_REG, TyMachDouble, this->m_func);
-    regXMM0->m_isCallArg = true;
-    IR::Instr * movInstr = IR::Instr::New(Js::OpCode::MOVSD, regXMM0, opnd, this->m_func);
-    instr->InsertBefore(movInstr);
-
-    IR::RegOpnd* reg1 = IR::RegOpnd::New(TyMachReg, this->m_func);
-    IR::AddrOpnd* helperAddr = IR::AddrOpnd::New((Js::Var)IR::GetMethodOriginalAddress(IR::HelperIsNegZero), IR::AddrOpndKind::AddrOpndKindDynamicMisc, this->m_func);
-    IR::Instr* mov = IR::Instr::New(Js::OpCode::MOV, reg1, helperAddr, this->m_func);
-    instr->InsertBefore(mov);
-
-    IR::Instr *helperCallInstr = IR::Instr::New(Js::OpCode::CALL, isNegZero, reg1, this->m_func);
-    instr->InsertBefore(helperCallInstr);
-
-#endif
-
     return isNegZero;
 }
 

+ 0 - 0
lib/Backend/LowerMDShared.h → Lib/Backend/LowerMDShared.h


+ 0 - 0
lib/Backend/LowerMDSharedSimd128.cpp → Lib/Backend/LowerMDSharedSimd128.cpp


+ 0 - 0
lib/Backend/NativeCodeData.cpp → Lib/Backend/NativeCodeData.cpp


+ 0 - 0
lib/Backend/NativeCodeData.h → Lib/Backend/NativeCodeData.h


+ 0 - 0
lib/Backend/NativeCodeGenerator.cpp → Lib/Backend/NativeCodeGenerator.cpp


+ 0 - 0
lib/Backend/NativeCodeGenerator.h → Lib/Backend/NativeCodeGenerator.h


+ 0 - 0
lib/Backend/Opnd.cpp → Lib/Backend/Opnd.cpp


+ 0 - 0
lib/Backend/Opnd.h → Lib/Backend/Opnd.h


+ 0 - 0
lib/Backend/Opnd.inl → Lib/Backend/Opnd.inl


+ 0 - 0
lib/Backend/PDataManager.cpp → Lib/Backend/PDataManager.cpp


+ 0 - 0
lib/Backend/PDataManager.h → Lib/Backend/PDataManager.h


+ 0 - 0
lib/Backend/Peeps.cpp → Lib/Backend/Peeps.cpp


+ 0 - 0
lib/Backend/Peeps.h → Lib/Backend/Peeps.h


+ 0 - 0
lib/Backend/PreLowerPeeps.cpp → Lib/Backend/PreLowerPeeps.cpp


+ 0 - 0
lib/Backend/PrologEncoder.cpp → Lib/Backend/PrologEncoder.cpp


+ 0 - 0
lib/Backend/PrologEncoder.h → Lib/Backend/PrologEncoder.h


Some files were not shown because too many files changed in this diff