未验证 提交 99e4fdac 编写于 作者: A Aleksey Kliger (λgeek) 提交者: GitHub

[mono] Remove some empty files and dead code (#48871)

* remote empty files

* [mono] remove dead code

* [mini] Delete genmdesc.c and *.sh

We use the Python genmdesc now.  The test shell scripts are dead too
上级 5b4477ac
......@@ -137,9 +137,7 @@ set(metadata_common_sources
mono-perfcounters.h
mono-perfcounters-def.h
mono-ptr-array.h
mono-route.c
monitor.h
number-ms.h
object.c
object-forward.h
object-internals.h
......
/**
* \file
* Read the network routing tables using sysctl(3) calls
* Required for Unix-like systems that don't have Linux's /proc/net/route
*
* Author:
* Ben Woods (woodsb02@gmail.com)
*/
#include "config.h"
extern const char mono_route_empty_file_no_warning;
const char mono_route_empty_file_no_warning = 0;
/**
* \file
*/
#ifndef __MONO_NUMBER_MS_H__
#define __MONO_NUMBER_MS_H__
#include <glib.h>
// Double floating point Bias
#define MONO_DOUBLE_BIAS 1022
// Structure to access an encoded double floating point
typedef struct {
#if G_BYTE_ORDER == G_BIG_ENDIAN
guint sign : 1;
guint exp : 11;
guint mantHi : 20;
guint mantLo : 32;
#define MONO_INIT_DOUBLE(sign, exp, mantHi, mantLo) { sign, exp, mantHi, mantLo }
#else // BIGENDIAN
guint mantLo : 32;
guint mantHi : 20;
guint exp : 11;
guint sign : 1;
#define MONO_INIT_DOUBLE(sign, exp, mantHi, mantLo) { mantLo, mantHi, exp, sign }
#endif
} MonoDouble;
typedef union {
MonoDouble s;
gdouble d;
} MonoDouble_double;
#endif
......@@ -26,7 +26,6 @@
#include <math.h>
#include "number-ms.h"
#include "utils/mono-compiler.h"
#include "utils/mono-math.h"
#include "icalls.h"
......
// Every library must have at least one source file.
/**
* \file
* Generates the machine description
*
* Authors:
* Paolo Molaro (lupus@ximian.com)
*
* (C) 2003 Ximian, Inc.
*/
#include "mini.h"
#include <ctype.h>
#include <string.h>
#include <mono/metadata/opcodes.h>
#define MINI_OP(a,b,dest,src1,src2) b,
#define MINI_OP3(a,b,dest,src1,src2,src3) b,
/* keep in sync with the enum in mini.h */
static const char* const
opnames[] = {
#include "mini-ops.h"
};
#undef MINI_OP
#undef MINI_OP3
/*
* Duplicate this from helpers.c, so the opcode name array can be omitted when
* DISABLE_JIT is set.
*/
static const char*
inst_name (int op) {
if (op >= OP_LOAD && op <= OP_LAST)
return opnames [op - OP_LOAD];
if (op < OP_LOAD)
return mono_opcode_name (op);
g_error ("unknown opcode name for %d", op);
return NULL;
}
typedef struct {
int num;
const char *name;
char *desc;
char *comment;
MonoInstSpec spec;
} OpDesc;
static int nacl = 0;
static GHashTable *table;
static GHashTable *template_table;
#define eat_whitespace(s) while (*(s) && isspace (*(s))) s++;
// Per spec isalnum() expects input in the range 0-255
// and can misbehave if you pass in a signed char.
static int
isalnum_char(char c)
{
return isalnum ((unsigned char)c);
}
static int
load_file (const char *name) {
FILE *f;
char buf [256];
char *str, *p;
int line;
OpDesc *desc;
GString *comment;
if (!(f = fopen (name, "r")))
g_error ("Cannot open file '%s'", name);
comment = g_string_new ("");
/*
* The format of the lines are:
* # comment
* opcode: [dest:format] [src1:format] [src2:format] [flags:format] [clob:format]
* [cost:num] [res:format] [delay:num] [len:num] [nacl:num]
* format is a single letter that depends on the field
* NOTE: no space between the field name and the ':'
*
* len: maximum instruction length
*/
line = 0;
while ((str = fgets (buf, sizeof (buf), f))) {
gboolean is_template = FALSE;
gboolean nacl_length_set = FALSE;
++line;
eat_whitespace (str);
if (!str [0])
continue;
if (str [0] == '#') {
g_string_append (comment, str);
continue;
}
p = strchr (str, '#');
if (p)
*p = 0;
p = strchr (str, ':');
if (!p)
g_error ("Invalid format at line %d in %s\n", line, name);
*p++ = 0;
eat_whitespace (p);
if (strcmp (str, "template") == 0) {
is_template = TRUE;
desc = g_new0 (OpDesc, 1);
} else {
desc = (OpDesc *)g_hash_table_lookup (table, str);
if (!desc)
g_error ("Invalid opcode '%s' at line %d in %s\n", str, line, name);
if (desc->desc)
g_error ("Duplicated opcode %s at line %d in %s\n", str, line, name);
}
desc->desc = g_strdup (p);
desc->comment = g_strdup (comment->str);
g_string_truncate (comment, 0);
while (*p) {
if (strncmp (p, "dest:", 5) == 0) {
desc->spec.dest = p [5];
p += 6;
} else if (strncmp (p, "src1:", 5) == 0) {
desc->spec.src1 = p [5];
p += 6;
} else if (strncmp (p, "src2:", 5) == 0) {
desc->spec.src2 = p [5];
p += 6;
} else if (strncmp (p, "src3:", 5) == 0) {
desc->spec.src3 = p [5];
p += 6;
} else if (strncmp (p, "clob:", 5) == 0) {
desc->spec.clob = p [5];
p += 6;
/* Currently unused fields
} else if (strncmp (p, "cost:", 5) == 0) {
desc->spec.cost = p [5];
p += 6;
} else if (strncmp (p, "res:", 4) == 0) {
desc->spec.res = p [4];
p += 5;
} else if (strncmp (p, "flags:", 6) == 0) {
desc->spec.flags = p [6];
p += 7;
} else if (strncmp (p, "delay:", 6) == 0) {
desc->spec.delay = p [6];
p += 7;
*/
} else if (strncmp (p, "len:", 4) == 0) {
unsigned long size;
char* endptr;
p += 4;
size = strtoul (p, &endptr, 10);
if (size == 0 && p == endptr)
g_error ("Invalid length '%s' at line %d in %s\n", p, line, name);
p = endptr;
if (!nacl_length_set) {
desc->spec.len = size;
}
} else if (strncmp (p, "nacl:", 5) == 0) {
unsigned long size;
p += 5;
size = strtoul (p, &p, 10);
if (nacl) {
desc->spec.len = size;
nacl_length_set = TRUE;
}
} else if (strncmp (p, "template:", 9) == 0) {
char *tname;
int i;
OpDesc *tdesc;
p += 9;
tname = p;
while (*p && isalnum_char (*p)) ++p;
*p++ = 0;
tdesc = (OpDesc *)g_hash_table_lookup (template_table, tname);
if (!tdesc)
g_error ("Invalid template name %s at '%s' at line %d in %s\n", tname, p, line, name);
for (i = 0; i < MONO_INST_MAX; ++i) {
if (desc->spec.bytes [i])
g_error ("The template overrides any previous value set at line %d in %s\n", line, name);
}
desc->spec = tdesc->spec;
} else if (strncmp (p, "name:", 5) == 0) {
char *tname;
if (!is_template)
g_error ("name tag only valid in templates at '%s' at line %d in %s\n", p, line, name);
if (desc->name)
g_error ("Duplicated name tag in template %s at '%s' at line %d in %s\n", desc->name, p, line, name);
p += 5;
tname = p;
while (*p && isalnum_char (*p)) ++p;
*p++ = 0;
if (g_hash_table_lookup (template_table, tname))
g_error ("Duplicated template %s at line %d in %s\n", tname, line, name);
desc->name = g_strdup (tname);
g_hash_table_insert (template_table, (void*)desc->name, desc);
} else {
g_error ("Parse error at '%s' at line %d in %s\n", p, line, name);
}
eat_whitespace (p);
}
if (is_template && !desc->name)
g_error ("Template without name at line %d in %s\n", line, name);
}
g_string_free (comment,TRUE);
fclose (f);
return 0;
}
static OpDesc *opcodes = NULL;
static void
init_table (void) {
int i;
OpDesc *desc;
template_table = g_hash_table_new (g_str_hash, g_str_equal);
table = g_hash_table_new (g_str_hash, g_str_equal);
opcodes = g_new0 (OpDesc, OP_LAST);
for (i = OP_LOAD; i < OP_LAST; ++i) {
desc = opcodes + i;
desc->num = i;
desc->name = inst_name (i);
g_hash_table_insert (table, (char *)desc->name, desc);
}
}
static void
output_char (FILE *f, char c) {
if (isalnum_char (c))
fprintf (f, " '%c'", c);
else if (c < 9)
fprintf (f, " %u", (guint8)c);
else
fprintf (f, "0x%02X", (guint8)c);
}
static void
build_table (const char *fname, const char *name) {
FILE *f;
int i, j, idx;
OpDesc *desc;
GString *idx_array = g_string_new ("");
/* use this to remove duplicates */
GHashTable *desc_ht = g_hash_table_new (g_str_hash, g_str_equal);
if (!(f = fopen (fname, "w")))
g_error ("Cannot open file '%s'", fname);
fprintf (f, "/* File automatically generated by genmdesc, don't change */\n\n");
fprintf (f, "const MonoInstSpec mono_%s [ ] = {\n {{", name);
for (j = 0; j < MONO_INST_MAX; ++j)
fprintf (f, "0%s", (j < MONO_INST_MAX - 1) ? ", " : "");
fprintf (f, "}}, // null entry\n");
idx = 1;
g_string_append_printf (idx_array, "const guint16 mono_%s_idx [] = {\n", name);
int row = 40;
for (i = OP_LOAD; i < OP_LAST; ++i) {
if (row == 40) {
fprintf (f, "// dest src1 src2 src3 len clob\n");
fprintf (f, "// ----- ----- ----- ---- ----- -----\n");
row = 0;
} else
row += 1;
desc = opcodes + i;
if (!desc->desc)
g_string_append_printf (idx_array, " 0, // %s\n", desc->name ? desc->name : "");
else {
fprintf (f, " {{");
for (j = 0; j < MONO_INST_MAX; ++j) {
output_char (f, desc->spec.bytes [j]);
if (j < MONO_INST_MAX - 1)
fprintf (f, ", ");
}
fprintf (f, " }}, // %s\n", desc->name);
g_string_append_printf (idx_array, " %d, // %s\n", idx, desc->name);
++idx;
}
}
fprintf (f, "};\n\n");
fprintf (f, "%s};\n\n", idx_array->str);
fclose (f);
g_string_free (idx_array, TRUE);
g_hash_table_destroy (desc_ht);
}
static void
dump (void) {
int i;
OpDesc *desc;
for (i = 0; i < MONO_CEE_LAST; ++i) {
desc = opcodes + i;
if (desc->comment)
g_print ("%s", desc->comment);
if (!desc->desc)
g_print ("%s:\n", desc->name);
else {
g_print ("%s: %s", desc->name, desc->desc);
if (!strchr (desc->desc, '\n'))
g_print ("\n");
}
}
for (i = OP_LOAD; i < OP_LAST; ++i) {
desc = opcodes + i;
if (!desc->desc)
g_print ("%s:\n", desc->name);
else {
g_print ("%s: %s", desc->name, desc->desc);
if (!strchr (desc->desc, '\n'))
g_print ("\n");
}
}
}
/*
* TODO: output the table (possibly merged), in the input format
*/
int
main (int argc, char* argv [])
{
init_table ();
if (argc == 2) {
/* useful to get a new file when some opcodes are added: looses the comments, though */
load_file (argv [1]);
dump ();
} else if (argc < 4) {
g_print ("Usage: genmdesc arguments\n");
g_print ("\tgenmdesc desc Output to stdout the description file.\n");
g_print ("\tgenmdesc [--nacl] output name desc [desc1...]\n"
" Write to output the description in a table named 'name',\n"
" use --nacl to generate Google NativeClient code\n");
return 1;
} else {
int i = 3;
if (strcmp (argv [1], "--nacl") == 0) {
nacl = 1;
i++;
}
for (; i < argc; ++i)
load_file (argv [i]);
build_table (argv [1 + nacl], argv [2 + nacl]);
}
return 0;
}
#!/bin/bash -e
DEFAULT_PROFILE=$1
TEST_FILE=$2
USE_AOT=$3
TMP_FILE_PREFIX=$(basename $0).tmp
BASEDIR=$(dirname $0)
case "$(uname -s)" in
CYGWIN*)
PLATFORM_PATH_SEPARATOR=';'
PLATFORM_AOT_ARGUMENT=--aot=asmonly
;;
*)
PLATFORM_PATH_SEPARATOR=':'
PLATFORM_AOT_ARGUMENT=--aot
;;
esac
MONO_PATH=$BASEDIR/../../mcs/class/lib/$DEFAULT_PROFILE$PLATFORM_PATH_SEPARATOR$BASEDIR
RUNTIME=$BASEDIR/../../runtime/mono-wrapper
trap "rm -rf ${TMP_FILE_PREFIX}*" EXIT
tmp_file () {
mktemp ./${TMP_FILE_PREFIX}XXXXXX
}
clean_aot () {
rm -rf *.exe.so *.exe.dylib *.exe.dylib.dSYM *.exe.dll *.exe.s
}
# The test compares the generated native code size between a compilation with and without seq points.
# In some architectures ie:amd64 when possible 32bit instructions and registers are used instead of 64bit ones.
# Using MONO_DEBUG=single-imm-size avoids 32bit optimizations thus mantaining the native code size between compilations.
get_methods () {
if [ -z $4 ]; then
MONO_PATH=$1 $2 -v --compile-all=1 $3 | grep '^Method .*code length' | sed 's/emitted[^()]*//' | sort
return ${PIPESTATUS[0]}
else
clean_aot
MONO_PATH=$1 $2 -v $PLATFORM_AOT_ARGUMENT $3 | grep '^Method .*code length' | sed 's/emitted[^()]*//' | sort
return ${PIPESTATUS[0]}
fi
}
get_method () {
if [ -z $5 ]; then
MONO_VERBOSE_METHOD="$4" MONO_PATH=$1 $2 --compile-all=1 $3 | sed 's/0x[0-9a-fA-F]*/0x0/g'
return ${PIPESTATUS[0]}
else
clean_aot
MONO_VERBOSE_METHOD="$4" MONO_PATH=$1 $2 $PLATFORM_AOT_ARGUMENT $3 | sed 's/0x[0-9a-fA-F]*/0x0/g'
return ${PIPESTATUS[0]}
fi
}
diff_methods () {
TMP_FILE1=$(tmp_file)
TMP_FILE2=$(tmp_file)
echo "$(MONO_DEBUG=no-compact-seq-points,single-imm-size get_methods $1 $2 $3 $4 || echo Non-zero exit code for file1: $?)" >$TMP_FILE1
echo "$(MONO_DEBUG=single-imm-size get_methods $1 $2 $3 $4 || echo Non-zero exit code for file2: $?)" >$TMP_FILE2
diff $TMP_FILE1 $TMP_FILE2
}
diff_method () {
TMP_FILE1=$(tmp_file)
TMP_FILE2=$(tmp_file)
echo "$(MONO_DEBUG=no-compact-seq-points,single-imm-size get_method $1 $2 $3 $4 $5)" >$TMP_FILE1
echo "$(MONO_DEBUG=single-imm-size get_method $1 $2 $3 $4 $5 | grep -Ev il_seq_point)" >$TMP_FILE2
sdiff -w 150 $TMP_FILE1 $TMP_FILE2
}
get_method_name () {
echo $1 | sed -E 's/.*Method (\([^)]*\) )?([^ ]*).*/\2/g'
}
get_method_length () {
echo $1 | sed 's/.*code length \([0-9]*\).*/\1/'
}
if [ -z $USE_AOT ]; then
echo "Checking unintended native code changes in $TEST_FILE without AOT"
else
echo "Checking unintended native code changes in $TEST_FILE with AOT"
fi
TMP_FILE=$(tmp_file)
echo "$(diff_methods $MONO_PATH $RUNTIME $TEST_FILE $USE_AOT)" > $TMP_FILE
CHANGES=0
FAIL=0
METHOD=""
MIN_SIZE=10000
while read line; do
if [ "$line" != "" ]; then
echo $line
if [[ "$line" == *"Non-zero exit code"* ]]; then
FAIL=1
elif [[ ${line:0:1} == "<" ]]; then
CHANGES=$((CHANGES+1))
SIZE=$(get_method_length "$line")
if [[ SIZE -lt MIN_SIZE ]]; then
MIN_SIZE=$SIZE
METHOD="$line"
fi
fi
fi
done < $TMP_FILE
TESTRESULT_FILE=TestResult-op_il_seq_point.tmp
echo -n " <test-case name=\"MonoTests.op_il_seq_point.${TEST_FILE}${USE_AOT}\" executed=\"True\" time=\"0\" asserts=\"0\" success=\"" >> $TESTRESULT_FILE
if [ $FAIL != 0 ]
then
echo "False\">" >> $TESTRESULT_FILE
echo " <failure>" >> $TESTRESULT_FILE
echo -n " <message><![CDATA[" >> $TESTRESULT_FILE
echo "Mono failed on $TEST_FILE" >> $TESTRESULT_FILE
echo "]]></message>" >> $TESTRESULT_FILE
echo " <stack-trace>" >> $TESTRESULT_FILE
echo " </stack-trace>" >> $TESTRESULT_FILE
echo " </failure>" >> $TESTRESULT_FILE
echo " </test-case>" >> $TESTRESULT_FILE
exit 1
elif [ $CHANGES != 0 ]
then
METHOD_NAME=$(get_method_name "$METHOD")
echo "False\">" >> $TESTRESULT_FILE
echo " <failure>" >> $TESTRESULT_FILE
echo -n " <message><![CDATA[" >> $TESTRESULT_FILE
echo "Detected OP_IL_SEQ_POINT incompatibility on $TEST_FILE" >> $TESTRESULT_FILE
echo " $CHANGES methods differ when sequence points are enabled." >> $TESTRESULT_FILE
echo ' This is probably caused by a runtime optimization that is not handling OP_IL_SEQ_POINT' >> $TESTRESULT_FILE
echo '' >> $TESTRESULT_FILE
echo "Diff $METHOD_NAME" >> $TESTRESULT_FILE
echo "Without IL_OP_SEQ_POINT With IL_OP_SEQ_POINT" >> $TESTRESULT_FILE
echo -n "$(diff_method $MONO_PATH $RUNTIME $TEST_FILE $METHOD_NAME $USE_AOT)" >> $TESTRESULT_FILE
echo "]]></message>" >> $TESTRESULT_FILE
echo " <stack-trace>" >> $TESTRESULT_FILE
echo " </stack-trace>" >> $TESTRESULT_FILE
echo " </failure>" >> $TESTRESULT_FILE
echo " </test-case>" >> $TESTRESULT_FILE
echo ''
echo "Detected OP_IL_SEQ_POINT incompatibility on $TEST_FILE"
echo " $CHANGES methods differ when sequence points are enabled."
echo ' This is probably caused by a runtime optimization that is not handling OP_IL_SEQ_POINT'
echo ''
echo "Diff $METHOD_NAME"
echo "Without IL_OP_SEQ_POINT With IL_OP_SEQ_POINT"
echo "$(diff_method $MONO_PATH $RUNTIME $TEST_FILE $METHOD_NAME $USE_AOT)"
exit 1
else
echo "True\" />" >> $TESTRESULT_FILE
fi
#!/bin/sh -e
TESTRESULT_FILE=TestResult-op_il_seq_point.tmp
TOTAL=$(grep -c "<test-case" $TESTRESULT_FILE || true)
FAILURES=$(grep -c "<failure>" $TESTRESULT_FILE || true)
if [ "$FAILURES" -eq "0" ] && [ "$TOTAL" -ne "0" ]
then
PASS="True"
else
PASS="False"
fi
MYLOCALE=$(echo $LANG | cut -f1 -d'.')
MYUNAME=$(uname -r)
MYHOSTNAME=$(hostname -s)
MYFQDN=$(hostname -f)
MYDATE=$(date +%F)
MYTIME=$(date +%T)
echo " </results>" >> $TESTRESULT_FILE
echo " </test-suite>" >> $TESTRESULT_FILE
echo " </results>" >> $TESTRESULT_FILE
echo " </test-suite>" >> $TESTRESULT_FILE
echo " </results>" >> $TESTRESULT_FILE
echo " </test-suite>" >> $TESTRESULT_FILE
echo "</test-results>" >> $TESTRESULT_FILE
echo "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>" > $TESTRESULT_FILE.header
echo "<!--This file represents the results of running a test suite-->" >> $TESTRESULT_FILE.header
echo "<test-results name=\"regression-tests.dummy\" total=\"${TOTAL}\" failures=\"${FAILURES}\" not-run=\"0\" date=\"${MYDATE}\" time=\"${MYTIME}\">" >> $TESTRESULT_FILE.header
echo " <environment nunit-version=\"2.4.8.0\" clr-version=\"4.0.30319.17020\" os-version=\"Unix ${MYUNAME}\" platform=\"Unix\" cwd=\"${PWD}\" machine-name=\"${MYHOSTNAME}\" user=\"${USER}\" user-domain=\"${MYFQDN}\" />" >> $TESTRESULT_FILE.header
echo " <culture-info current-culture=\"${MYLOCALE}\" current-uiculture=\"${MYLOCALE}\" />" >> $TESTRESULT_FILE.header
echo " <test-suite name=\"op_il_seq_point-tests.dummy\" success=\"${PASS}\" time=\"0\" asserts=\"0\">" >> $TESTRESULT_FILE.header
echo " <results>" >> $TESTRESULT_FILE.header
echo " <test-suite name=\"MonoTests\" success=\"${PASS}\" time=\"0\" asserts=\"0\">" >> $TESTRESULT_FILE.header
echo " <results>" >> $TESTRESULT_FILE.header
echo " <test-suite name=\"op_il_seq_point\" success=\"${PASS}\" time=\"0\" asserts=\"0\">" >> $TESTRESULT_FILE.header
echo " <results>" >> $TESTRESULT_FILE.header
cat $TESTRESULT_FILE.header $TESTRESULT_FILE > $(basename $TESTRESULT_FILE .tmp).xml
rm -f $TESTRESULT_FILE.header $TESTRESULT_FILE
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册