-/*
- * abcremoval.h: Array bounds check removal
+/**
+ * \file
+ * Array bounds check removal
*
* Author:
* Massimiliano Mantione (massi@ximian.com)
* delta: the delta (can be zero)
*/
typedef struct MonoSummarizedVariableValue {
- gssize variable;
+ int variable;
int delta;
} MonoSummarizedVariableValue;
MONO_NO_RELATION = 0
} MonoValueRelation;
+/**
+ * A "kind" of integer value.
+ * The enumeration is used as a bit field, with two fields.
+ * The first, four bits wide, is the "sizeof" in bytes.
+ * The second is a flag that is true if the value is unsigned.
+ */
+typedef enum {
+ MONO_INTEGER_VALUE_SIZE_1 = 1,
+ MONO_INTEGER_VALUE_SIZE_2 = 2,
+ MONO_INTEGER_VALUE_SIZE_4 = 4,
+ MONO_INTEGER_VALUE_SIZE_8 = 8,
+ MONO_INTEGER_VALUE_SIZE_BITMASK = 15,
+ MONO_UNSIGNED_VALUE_FLAG = 16,
+ MONO_UNSIGNED_INTEGER_VALUE_SIZE_1 = MONO_UNSIGNED_VALUE_FLAG|MONO_INTEGER_VALUE_SIZE_1,
+ MONO_UNSIGNED_INTEGER_VALUE_SIZE_2 = MONO_UNSIGNED_VALUE_FLAG|MONO_INTEGER_VALUE_SIZE_2,
+ MONO_UNSIGNED_INTEGER_VALUE_SIZE_4 = MONO_UNSIGNED_VALUE_FLAG|MONO_INTEGER_VALUE_SIZE_4,
+ MONO_UNSIGNED_INTEGER_VALUE_SIZE_8 = MONO_UNSIGNED_VALUE_FLAG|MONO_INTEGER_VALUE_SIZE_8,
+ MONO_UNKNOWN_INTEGER_VALUE = 0
+} MonoIntegerValueKind;
+
/**
* A relation between variables (or a variable and a constant).
* The first variable (the one "on the left of the expression") is implicit.
/**
* The context of a variable evaluation.
- * status: the evaluation status
* current_relation: the relation that is currently evaluated.
* ranges: the result of the evaluation.
* father: the context of the evaluation that invoked this one (used to
* perform the backtracking when loops are detected.
*/
typedef struct MonoRelationsEvaluationContext {
- MonoRelationsEvaluationStatus status;
MonoSummarizedValueRelation *current_relation;
MonoRelationsEvaluationRanges ranges;
struct MonoRelationsEvaluationContext *father;
MONO_MAKE_RELATIONS_EVALUATION_RANGE_IMPOSSIBLE ((rs).zero); \
MONO_MAKE_RELATIONS_EVALUATION_RANGE_IMPOSSIBLE ((rs).variable); \
} while (0)
-#define MONO_RELATIONS_EVALUATION_RANGE_IS_IMPOSSIBLE(r) (((r).lower==INT_MAX)&&((r).upper==INT_MIN))
-#define MONO_RELATIONS_EVALUATION_RANGES_IS_IMPOSSIBLE(rs) \
- (MONO_RELATIONS_EVALUATION_RANGE_IS_IMPOSSIBLE((rs).zero) && \
+#define MONO_RELATIONS_EVALUATION_RANGE_IS_WEAK(r) (((r).lower==INT_MIN)&&((r).upper==INT_MAX))
+#define MONO_RELATIONS_EVALUATION_RANGES_ARE_WEAK(rs) \
+ (MONO_RELATIONS_EVALUATION_RANGE_IS_WEAK((rs).zero) && \
+ MONO_RELATIONS_EVALUATION_RANGE_IS_WEAK((rs).variable))
+#define MONO_RELATIONS_EVALUATION_RANGE_IS_IMPOSSIBLE(r) (((r).lower)>((r).upper))
+#define MONO_RELATIONS_EVALUATION_RANGES_ARE_IMPOSSIBLE(rs) \
+ (MONO_RELATIONS_EVALUATION_RANGE_IS_IMPOSSIBLE((rs).zero) || \
MONO_RELATIONS_EVALUATION_RANGE_IS_IMPOSSIBLE((rs).variable))
/*
* relations: and array of relations, one for each method variable (each
* relation is the head of a list); this is the evaluation graph
* contexts: an array of evaluation contexts (one for each method variable)
+ * variable_value_kind: an array of MonoIntegerValueKind, one for each local
+ * variable (or argument)
+ * defs: maps vregs to the instruction which defines it.
*/
typedef struct MonoVariableRelationsEvaluationArea {
MonoCompile *cfg;
MonoSummarizedValueRelation *relations;
+
+/**
+ * statuses and contexts are parallel arrays. A given index into each refers to
+ * the same context. This is a performance optimization. Clean_context was
+ * coming to dominate the running time of abcremoval. By
+ * storing the statuses together, we can memset the entire
+ * region.
+ */
+ MonoRelationsEvaluationStatus *statuses;
MonoRelationsEvaluationContext *contexts;
+
+ MonoIntegerValueKind *variable_value_kind;
+ MonoInst **defs;
} MonoVariableRelationsEvaluationArea;
/**
* in the traversal of the dominator tree)
*/
typedef struct MonoAdditionalVariableRelation {
- gssize variable;
+ int variable;
MonoSummarizedValueRelation relation;
MonoSummarizedValueRelation *insertion_point;
} MonoAdditionalVariableRelation;
#endif /* __MONO_ABCREMOVAL_H__ */
-