Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / mini / abcremoval.h
index e514eaa9d945f3b0cdc86bbb8cc9fe56e52f3310..ac52857ea76d9037ad1aa3edeb50883d32f32504 100644 (file)
@@ -1,5 +1,6 @@
-/*
- * abcremoval.h: Array bounds check removal
+/**
+ * \file
+ * Array bounds check removal
  *
  * Author:
  *   Massimiliano Mantione (massi@ximian.com)
@@ -44,7 +45,7 @@ typedef struct MonoSummarizedConstantValue {
  * delta: the delta (can be zero)
  */
 typedef struct MonoSummarizedVariableValue {
-       gssize variable;
+       int variable;
        int delta;
 } MonoSummarizedVariableValue;
 
@@ -90,6 +91,26 @@ typedef enum {
        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.
@@ -159,14 +180,12 @@ typedef struct MonoRelationsEvaluationRanges {
 
 /**
  * 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;
@@ -191,9 +210,13 @@ typedef struct MonoRelationsEvaluationContext {
                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))
 
 /*
@@ -277,11 +300,26 @@ typedef struct MonoRelationsEvaluationContext {
  * 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;
 
 /**
@@ -294,7 +332,7 @@ typedef struct MonoVariableRelationsEvaluationArea {
  *                  in the traversal of the dominator tree)
  */
 typedef struct MonoAdditionalVariableRelation {
-       gssize variable;
+       int variable;
        MonoSummarizedValueRelation relation;
        MonoSummarizedValueRelation *insertion_point;
 } MonoAdditionalVariableRelation;
@@ -312,4 +350,3 @@ typedef struct MonoAdditionalVariableRelationsForBB {
 
 
 #endif /* __MONO_ABCREMOVAL_H__ */
-