[Mono-bugs] [Bug 74653][Wis] New - mjs generated incorrect code for bool literals, in a loading context.

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Mon, 18 Apr 2005 14:34:39 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by cesar@ciencias.unam.mx.

http://bugzilla.ximian.com/show_bug.cgi?id=74653

--- shadow/74653	2005-04-18 14:34:39.000000000 -0400
+++ shadow/74653.tmp.14004	2005-04-18 14:34:39.000000000 -0400
@@ -0,0 +1,137 @@
+Bug#: 74653
+Product: Mono: Compilers
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: JScript
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: cesar@ciencias.unam.mx               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: mjs generated incorrect code for bool literals, in a loading context.
+
+Description of Problem:
+Now by default we generate a OpCodes.Box instruction every time we load a
+boolean literal, which is ok when we are in an assignment context to a
+variable, but it's not ok when doing checks with OpCodes.Brfalse or
+OpCodes.Brtrue.  
+
+
+Steps to reproduce the problem:
+Compile attached test case.
+
+Actual Results:
+Scenario: Use logical AND with true/false constants
+logical AND T/F (consts) failed
+
+
+Expected Results:
+Scenario: Use logical AND with true/false constants
+succeeded
+
+
+How often does this happen? 
+Always.
+
+Additional Information:
+
+The incorrect CIL is the following:
+ IL_000c:  ldstr "Scenario: Use logical AND with true/false constants"
+        IL_0011:  call void class
+[Microsoft.JScript]Microsoft.JScript.ScriptStream::WriteLine(string)
+        IL_0016:  ldc.i4.1
+        IL_0017:  box [mscorlib]System.Boolean
+        IL_001c:  brfalse IL_0037
+                                                                          
+                                                    
+        IL_0021:  ldc.i4.0
+        IL_0022:  box [mscorlib]System.Boolean
+        IL_0027:  brfalse IL_0037
+                                                                          
+                                                    
+        IL_002c:  ldc.i4.1
+        IL_002d:  box [mscorlib]System.Boolean
+        IL_0032:  br IL_003d
+                                                                          
+                                                    
+        IL_0037:  ldc.i4.0
+        IL_0038:  box [mscorlib]System.Boolean
+        IL_003d:  stsfld  object 'JScript 0'::result
+        IL_0042:  ldc.i4.0
+        IL_0043:  box [mscorlib]System.Boolean
+        IL_0048:  stsfld  object 'JScript 0'::expected
+        IL_004d:  ldc.i4.s 0x36
+        IL_004f:  newobj instance void class
+[Microsoft.JScript]Microsoft.JScript.Equality::.ctor(int32)
+        IL_0054:  stloc.0
+        IL_0055:  ldloc.0
+        IL_0056:  ldsfld  object 'JScript 0'::result
+        IL_005b:  ldsfld  object 'JScript 0'::expected
+        IL_0060:  call instance bool class
+[Microsoft.JScript]Microsoft.JScript.Equality::EvaluateEquality(object, object)
+        IL_0065:  brtrue IL_0079
+                                                                          
+                                                    
+        IL_006a:  ldstr "logical AND T/F (consts) failed"
+        IL_006f:  call void class
+[Microsoft.JScript]Microsoft.JScript.ScriptStream::WriteLine(string)
+        IL_0074:  br IL_0083
+                                                                          
+                                                    
+        IL_0079:  ldstr "succeeded"
+        IL_007e:  call void class
+[Microsoft.JScript]Microsoft.JScript.ScriptStream::WriteLine(string)
+
+The correct CIL would be:
+
+ IL_000c:  ldstr "Scenario: Use logical AND with true/false constants"
+        IL_0011:  call void class
+[Microsoft.JScript]Microsoft.JScript.ScriptStream::WriteLine(string)
+        IL_0016:  ldc.i4.1
+        IL_001c:  brfalse IL_0037
+                                                                          
+                                                    
+        IL_0021:  ldc.i4.0
+        IL_0027:  brfalse IL_0037
+                                                                          
+                                                    
+        IL_002c:  ldc.i4.1
+        IL_002d:  box [mscorlib]System.Boolean
+        IL_0032:  br IL_003d
+                                                                          
+                                                    
+        IL_0037:  ldc.i4.0
+        IL_0038:  box [mscorlib]System.Boolean
+        IL_003d:  stsfld  object 'JScript 0'::result
+        IL_0042:  ldc.i4.0
+        IL_0043:  box [mscorlib]System.Boolean
+        IL_0048:  stsfld  object 'JScript 0'::expected
+        IL_004d:  ldc.i4.s 0x36
+        IL_004f:  newobj instance void class
+[Microsoft.JScript]Microsoft.JScript.Equality::.ctor(int32)
+        IL_0054:  stloc.0
+        IL_0055:  ldloc.0
+        IL_0056:  ldsfld  object 'JScript 0'::result
+        IL_005b:  ldsfld  object 'JScript 0'::expected
+        IL_0060:  call instance bool class
+[Microsoft.JScript]Microsoft.JScript.Equality::EvaluateEquality(object, object)
+        IL_0065:  brtrue IL_0079
+                                                                          
+                                                    
+        IL_006a:  ldstr "logical AND T/F (consts) failed"
+        IL_006f:  call void class
+[Microsoft.JScript]Microsoft.JScript.ScriptStream::WriteLine(string)
+        IL_0074:  br IL_0083
+                                                                          
+                                                    
+        IL_0079:  ldstr "succeeded"
+        IL_007e:  call void class
+[Microsoft.JScript]Microsoft.JScript.ScriptStream::WriteLine(string)
+
+in which I have removed the OpCodes.Box before the brfalse's.