type) {
+ InstrumentationHandler instrumentationHandler = (InstrumentationHandler) vm;
+ return instrumentationHandler.lookup(key, type);
}
@Override
diff --git a/truffle/com.oracle.truffle.api.instrumentation/src/com/oracle/truffle/api/instrumentation/InstrumentationLanguage.java b/truffle/com.oracle.truffle.api.instrumentation/src/com/oracle/truffle/api/instrumentation/InstrumentationLanguage.java
deleted file mode 100644
index 77b94db044fb..000000000000
--- a/truffle/com.oracle.truffle.api.instrumentation/src/com/oracle/truffle/api/instrumentation/InstrumentationLanguage.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.api.instrumentation;
-
-import com.oracle.truffle.api.TruffleLanguage;
-
-/**
- *
- * {@link TruffleLanguage} implementations can decide to implement this additional interface to
- * register {@link EventBinding bindings} specifically for this language. This can be useful to
- * implement core language features using the instrumentation API. Instrumentations created by an
- * {@link InstrumentationLanguage} have elevated rights in the system. Exceptions thrown by
- * {@link EventBinding bindings} that were created using the {@link Instrumenter} passed in
- * {@link #installInstrumentations(Object, Instrumenter)} are directly passed on to the guest
- * language AST.
- *
- *
- * Bindings created by the guest language are also automatically disposed together with the
- * language.
- */
-public interface InstrumentationLanguage {
-
- /**
- * Invoked for each allocated context on guest language startup. Bindings attached to the
- * instrumenter apply only for the given context and guest language.
- *
- * @param context the context of the language that
- * @param instrumenter
- *
- * @see Instrumenter
- */
- void installInstrumentations(C context, Instrumenter instrumenter);
-
-}
diff --git a/truffle/com.oracle.truffle.api.instrumentation/src/com/oracle/truffle/api/instrumentation/package-info.java b/truffle/com.oracle.truffle.api.instrumentation/src/com/oracle/truffle/api/instrumentation/package-info.java
index 600a9267cd13..0232f32216f2 100644
--- a/truffle/com.oracle.truffle.api.instrumentation/src/com/oracle/truffle/api/instrumentation/package-info.java
+++ b/truffle/com.oracle.truffle.api.instrumentation/src/com/oracle/truffle/api/instrumentation/package-info.java
@@ -35,9 +35,10 @@
* {@link com.oracle.truffle.api.instrumentation.TruffleInstrument} interface. Please refer to
* {@link com.oracle.truffle.api.instrumentation.TruffleInstrument} for further details.
*
- * Guest languages that want to use the capabilities of the instrumentation framework can implement
- * {@link com.oracle.truffle.api.instrumentation.InstrumentationLanguage} for their
- * {@link com.oracle.truffle.api.TruffleLanguage language} subclass.
+ * Guest languages that want to use the capabilities of the instrumentation framework can access
+ * {@link com.oracle.truffle.api.instrumentation.Instrumenter} for their
+ * {@link com.oracle.truffle.api.TruffleLanguage language} by calling
+ * {@link com.oracle.truffle.api.TruffleLanguage.Env#lookup lookup(Instrumenter.class)}.
* {@link com.oracle.truffle.api.instrumentation.SourceSectionFilter Filters} created using guest
* languages may be used to implement guest language features that require meta-programming
* capabilities.
@@ -45,7 +46,6 @@
* Instrumentations can get enabled/disabled using PolyglotEngine.
*
* @see com.oracle.truffle.api.instrumentation.TruffleInstrument
- * @see com.oracle.truffle.api.instrumentation.InstrumentationLanguage
* @see com.oracle.truffle.api.instrumentation.Instrumentable
*/
package com.oracle.truffle.api.instrumentation;
diff --git a/truffle/com.oracle.truffle.api.vm/src/com/oracle/truffle/api/vm/EventConsumer.java b/truffle/com.oracle.truffle.api.vm/src/com/oracle/truffle/api/vm/EventConsumer.java
index da1f2fb8a89e..c3f79d267a73 100644
--- a/truffle/com.oracle.truffle.api.vm/src/com/oracle/truffle/api/vm/EventConsumer.java
+++ b/truffle/com.oracle.truffle.api.vm/src/com/oracle/truffle/api/vm/EventConsumer.java
@@ -25,14 +25,12 @@
package com.oracle.truffle.api.vm;
import com.oracle.truffle.api.TruffleLanguage;
-import com.oracle.truffle.api.debug.ExecutionEvent;
-import com.oracle.truffle.api.debug.SuspendedEvent;
/**
* {@link PolyglotEngine} generates various events and delivers them to
* {@link PolyglotEngine.Builder#onEvent(com.oracle.truffle.api.vm.EventConsumer) registered}
* handlers. Each handler is registered for a particular type of event. Examples of events include
- * {@link ExecutionEvent} or {@link SuspendedEvent} useful when debugging {@link TruffleLanguage
+ * {@link com.oracle.truffle.api.debug.ExecutionEvent} or {@link com.oracle.truffle.api.debug.SuspendedEvent} useful when debugging {@link TruffleLanguage
* Truffle language}s.
*
* @param type of event to observe and handle
diff --git a/truffle/com.oracle.truffle.api.vm/src/com/oracle/truffle/api/vm/PolyglotEngine.java b/truffle/com.oracle.truffle.api.vm/src/com/oracle/truffle/api/vm/PolyglotEngine.java
index 2b5a5d3b40d0..f9622bf6c1f6 100644
--- a/truffle/com.oracle.truffle.api.vm/src/com/oracle/truffle/api/vm/PolyglotEngine.java
+++ b/truffle/com.oracle.truffle.api.vm/src/com/oracle/truffle/api/vm/PolyglotEngine.java
@@ -50,9 +50,6 @@
import com.oracle.truffle.api.TruffleLanguage.Env;
import com.oracle.truffle.api.TruffleLanguage.Registration;
import com.oracle.truffle.api.TruffleOptions;
-import com.oracle.truffle.api.debug.Debugger;
-import com.oracle.truffle.api.debug.ExecutionEvent;
-import com.oracle.truffle.api.debug.SuspendedEvent;
import com.oracle.truffle.api.frame.MaterializedFrame;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.impl.Accessor;
@@ -114,7 +111,6 @@ public class PolyglotEngine {
private final Map globals;
private final Object instrumentationHandler;
private final Map instruments;
- private Object debugger = null;
private boolean disposed;
static {
@@ -140,7 +136,6 @@ public class PolyglotEngine {
this.globals = null;
this.executor = null;
this.instrumentationHandler = null;
- this.debugger = null;
this.instruments = null;
}
@@ -167,19 +162,6 @@ public class PolyglotEngine {
}
this.langs = map;
this.instruments = createAndAutostartDescriptors(InstrumentCache.load(getClass().getClassLoader()));
- try {
- Class.forName("com.oracle.truffle.api.debug.Debugger", true, Debugger.class.getClassLoader());
- } catch (ClassNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- private Object getDebugger() {
- if (debugger == null) {
- debugger = SPI.getDebugger(this);
- }
- return debugger;
}
private Map createAndAutostartDescriptors(List instrumentCaches) {
@@ -482,7 +464,7 @@ Language createLanguage(Map.Entry en) {
@SuppressWarnings("try")
private Object evalImpl(TruffleLanguage>[] fillLang, Source s, Language l) throws IOException {
- try (Closeable d = SPI.executionStart(this, -1, getDebugger(), s)) {
+ try (Closeable d = SPI.executionStart(this, -1, null, s)) {
TruffleLanguage> langImpl = l.getImpl(true);
fillLang[0] = langImpl;
return SPI.eval(langImpl, s, l.cache);
@@ -493,7 +475,7 @@ private Object evalImpl(TruffleLanguage>[] fillLang, Source s, Language l) thr
final Object invokeForeign(final Node foreignNode, VirtualFrame frame, final TruffleObject receiver) throws IOException {
Object res;
if (executor == null) {
- try (final Closeable c = SPI.executionStart(PolyglotEngine.this, -1, getDebugger(), null)) {
+ try (final Closeable c = SPI.executionStart(PolyglotEngine.this, -1, null, null)) {
final Object[] args = ForeignAccess.getArguments(frame).toArray();
res = ForeignAccess.execute(foreignNode, frame, receiver, args);
}
@@ -514,7 +496,7 @@ private Object invokeForeignOnExecutor(final Node foreignNode, VirtualFrame fram
@SuppressWarnings("try")
@Override
protected Object compute() throws IOException {
- try (final Closeable c = SPI.executionStart(PolyglotEngine.this, -1, getDebugger(), null)) {
+ try (final Closeable c = SPI.executionStart(PolyglotEngine.this, -1, null, null)) {
final Object[] args = ForeignAccess.getArguments(materialized).toArray();
RootNode node = SymbolInvokerImpl.createTemporaryRoot(TruffleLanguage.class, foreignNode, receiver, args.length);
final CallTarget target = Truffle.getRuntime().createCallTarget(node);
@@ -601,21 +583,21 @@ private void checkThread() {
@SuppressWarnings("unchecked")
void dispatch(Object ev) {
Class type = ev.getClass();
- if (type == SuspendedEvent.class) {
- dispatchSuspendedEvent((SuspendedEvent) ev);
+ if (type.getSimpleName().equals("SuspendedEvent")) {
+ dispatchSuspendedEvent(ev);
}
- if (type == ExecutionEvent.class) {
- dispatchExecutionEvent((ExecutionEvent) ev);
+ if (type.getSimpleName().equals("ExecutionEvent")) {
+ dispatchExecutionEvent(ev);
}
dispatch(type, ev);
}
@SuppressWarnings("unused")
- void dispatchSuspendedEvent(SuspendedEvent event) {
+ void dispatchSuspendedEvent(Object event) {
}
@SuppressWarnings("unused")
- void dispatchExecutionEvent(ExecutionEvent event) {
+ void dispatchExecutionEvent(Object event) {
}
@SuppressWarnings("unchecked")
@@ -757,7 +739,7 @@ public Value execute(final Object... args) throws IOException {
@SuppressWarnings("try")
@Override
protected Object compute() throws IOException {
- try (final Closeable c = SPI.executionStart(PolyglotEngine.this, -1, debugger, null)) {
+ try (final Closeable c = SPI.executionStart(PolyglotEngine.this, -1, null, null)) {
List