changeset 21573:ffdd2ec86f42

Truffle/Debugging: temporary patches so the DebugEngine will work (partially) with the new TruffleVM framework.
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Wed, 27 May 2015 20:52:21 -0700
parents d6d7e51d9206
children e435b2fbd10e
files graal/com.oracle.truffle.interop/src/com/oracle/truffle/interop/SymbolInvokerImpl.java graal/com.oracle.truffle.sl.tools/src/com/oracle/truffle/sl/tools/debug/SLSourceExecutionProvider.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java
diffstat 3 files changed, 26 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.truffle.interop/src/com/oracle/truffle/interop/SymbolInvokerImpl.java	Wed May 27 20:49:09 2015 -0700
+++ b/graal/com.oracle.truffle.interop/src/com/oracle/truffle/interop/SymbolInvokerImpl.java	Wed May 27 20:52:21 2015 -0700
@@ -28,12 +28,14 @@
 import com.oracle.truffle.api.Truffle;
 import com.oracle.truffle.api.frame.FrameDescriptor;
 import com.oracle.truffle.api.frame.VirtualFrame;
+import com.oracle.truffle.api.instrument.*;
 import com.oracle.truffle.api.interop.TruffleObject;
 import com.oracle.truffle.api.impl.SymbolInvoker;
 import com.oracle.truffle.api.nodes.RootNode;
 import com.oracle.truffle.interop.messages.Execute;
 import com.oracle.truffle.interop.messages.Receiver;
 import com.oracle.truffle.interop.node.ForeignObjectAccessNode;
+
 import java.io.IOException;
 
 public final class SymbolInvokerImpl extends SymbolInvoker {
@@ -59,6 +61,11 @@
         }
 
         @Override
+        public void applyInstrumentation() {
+            Probe.applyASTProbers(foreignAccess);
+        }
+
+        @Override
         public Object execute(VirtualFrame frame) {
             return foreignAccess.executeForeign(frame, function, args);
         }
--- a/graal/com.oracle.truffle.sl.tools/src/com/oracle/truffle/sl/tools/debug/SLSourceExecutionProvider.java	Wed May 27 20:49:09 2015 -0700
+++ b/graal/com.oracle.truffle.sl.tools/src/com/oracle/truffle/sl/tools/debug/SLSourceExecutionProvider.java	Wed May 27 20:52:21 2015 -0700
@@ -24,10 +24,13 @@
  */
 package com.oracle.truffle.sl.tools.debug;
 
+import java.io.*;
+
 import com.oracle.truffle.api.frame.*;
 import com.oracle.truffle.api.instrument.*;
 import com.oracle.truffle.api.nodes.*;
 import com.oracle.truffle.api.source.*;
+import com.oracle.truffle.sl.*;
 import com.oracle.truffle.sl.nodes.instrument.*;
 import com.oracle.truffle.sl.runtime.*;
 import com.oracle.truffle.tools.debug.engine.*;
@@ -47,7 +50,11 @@
 
     @Override
     public void languageRun(Source source) {
-        slContext.executeMain(source);
+        try {
+            SLMain.run(source);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
     }
 
     /**
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java	Wed May 27 20:49:09 2015 -0700
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java	Wed May 27 20:52:21 2015 -0700
@@ -181,6 +181,17 @@
         }
     }
 
+    public static void run(Source source) throws IOException {
+        TruffleVM vm = TruffleVM.newVM().build();
+        assert vm.getLanguages().containsKey("application/x-sl");
+        vm.eval(new File(source.getPath()).toURI());
+        Symbol main = vm.findGlobalSymbol("main");
+        if (main == null) {
+            throw new SLException("No function main() defined in SL source file.");
+        }
+        main.invoke(null);
+    }
+
     /**
      * Parse and run the specified SL source. Factored out in a separate method so that it can also
      * be used by the unit test harness.