2017-08-02 12 views
9

मैं कोड के इस टुकड़े कर दिया है:RyuJIT सी # गलत योग परिणाम/साथ अनुकूलन

private void AnswerToCe(int currentBlock, int totalBlock = 0) 
{ 
    byte[] bufferToSend; 
    byte[] macDst = mac; 
    byte[] macSrc = ConnectionManager.SInstance.GetMyMAC(); 
    byte[] ethType; 
    byte[] header; 

    if (Function == FlashFunction.UPLOAD_APPL || Function == FlashFunction.UPLOAD_BITSTREAM) 
    { 
     ethType = BitConverter.GetBytes((ushort)EthType.ETH_TYPE_UPLOAD); 
     ethType = new byte[] { ethType[1], ethType[0] }; 
     header = Header.GetBytes((ushort)binaryBlocks.Count, (ushort)(currentBlock + 1), (ushort)binaryBlocks[currentBlock].Length); 
     int index = 0; 
     bufferToSend = new byte[macDst.Length + macSrc.Length + ethType.Length + header.Length + binaryBlocks[currentBlock].Length]; 
     Array.Copy(macDst, 0, bufferToSend, index, macDst.Length); 
     index += macDst.Length; 
     Array.Copy(macSrc, 0, bufferToSend, index, macSrc.Length); 
     index += macSrc.Length; 
     Logger.SInstance.Write(index.ToString(), "test index pre"); 
     Array.Copy(ethType, 0, bufferToSend, index, ethType.Length); 
     index += ethType.Length; 
     Logger.SInstance.Write(index.ToString(), "test index post"); 
     Array.Copy(header, 0, bufferToSend, index, header.Length); 
     index += header.Length; 
     Array.Copy(binaryBlocks[currentBlock], 0, bufferToSend, index, binaryBlocks[currentBlock].Length); 
    } 

अगर मैं निर्माण डीबग मोड में सब कुछ अपने आवेदन ठीक है, test index pre प्रिंट 12 और test index post प्रिंट 14. रिलीज में एक ही Optimize code के साथ मोड अनचेक। अगर मैं Optimize code के साथ परीक्षण करता हूं test index post 14 के बजाय 18 प्रिंट करता है
उसी परिणाम यदि मैं index += 2; के साथ बदलता हूं तो वही परिणाम। लगता है कि केवल index++;index++; काम कर रहा है।
मैंने इस कोड को एक खाली एप्लिकेशन में करने की कोशिश की और रकम ठीक है।
ऐप मल्टीथ्रेडिंग है लेकिन यहां कोई सहमति नहीं है।
डीएलएल से डीकंपील्ड कोड ठीक लगता है।
कोई विचार क्यों ऐसा होता है?

संपादित करें: केवल तब होता है जब ऐप x64 के लिए संकलित किया जाता है। x86 ठीक है।
संपादित करें 3: निर्माण env से कुछ जानकारी:
दृश्य स्टूडियो 15.0.0-RTW + 26228.4
ढांचे 4.7.02053
ढांचा 4.6.2 और 4.7 पर इस मुद्दे को गति प्रदान कर सकते हैं। अन्य ढांचे का परीक्षण नहीं किया जाता है।
संपादित करें 5: new, smaller example project। कोई निर्भरता की आवश्यकता नहीं है।
संपादित करें 6: परीक्षण परियोजना here के डिस्सेप्लर। (इसे यहां पोस्ट करने में बहुत लंबा)

+0

"ऐप मल्टीथ्रेडिंग है लेकिन यहां कोई सहमति नहीं है।" कहना मुश्किल है क्योंकि यह केवल आपके कोड का हिस्सा है और यह इस फ़ंक्शन के बाहर से कुछ चर का उपयोग करता है। –

+0

https://msdn.microsoft.com/en-us/library/c151dt3s.aspx – StefanE

+0

@ PawełŁukasik ब्रेकपॉइंट्स केवल एक बार मारा जाता है। सूचकांक चर बाहरी नहीं है। – rmbq

उत्तर

0

यह RyuJIT में पहले से ही एक रिपोर्ट की गई बग थी, अधिक जानकारी here। जल्द ही एक हॉटफिक्स में तय किया जाएगा।

संबंधित मुद्दे