[nem-bug] [Nemerle 0000702]: [0.9.3] When downcasting IL generates
unnecessary .castclass
feedback at nemerle.org
feedback at nemerle.org
Sun Jul 2 12:25:33 CEST 2006
The following issue has been RESOLVED.
======================================================================
<http://nemerle.org/bugs/view.php?id=702>
======================================================================
Reported By: Snaury
Assigned To: nazgul
======================================================================
Project: Nemerle
Issue ID: 702
Category: Compiler
Reproducibility: always
Severity: major
Priority: normal
Status: resolved
Resolution: fixed
Fixed in Version:
======================================================================
Date Submitted: 07-01-2006 16:48 CEST
Last Modified: 07-02-2006 12:25 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.
----------------------------------------------------------------------
nazgul - 07-02-06 12:25
----------------------------------------------------------------------
The patch is good. Thanks!
Fixed on trunk (r6415)
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
07-02-06 10:51 Snaury File Added: bug-upcast-proper.patch
07-02-06 12:25 nazgul Status new => resolved
07-02-06 12:25 nazgul Resolution open => fixed
07-02-06 12:25 nazgul Assigned To => nazgul
07-02-06 12:25 nazgul Note Added: 0001333
======================================================================
More information about the bugs
mailing list