[nem-bug] [Nemerle 0000702]: [0.9.3] When downcasting IL generates
unnecessary .castclass
feedback at nemerle.org
feedback at nemerle.org
Sun Jul 2 10:50:36 CEST 2006
A NOTE has been added to this issue.
======================================================================
<http://nemerle.org/bugs/view.php?id=702>
======================================================================
Reported By: Snaury
Assigned To:
======================================================================
Project: Nemerle
Issue ID: 702
Category: Compiler
Reproducibility: always
Severity: major
Priority: normal
Status: new
======================================================================
Date Submitted: 07-01-2006 16:48 CEST
Last Modified: 07-02-2006 10:50 CEST
======================================================================
Summary: [0.9.3] When downcasting IL generates unnecessary
.castclass
Description:
Consider the following code:
def a = "some string"
def b = a : object
After compiling and looking at IL I can see that string downcast, for some
strange reason, is compiled into
.castclass System.Object
which is not only absolutely unnecessary, it also costs time (a quick test
showed that a call to function with .castclass from string to object seems
to be roughly (I'm not sure if I measured correctly) 10 times slower than
just an empty function call) and pollutes IL. For example, C# does not
generates .castclass when it does downcasts.
======================================================================
----------------------------------------------------------------------
Snaury - 07-02-06 10:50
----------------------------------------------------------------------
Ok, I spent a lot of time on this bug, following many wrong routes, because
for some very strange (only to me?) reason, because original idea of
unless (kind is ConversionKind.UpCast)
wasn't working (I was using msbuild which I ran three times: each time
copying new compiler to boot) giving me a lot of source code errors.
However, when I finally moved to configure/make, it no longer gives a
slightest error! O.o
So, I'm reattaching simpler patch.
Now unnecessary casts are finally omitted, for example:
def s = "string";
def o = s : object; // no cast generated
def l : list[int] = list.Cons(1, []); // not a single cast here as well
Whee-hee! Now I can write:
def a = array[a : object, b : object, c : object]
And never worry about castclass'es from string to object and the like.
=^_^=
P.S.
I ran make tests in ncc and they passed, however for other tests I didn't
run them (I'm using msys, so it's not as easy as make check for me), but I
hope they work.
Issue History
Date Modified Username Field Change
======================================================================
07-01-06 16:48 Snaury New Issue
07-02-06 10:36 Snaury File Added: bug-upcast.patch
07-02-06 10:50 Snaury Note Added: 0001332
======================================================================
More information about the bugs
mailing list