6 TMP_FILE_PREFIX=$(basename $0).tmp
9 MONO_PATH=$BASEDIR/../../mcs/class/lib/net_4_x:$BASEDIR
10 RUNTIME=$BASEDIR/../../runtime/mono-wrapper
12 trap "rm -rf ${TMP_FILE_PREFIX}*" EXIT
15 mktemp ./${TMP_FILE_PREFIX}XXXX
19 rm -rf *.exe..so *.exe.dylib *.exe.dylib.dSYM
22 # The test compares the generated native code size between a compilation with and without seq points.
23 # In some architectures ie:amd64 when possible 32bit instructions and registers are used instead of 64bit ones.
24 # Using MONO_DEBUG=single-imm-size avoids 32bit optimizations thus mantaining the native code size between compilations.
28 MONO_PATH=$1 $2 -v --compile-all=1 $3 | grep '^Method .*code length' | sed 's/emitted[^()]*//' | sort
31 MONO_PATH=$1 $2 -v --aot $3 | grep '^Method .*code length' | sed 's/emitted[^()]*//' | sort
37 MONO_VERBOSE_METHOD="$4" MONO_PATH=$1 $2 --compile-all=1 $3 | sed 's/0x[0-9a-fA-F]*/0x0/g'
40 MONO_VERBOSE_METHOD="$4" MONO_PATH=$1 $2 --aot $3 | sed 's/0x[0-9a-fA-F]*/0x0/g'
46 echo "$(MONO_DEBUG=single-imm-size get_methods $1 $2 $3 $4)" >$TMP_FILE
47 diff <(cat $TMP_FILE) <(echo "$(MONO_DEBUG=gen-compact-seq-points,single-imm-size get_methods $1 $2 $3 $4)")
52 echo "$(MONO_DEBUG=single-imm-size get_method $1 $2 $3 $4 $5)" >$TMP_FILE
53 sdiff -w 150 <(cat $TMP_FILE) <(echo "$(MONO_DEBUG=gen-compact-seq-points,single-imm-size get_method $1 $2 $3 $4 $5 | grep -Ev il_seq_point)")
57 echo $1 | sed -E 's/.*Method (\([^)]*\) )?([^ ]*).*/\2/g'
60 get_method_length () {
61 echo $1 | sed 's/.*code length \([0-9]*\).*/\1/'
64 if [ -z $USE_AOT ]; then
65 echo "Checking unintended native code changes in $TEST_FILE without AOT"
67 echo "Checking unintended native code changes in $TEST_FILE with AOT"
72 echo "$(diff_methods $MONO_PATH $RUNTIME $TEST_FILE $USE_AOT)" > $TMP_FILE
79 if [ "$line" != "" ]; then
81 if [[ ${line:0:1} == "<" ]]; then
82 CHANGES=$((CHANGES+1))
83 SIZE=$(get_method_length "$line")
84 if [[ SIZE -lt MIN_SIZE ]]; then
92 echo -n " <test-case name=\"MonoTests.op_il_seq_point.${TEST_FILE}${USE_AOT}\" executed=\"True\" time=\"0\" asserts=\"0\" success=\"" >> TestResults_op_il_seq_point.xml
96 METHOD_NAME=$(get_method_name "$METHOD")
98 echo "False\">" >> TestResults_op_il_seq_point.xml
99 echo " <failure>" >> TestResults_op_il_seq_point.xml
100 echo -n " <message><![CDATA[" >> TestResults_op_il_seq_point.xml
101 echo "Detected OP_IL_SEQ_POINT incompatibility on $TEST_FILE" >> TestResults_op_il_seq_point.xml
102 echo " $CHANGES methods differ when sequence points are enabled." >> TestResults_op_il_seq_point.xml
103 echo ' This is probably caused by a runtime optimization that is not handling OP_IL_SEQ_POINT' >> TestResults_op_il_seq_point.xml
104 echo '' >> TestResults_op_il_seq_point.xml
105 echo "Diff $METHOD_NAME" >> TestResults_op_il_seq_point.xml
106 echo "Without IL_OP_SEQ_POINT With IL_OP_SEQ_POINT" >> TestResults_op_il_seq_point.xml
107 echo -n "$(diff_method $MONO_PATH $RUNTIME $TEST_FILE $METHOD_NAME $USE_AOT)" >> TestResults_op_il_seq_point.xml
108 echo "]]></message>" >> TestResults_op_il_seq_point.xml
109 echo " <stack-trace>" >> TestResults_op_il_seq_point.xml
110 echo " </stack-trace>" >> TestResults_op_il_seq_point.xml
111 echo " </failure>" >> TestResults_op_il_seq_point.xml
112 echo " </test-case>" >> TestResults_op_il_seq_point.xml
115 echo "Detected OP_IL_SEQ_POINT incompatibility on $TEST_FILE"
116 echo " $CHANGES methods differ when sequence points are enabled."
117 echo ' This is probably caused by a runtime optimization that is not handling OP_IL_SEQ_POINT'
120 echo "Diff $METHOD_NAME"
121 echo "Without IL_OP_SEQ_POINT With IL_OP_SEQ_POINT"
122 echo "$(diff_method $MONO_PATH $RUNTIME $TEST_FILE $METHOD_NAME $USE_AOT)"
125 echo "True\" />" >> TestResults_op_il_seq_point.xml