JaroslavTulach at 11:27, 1 August 2017 - 2017-08-01 11:27:28

←Older revision Revision as of 11:27, 1 August 2017
Line 23: Line 23:
Designing your own [[language]]? Do you want to spend time writing a [[debugger]]? If not, use [[Truffle]] and you'll get your [[debugger]] for free!
Designing your own [[language]]? Do you want to spend time writing a [[debugger]]? If not, use [[Truffle]] and you'll get your [[debugger]] for free!
-
== Debugger in [[NetBeans]] 8.1 ==
+
{{:TruffleNetBeansDebugger}}
-
 
+
-
[[NetBeans]] 8.1 will ship with support for debugging of [[Truffle]] languages. Here is a promotional video demonstrating how to use such feature, but you can try that too! Just get the most recent build of [[NetBeans]], install the [[Truffle]] Debugging Support module and get the sources:
+
-
 
+
-
* Download latest daily build of [[NetBeans]] - tested on '''netbeans-trunk-nightly-201510210002-javase.zip''' downloaded from http://bits.netbeans.org/download/trunk/nightly/2015-10-21_00-02-28/zip/
+
-
* Install [[Truffle]] Debugging Support: Go to ''Tools/Plugins/Available Plugins'' and seek for ''Truffle'', then install.
+
-
* Get the latest [[GraalVM]] build from the OTN: http://www.oracle.com/technetwork/oracle-labs/program-languages/overview/index.html
+
-
 
+
-
==== Installing [[Maven]] Bits and Working with Sources ====
+
-
 
+
-
Assuming your [[GraalVM]] is installed in directory ''$GRAAL_VM'', continue by installing essential [[Truffle]] binaries into your local [[Maven]] repository:
+
-
 
+
-
<source lang="bash">
+
-
$ $GRAAL_VM/bin/maven_install_graalvm
+
-
</source>
+
-
 
+
-
and then you can work with the sources. First of all obtain them and switch to the correct (known to work at present time) revision:
+
-
 
+
-
<source lang="bash">
+
-
$ hg clone http://source.apidesign.org/hg/truffledebugdemo/
+
-
$ cd truffledebugdemo
+
-
$ hg up -C GraalVM-0.9
+
-
</source>
+
-
 
+
-
With the sources you can now use the command line or the IDE to work with them:
+
-
 
+
-
<source lang="bash">
+
-
# compile:
+
-
$ JAVA_HOME=$GRAAL_VM mvn clean install
+
-
# execute
+
-
$ JAVA_HOME=$GRAAL_VM mvn exec:exec
+
-
factorial(5) = 120
+
-
</source>
+
-
 
+
-
The sample prints out value of factorial for five computed in four different ([[Java]], [[Ruby]], [[JavaScript]] and our testing simple language) [[language]]s.
+
-
 
+
-
==== Debugging from [[NetBeans]] ====
+
-
 
+
-
Make sure [[NetBeans]] is running on the [[GraalVM]]:
+
-
 
+
-
<source lang="bash">
+
-
$ /netbeans8.1/bin/netbeans --jdkhome $GRAAL_VM
+
-
</source>
+
-
 
+
-
Open the project sources in the IDE (File/Open Project, select the '''truffledebugdemo''' directory). Open ''MixLanguages.java'' source file. Put breakpoint to ''MixLanguages.java'' line 37 that invokes the global ''factorial'' symbol and debug the project (Debug/Debug Project or press Ctrl-F5). Once the breakpoint is hit, you can step-into (F7), you'll be in [[JavaScript]]. If you continue stepping in you'll get into ''simple language'' and then also into [[Ruby]]. Values of local variables will be available. Enjoy:
+
-
 
+
-
{{#ev:youtube|ewdzDqPsn38}}
+
-
 
+
-
 
+
-
[[Category:Video]]
+

JaroslavTulach at 06:13, 1 August 2017 - 2017-08-01 06:13:59

←Older revision Revision as of 06:13, 1 August 2017
Line 1: Line 1:
-
A set of [[API]]s to build own language interpreter that gets special treatment by [[Graal]] (alternative version of [[HotSpot]] [[VM]]). As a result a well written interpreter can run faster than generated native code at the end.
+
I have spent last two years [[TwoYearsOfTruffle|designing Truffle]] A set of [[API]]s to build own language interpreter that gets special treatment by [[Graal]] (alternative version of [[HotSpot]] [[VM]]). As a result a well written interpreter can run faster than generated native code at the end.
[[Truffle]] is using sort of [[AsmJs]] approach: rather than complicating the [[JVM]] (like it was done with [[invokeDynamic]] instruction), it creates additional [[Java]] [[API]]s that dynamic [[language]] vendors may use. The [[API]] patterns are then recognized by the enhanced [[HotSpot]] compiler to emit more effective code. All of that without modification to the [[JVM]] spec.
[[Truffle]] is using sort of [[AsmJs]] approach: rather than complicating the [[JVM]] (like it was done with [[invokeDynamic]] instruction), it creates additional [[Java]] [[API]]s that dynamic [[language]] vendors may use. The [[API]] patterns are then recognized by the enhanced [[HotSpot]] compiler to emit more effective code. All of that without modification to the [[JVM]] spec.

JaroslavTulach: /* Debugging from NetBeans */ - 2015-10-21 18:45:53

Debugging from NetBeans

←Older revision Revision as of 18:45, 21 October 2015
Line 67: Line 67:
</source>
</source>
-
Open the project sources in the IDE (File/Open Project). Open ''MixLanguages.java'' source file. Put breakpoint to ''MixLanguages.java'' line 37 that invokes the global ''factorial'' symbol and debug the project (Debug/Debug Project or press Ctrl-F5). Once the breakpoint is hit, you can step-into (F7), you'll be in [[JavaScript]]. If you continue stepping in you'll get into ''simple language'' and then also into [[Ruby]]. Values of local variables will be available. Enjoy:
+
Open the project sources in the IDE (File/Open Project, select the '''truffledebugdemo''' directory). Open ''MixLanguages.java'' source file. Put breakpoint to ''MixLanguages.java'' line 37 that invokes the global ''factorial'' symbol and debug the project (Debug/Debug Project or press Ctrl-F5). Once the breakpoint is hit, you can step-into (F7), you'll be in [[JavaScript]]. If you continue stepping in you'll get into ''simple language'' and then also into [[Ruby]]. Values of local variables will be available. Enjoy:
{{#ev:youtube|ewdzDqPsn38}}
{{#ev:youtube|ewdzDqPsn38}}

JaroslavTulach: /* Debugger in NetBeans 8.1 */ - 2015-10-21 18:39:39

Debugger in NetBeans 8.1

←Older revision Revision as of 18:39, 21 October 2015
Line 27: Line 27:
[[NetBeans]] 8.1 will ship with support for debugging of [[Truffle]] languages. Here is a promotional video demonstrating how to use such feature, but you can try that too! Just get the most recent build of [[NetBeans]], install the [[Truffle]] Debugging Support module and get the sources:
[[NetBeans]] 8.1 will ship with support for debugging of [[Truffle]] languages. Here is a promotional video demonstrating how to use such feature, but you can try that too! Just get the most recent build of [[NetBeans]], install the [[Truffle]] Debugging Support module and get the sources:
-
* Download latest daily build of [[NetBeans]] from http://bits.netbeans.org/download/trunk/nightly/latest/
+
* Download latest daily build of [[NetBeans]] - tested on '''netbeans-trunk-nightly-201510210002-javase.zip''' downloaded from http://bits.netbeans.org/download/trunk/nightly/2015-10-21_00-02-28/zip/
* Install [[Truffle]] Debugging Support: Go to ''Tools/Plugins/Available Plugins'' and seek for ''Truffle'', then install.
* Install [[Truffle]] Debugging Support: Go to ''Tools/Plugins/Available Plugins'' and seek for ''Truffle'', then install.
* Get the latest [[GraalVM]] build from the OTN: http://www.oracle.com/technetwork/oracle-labs/program-languages/overview/index.html
* Get the latest [[GraalVM]] build from the OTN: http://www.oracle.com/technetwork/oracle-labs/program-languages/overview/index.html

JaroslavTulach: /* Debugging from NetBeans */ - 2015-10-21 17:23:37

Debugging from NetBeans

←Older revision Revision as of 17:23, 21 October 2015
Line 67: Line 67:
</source>
</source>
-
Open the project sources in the IDE (File/Open Project). Open ''MixLanguages.java'' source file. Put breakpoint to ''MixLanguages.java'' line 37 that calls the ''invoke'' method on ''tenant'' instance and debug the project (Debug/Debug Project or press Ctrl-F5). Once the breakpoint is hit, you can step-into (F7), you'll be in [[JavaScript]]. If you continue stepping in you'll get into ''simple language'' and then also into [[Ruby]]. Values of local variables will be available. Enjoy:
+
Open the project sources in the IDE (File/Open Project). Open ''MixLanguages.java'' source file. Put breakpoint to ''MixLanguages.java'' line 37 that invokes the global ''factorial'' symbol and debug the project (Debug/Debug Project or press Ctrl-F5). Once the breakpoint is hit, you can step-into (F7), you'll be in [[JavaScript]]. If you continue stepping in you'll get into ''simple language'' and then also into [[Ruby]]. Values of local variables will be available. Enjoy:
{{#ev:youtube|ewdzDqPsn38}}
{{#ev:youtube|ewdzDqPsn38}}

JaroslavTulach: /* Debugging from NetBeans */ - 2015-10-21 17:19:00

Debugging from NetBeans

←Older revision Revision as of 17:19, 21 October 2015
Line 67: Line 67:
</source>
</source>
-
Open the project sources in the IDE (File/Open Project). Open ''MixLanguages.java'' source file. Put breakpoint to ''MixLanguages.java'' line 37 that calls the ''invoke'' method on ''tenant'' instance and debug the project (Debug/Debug Project or press F5). Once the breakpoint is hit, you can step-into (F7), you'll be in [[JavaScript]]. If you continue stepping in you'll get into ''simple language'' and then also into [[Ruby]]. Values of local variables will be available. Enjoy:
+
Open the project sources in the IDE (File/Open Project). Open ''MixLanguages.java'' source file. Put breakpoint to ''MixLanguages.java'' line 37 that calls the ''invoke'' method on ''tenant'' instance and debug the project (Debug/Debug Project or press Ctrl-F5). Once the breakpoint is hit, you can step-into (F7), you'll be in [[JavaScript]]. If you continue stepping in you'll get into ''simple language'' and then also into [[Ruby]]. Values of local variables will be available. Enjoy:
{{#ev:youtube|ewdzDqPsn38}}
{{#ev:youtube|ewdzDqPsn38}}

JaroslavTulach: /* Debugging from NetBeans */ - 2015-10-21 17:18:25

Debugging from NetBeans

←Older revision Revision as of 17:18, 21 October 2015
Line 67: Line 67:
</source>
</source>
-
Open the project sources in the IDE (File/Open Project). Open ''MixLanguages.java'' source file. Put breakpoint to ''MixLanguages.java'' line that calls the ''invoke'' method on ''tenant'' instance and debug the project (Debug/Debug Project or press F5). Once the breakpoint is hit, you can step-into (F7), you'll be in [[JavaScript]]. If you continue stepping in you'll get into ''simple language'' and then also into [[Ruby]]. Values of local variables will be available. Enjoy:
+
Open the project sources in the IDE (File/Open Project). Open ''MixLanguages.java'' source file. Put breakpoint to ''MixLanguages.java'' line 37 that calls the ''invoke'' method on ''tenant'' instance and debug the project (Debug/Debug Project or press F5). Once the breakpoint is hit, you can step-into (F7), you'll be in [[JavaScript]]. If you continue stepping in you'll get into ''simple language'' and then also into [[Ruby]]. Values of local variables will be available. Enjoy:
{{#ev:youtube|ewdzDqPsn38}}
{{#ev:youtube|ewdzDqPsn38}}

JaroslavTulach: /* Debugging from NetBeans */ - 2015-10-21 17:14:14

Debugging from NetBeans

←Older revision Revision as of 17:14, 21 October 2015
Line 61: Line 61:
==== Debugging from [[NetBeans]] ====
==== Debugging from [[NetBeans]] ====
-
Open the project in the IDE. Put breakpoint to ''MixLanguages.java'' line that calls the ''invoke'' method on ''tenant'' instance and debug ''MixLanguagesTest.java'' instance. If you step-into (F7), you'll be in [[JavaScript]]. If you continue stepping in you'll get into ''simple language'' and then also into [[Ruby]]. Enjoy:
+
Make sure [[NetBeans]] is running on the [[GraalVM]]:
 +
 
 +
<source lang="bash">
 +
$ /netbeans8.1/bin/netbeans --jdkhome $GRAAL_VM
 +
</source>
 +
 
 +
Open the project sources in the IDE (File/Open Project). Open ''MixLanguages.java'' source file. Put breakpoint to ''MixLanguages.java'' line that calls the ''invoke'' method on ''tenant'' instance and debug the project (Debug/Debug Project or press F5). Once the breakpoint is hit, you can step-into (F7), you'll be in [[JavaScript]]. If you continue stepping in you'll get into ''simple language'' and then also into [[Ruby]]. Values of local variables will be available. Enjoy:
{{#ev:youtube|ewdzDqPsn38}}
{{#ev:youtube|ewdzDqPsn38}}

JaroslavTulach: /* Debugger in NetBeans 8.1 */ - 2015-10-21 16:58:57

Debugger in NetBeans 8.1

←Older revision Revision as of 16:58, 21 October 2015
Line 31: Line 31:
* Get the latest [[GraalVM]] build from the OTN: http://www.oracle.com/technetwork/oracle-labs/program-languages/overview/index.html
* Get the latest [[GraalVM]] build from the OTN: http://www.oracle.com/technetwork/oracle-labs/program-languages/overview/index.html
-
and then you can work with the sources
+
==== Installing [[Maven]] Bits and Working with Sources ====
 +
 
 +
Assuming your [[GraalVM]] is installed in directory ''$GRAAL_VM'', continue by installing essential [[Truffle]] binaries into your local [[Maven]] repository:
<source lang="bash">
<source lang="bash">
-
$ http://source.apidesign.org/hg/truffledebugdemo/
+
$ $GRAAL_VM/bin/maven_install_graalvm
 +
</source>
 +
 
 +
and then you can work with the sources. First of all obtain them and switch to the correct (known to work at present time) revision:
 +
 
 +
<source lang="bash">
 +
$ hg clone http://source.apidesign.org/hg/truffledebugdemo/
$ cd truffledebugdemo
$ cd truffledebugdemo
-
$ hg up -C
+
$ hg up -C GraalVM-0.9
-
# build it here or in the IDE
+
-
$ mvm clean install
+
</source>
</source>
 +
 +
With the sources you can now use the command line or the IDE to work with them:
 +
 +
<source lang="bash">
 +
# compile:
 +
$ JAVA_HOME=$GRAAL_VM mvn clean install
 +
# execute
 +
$ JAVA_HOME=$GRAAL_VM mvn exec:exec
 +
factorial(5) = 120
 +
</source>
 +
 +
The sample prints out value of factorial for five computed in four different ([[Java]], [[Ruby]], [[JavaScript]] and our testing simple language) [[language]]s.
 +
 +
==== Debugging from [[NetBeans]] ====
Open the project in the IDE. Put breakpoint to ''MixLanguages.java'' line that calls the ''invoke'' method on ''tenant'' instance and debug ''MixLanguagesTest.java'' instance. If you step-into (F7), you'll be in [[JavaScript]]. If you continue stepping in you'll get into ''simple language'' and then also into [[Ruby]]. Enjoy:
Open the project in the IDE. Put breakpoint to ''MixLanguages.java'' line that calls the ''invoke'' method on ''tenant'' instance and debug ''MixLanguagesTest.java'' instance. If you step-into (F7), you'll be in [[JavaScript]]. If you continue stepping in you'll get into ''simple language'' and then also into [[Ruby]]. Enjoy:

JaroslavTulach: /* Debugger in NetBeans 8.1 */ - 2015-10-21 16:45:24

Debugger in NetBeans 8.1

←Older revision Revision as of 16:45, 21 October 2015
Line 28: Line 28:
* Download latest daily build of [[NetBeans]] from http://bits.netbeans.org/download/trunk/nightly/latest/
* Download latest daily build of [[NetBeans]] from http://bits.netbeans.org/download/trunk/nightly/latest/
-
* Install [[Truffle]] Debugging Support: Go to ''Tools/Plugins//Available Plugins'' and seek for ''Truffle'' - install.
+
* Install [[Truffle]] Debugging Support: Go to ''Tools/Plugins/Available Plugins'' and seek for ''Truffle'', then install.
* Get the latest [[GraalVM]] build from the OTN: http://www.oracle.com/technetwork/oracle-labs/program-languages/overview/index.html
* Get the latest [[GraalVM]] build from the OTN: http://www.oracle.com/technetwork/oracle-labs/program-languages/overview/index.html