[MLton-commit] r6879

Wesley Terpstra wesley at mlton.org
Mon Sep 22 05:32:22 PDT 2008


Fix a bug in the bytecode generator whereby a symbol used in both _import and 
_address only generates one entry in the MLton_callC function. This collision
obviously led to either the C call or the symbol address failing.


----------------------------------------------------------------------

U   mlton/trunk/mlton/codegen/bytecode/bytecode.fun

----------------------------------------------------------------------

Modified: mlton/trunk/mlton/codegen/bytecode/bytecode.fun
===================================================================
--- mlton/trunk/mlton/codegen/bytecode/bytecode.fun	2008-09-22 10:14:19 UTC (rev 6878)
+++ mlton/trunk/mlton/codegen/bytecode/bytecode.fun	2008-09-22 12:32:21 UTC (rev 6879)
@@ -291,7 +291,8 @@
                                  ignore
                                  (HashSet.lookupOrInsert
                                   (calls, hash,
-                                   fn {name = n, ...} => n = name,
+                                   fn {name = n, symbol, ...} => 
+                                   n = name andalso symbol,
                                    fn () =>
                                    let
                                       val index = Counter.next callCounter
@@ -311,7 +312,8 @@
                                    in
                                       {hash = hash,
                                        index = index,
-                                       name = name}
+                                       name = name,
+                                       symbol = true}
                                    end))
                               end)
                         | _ => ())
@@ -331,7 +333,8 @@
                                     ignore
                                     (HashSet.lookupOrInsert
                                      (calls, hash,
-                                      fn {name = n, ...} => n = name,
+                                      fn {name = n, symbol, ...} => 
+                                      n = name andalso (not symbol),
                                       fn () =>
                                       let
                                          val index = Counter.next callCounter
@@ -345,7 +348,8 @@
                                       in
                                          {hash = hash,
                                           index = index,
-                                          name = name}
+                                          name = name,
+                                          symbol = false}
                                       end))
                                  end
                             | Indirect => ()
@@ -354,9 +358,15 @@
          fun directIndex (name: string) =
             #index (HashSet.lookupOrInsert
                     (calls, String.hash name,
-                     fn {name = n, ...} => n = name,
+                     fn {name = n, symbol, ...} => 
+                     n = name andalso (not symbol),
                      fn () => Error.bug "Bytecode.output.directIndex"))
-         val ffiSymbolIndex = directIndex
+         fun ffiSymbolIndex (name: string) = 
+            #index (HashSet.lookupOrInsert
+                    (calls, String.hash name,
+                     fn {name = n, symbol, ...} => 
+                     n = name andalso symbol,
+                     fn () => Error.bug "Bytecode.output.ffiSymbolIndex"))
       end
       fun indirectIndex (f: 'a CFunction.t): int =
          let




More information about the MLton-commit mailing list