9 Star 65 Fork 15

Gitee 极速下载/GraalVM

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
.devcontainer
.github
ci
ci_includes
compiler
docs
espresso-compiler-stub
espresso
regex
sdk
substratevm
sulong
tools
truffle
ci
docs
bytecode_dsl
splitting
AOT.md
AOTOverview.md
AuxiliaryEngineCachingEnterprise.md
BranchInstrumentation.md
CloseOnGc.md
DSLGuidelines.md
DSLNodeObjectInlining.md
DSLWarnings.md
DynamicObjectModel.md
Exit.md
HostCompilation.md
Inlining.md
InteropMigration.md
LanguageTutorial.md
Languages.md
ModuleMigration.md
NFI.md
OnStackReplacement.md
Optimizing.md
Options.md
Profiling.md
README.md
Safepoints.md
SpecializationHistogram.md
SpecializationTesting.md
StaticObjectModel.md
TCK.md
TraversingCompilationQueue.md
TruffleLibraries.md
TruffleStrings.md
context_references.png
exitschema.png
hardexitschema.png
external_repos
mx.truffle
src
CHANGELOG.md
CONTRIBUTING.md
LICENSE.md
OWNERS.toml
README.md
visualizer
vm
wasm
web-image
.clang-format
.gitattributes
.gitignore
.mx_vcs_root
CENSUS.md
CONTRIBUTING.md
LICENSE
README.md
SECURITY.md
THIRD_PARTY_LICENSE.txt
ci-branch-config.jsonnet
ci.jsonnet
common.json
graal-common.json
pyproject.toml
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/oracle/graal
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
layouttoc_grouplink_titlepermalink
docstruffleTruffle Language Implementation Framework/graalvm-as-a-platform/language-implementation-framework/

Truffle Language Implementation Framework

The Truffle language implementation framework (Truffle) is an open source library for building tools and programming languages implementations as interpreters for self-modifying Abstract Syntax Trees. Together with the open source Graal compiler, Truffle represents a significant step forward in programming language implementation technology in the current era of dynamic languages.

The Truffle artifacts are uploaded to Maven Central - Sonatype{:target="_blank"}. You can use them from your pom.xml file as:

<properties>
    <graalvm.version>24.2.0</graalvm.version> <!-- or any later version -->
</properties>
<dependency>
    <groupId>org.graalvm.truffle</groupId>
    <artifactId>truffle-api</artifactId>
    <version>${graalvm.version}</version> <!-- or any later version -->
</dependency>
<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.14.0</version>
            <configuration>
                <source>21</source>
                <target>21</target>
                <annotationProcessorPaths>
                    <path>
                        <groupId>org.graalvm.truffle</groupId>
                        <artifactId>truffle-dsl-processor</artifactId>
                        <version>${graalvm.version}</version>
                    </path>
                </annotationProcessorPaths>
            </configuration>
        </plugin>
    </plugins>
</build>

Implement Your Language

The Truffle framework allows you to run programming languages efficiently on GraalVM. It simplifies language implementation by automatically deriving high-performance code from interpreters.

Getting Started

We provide extensive Truffle API documentation. Start by looking at the TruffleLanguage class, which you should subclass to start developing a language. Truffle comes with the Graal Compiler and several language implementations as part of GraalVM.

A good way to start implementing your language with Truffle is to fork the SimpleLanguage project and start hacking. SimpleLanguage is a relatively small language implementation, well-documented, and designed to demonstrate most of the Truffle features. You could also try by looking at code in one of the existing open source languages implementations and experiments.

Advanced Topics

Implementing a language using Truffle offers a way to interoperate with other "Truffle" languages. To estimate if your language is a valid polyglot citizen, read about using the Polyglot API-based Test Compatibility Kit. Somewhat related topics worth exploring are Truffle Libraries, as well as how to use them to implement a language interoperability. Languages implemented with Truffle can also be embedded in Java host applications using the Polyglot API.

To better understand how to improve the performance of your language, see the documentation on Profiling Truffle Interpreters and Optimizing Truffle Interpreters. Also, to better understand how to use Truffle's automated monomorphization feature (for example, splitting), look at the related documentation.

Implement Your Tool

With the Truffle framework, you can develop language-agnostic tools such as debuggers, profilers, and other instrumentations. Start with looking at the TruffleInstrument class, which -- similar to TruffleLanguage -- one should subclass to start developing a tool.

If you want to implement your own "Truffle" tool, a good way to start is to fork the SimpleTool project -- like the SimpleLanguage project described above -- and start hacking. SimpleTool is a well-documented, minimalistic code-coverage tool designed to be a starting point for understanding the tool development process using Truffle.

Since tools, developed with Truffle, instrument the language using the same AST-node-based approach, most of the techniques available to language developers, in terms of improving performance, are available to the tool developers as well. This is why it is recommended that you understand how Truffle works from a language developer's perspective to get the maximum out of your tool.

Compatibility

The Truffle API is evolved in a backwards-compatible manner from one version to the next. When an API is deprecated, then it will stay deprecated for at least two GraalVM releases before it will be removed.

As a best practice it is recommended to upgrade Truffle only one version at a time. This way you can increment the version and fix deprecation warnings before continuing to the next version. The deprecated Javadoc tags on the deprecated APIs are designed to be a guide on how to upgrade.

The latest additions and changes can be seen in the changelog.

Modifying Truffle

To understand how to modify Truffle, check this file. If you would like to contribute to Truffle, consult the contribution documentation.

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors/GraalVM.git
git@gitee.com:mirrors/GraalVM.git
mirrors
GraalVM
GraalVM
master

搜索帮助