Author: raja
Date: 2007-05-14 22:59:28 -0400 (Mon, 14 May 2007)
New Revision: 77386
Modified:
trunk/mcs/mcs/ChangeLog
trunk/mcs/mcs/flowanalysis.cs
trunk/mcs/mcs/statement.cs
Log:
Rationalize ResolveMeta, part 1
* statement.cs (Block.local_map, Block.LocalMap): Remove.
(Block.AssignableSlots): New.
(Block.ResolveMeta): Make protected. Don't create a VariableMap
for locals -- move code from VariableMap here. Avoid unnecessary
allocations.
* flowanalysis.cs (FlowBranching.local_map): Remove.
(FlowBranching..ctor): Use Block.AssignableSlots.
(VariableMap): Remove unused constructors.
Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog 2007-05-15 02:38:20 UTC (rev 77385)
+++ trunk/mcs/mcs/ChangeLog 2007-05-15 02:59:28 UTC (rev 77386)
@@ -1,3 +1,15 @@
+2007-05-15 Raja R Harinath <[EMAIL PROTECTED]>
+
+ Rationalize ResolveMeta, part 1
+ * statement.cs (Block.local_map, Block.LocalMap): Remove.
+ (Block.AssignableSlots): New.
+ (Block.ResolveMeta): Make protected. Don't create a VariableMap
+ for locals -- move code from VariableMap here. Avoid unnecessary
+ allocations.
+ * flowanalysis.cs (FlowBranching.local_map): Remove.
+ (FlowBranching..ctor): Use Block.AssignableSlots.
+ (VariableMap): Remove unused constructors.
+
2007-05-11 Raja R Harinath <[EMAIL PROTECTED]>
* Makefile [PROFILE=net_2_0_bootstrap]: Add special-case rules.
Modified: trunk/mcs/mcs/flowanalysis.cs
===================================================================
--- trunk/mcs/mcs/flowanalysis.cs 2007-05-15 02:38:20 UTC (rev 77385)
+++ trunk/mcs/mcs/flowanalysis.cs 2007-05-15 02:59:28 UTC (rev 77386)
@@ -116,7 +116,7 @@
// </summary>
public readonly Location Location;
- protected VariableMap param_map, local_map;
+ protected VariableMap param_map;
static int next_id = 0;
int id;
@@ -394,15 +394,11 @@
UsageVector vector;
if (Block != null) {
param_map = Block.ParameterMap;
- local_map = Block.LocalMap;
-
UsageVector parent_vector = parent != null ?
parent.CurrentUsageVector : null;
vector = new UsageVector (
- stype, parent_vector, Block, loc,
- param_map.Length, local_map.Length);
+ stype, parent_vector, Block, loc,
param_map.Length, Block.AssignableSlots);
} else {
param_map = Parent.param_map;
- local_map = Parent.local_map;
vector = new UsageVector (
stype, Parent.CurrentUsageVector, null,
loc);
}
@@ -1510,41 +1506,6 @@
}
}
- public VariableMap (LocalInfo[] locals)
- : this (null, locals)
- { }
-
- public VariableMap (VariableMap parent, LocalInfo[] locals)
- {
- int offset = 0, start = 0;
- if (parent != null && parent.map != null) {
- offset = parent.Length;
- start = parent.Count;
- }
-
- Count = locals.Length + start;
-
- if (Count == 0)
- return;
-
- map = new VariableInfo [Count];
- Length = offset;
-
- if (parent != null && parent.map != null) {
- parent.map.CopyTo (map, 0);
- }
-
- for (int i = start; i < Count; i++) {
- LocalInfo li = locals [i-start];
-
- if (li.VariableType == null)
- continue;
-
- map [i] = li.VariableInfo = new VariableInfo
(li, Length);
- Length += map [i].Length;
- }
- }
-
// <summary>
// Returns the VariableInfo for variable @index or null if we
don't need to
// compute assignment info for this variable.
Modified: trunk/mcs/mcs/statement.cs
===================================================================
--- trunk/mcs/mcs/statement.cs 2007-05-15 02:38:20 UTC (rev 77385)
+++ trunk/mcs/mcs/statement.cs 2007-05-15 02:59:28 UTC (rev 77386)
@@ -1897,7 +1897,7 @@
AddKnownVariable (name, vi);
if ((flags & Flags.VariablesInitialized) != 0)
- throw new Exception ();
+ throw new InternalErrorException ("block has
already been resolved");
return vi;
}
@@ -2007,7 +2007,7 @@
flags |= Flags.IsDestructor;
}
- VariableMap param_map, local_map;
+ VariableMap param_map;
public VariableMap ParameterMap {
get {
@@ -2019,12 +2019,13 @@
}
}
- public VariableMap LocalMap {
+ int assignable_slots;
+ public int AssignableSlots {
get {
- if ((flags & Flags.VariablesInitialized) == 0)
+ if ((flags & Flags.VariablesInitialized) == 0){
throw new Exception ("Variables have
not been initialized yet");
-
- return local_map;
+ }
+ return assignable_slots;
}
}
@@ -2061,35 +2062,15 @@
/// tc: is our typecontainer (to resolve type references)
/// ig: is the code generator:
/// </remarks>
- public void ResolveMeta (ToplevelBlock toplevel, EmitContext
ec, Parameters ip)
+ protected void ResolveMeta (ToplevelBlock toplevel, EmitContext
ec, Parameters ip)
{
Report.Debug (64, "BLOCK RESOLVE META", this, Parent,
toplevel);
+ int offset = Parent == null ? 0 :
Parent.AssignableSlots;
+
// If some parent block was unsafe, we remain unsafe
even if this block
// isn't explicitly marked as such.
using (ec.With (EmitContext.Flags.InUnsafe, ec.InUnsafe
| Unsafe)) {
- //
- // Compute the VariableMap's.
- //
- // Unfortunately, we don't know the type when
adding variables with
- // AddVariable(), so we need to compute this
info here.
- //
-
- LocalInfo[] locals;
- if (variables != null) {
- foreach (LocalInfo li in
variables.Values)
- li.Resolve (ec);
-
- locals = new LocalInfo
[variables.Count];
- variables.Values.CopyTo (locals, 0);
- } else
- locals = new LocalInfo [0];
-
- if (Parent != null)
- local_map = new VariableMap
(Parent.LocalMap, locals);
- else
- local_map = new VariableMap (locals);
-
param_map = new VariableMap (ip);
flags |= Flags.VariablesInitialized;
@@ -2097,6 +2078,14 @@
// Process this block variables
//
if (variables != null) {
+ // resolve all variables before
handling constants
+ foreach (LocalInfo li in
variables.Values) {
+ if (li.Resolve (ec)) {
+ li.VariableInfo = new
VariableInfo (li, offset);
+ offset +=
li.VariableInfo.Length;
+ }
+ }
+
foreach (DictionaryEntry de in
variables) {
string name = (string) de.Key;
LocalInfo vi = (LocalInfo)
de.Value;
@@ -2105,17 +2094,6 @@
if (variable_type == null)
continue;
- if (variable_type.IsPointer) {
- //
- // Am not really
convinced that this test is required (Microsoft does it)
- // but the fact is that
you would not be able to use the pointer variable
- // *anyways*
- //
- if
(!TypeManager.VerifyUnManaged (TypeManager.GetElementType (variable_type),
-
vi.Location))
- continue;
- }
-
if (constants == null)
continue;
@@ -2160,6 +2138,8 @@
}
}
+ assignable_slots = offset;
+
//
// Now, handle the children
//
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches