最佳编译目标 [英] Best Compiler Destination

查看:120
本文介绍了最佳编译目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几种语言,我一直在做翻译。当我准备采取下一步,什么选项最适合非本地编译格式...每个的利弊是什么?



我一直在寻找编译CLR或LLVM,并考虑C-midcompile几次,但我不完全确定。



一些功能希望能够端口如下:


  1. REPL - 我正在构建的语言之一在运行时支持块级评估。

  2. 强大的宏 - 我正在构建的其中一种语言需要在分词之前,以及在分词和解析之间的中间过滤代码。

好吧,不是真的几个,只是两个。我想我可以将任何其他功能,我的语言支持任何东西。



我最好的选择是什么和他们的优点/缺点?

解决方案

pro / cons:







    • pro:CLR环境随时可用;很多东西要绑定

    • con:绑定到CLR(;-);


  • 在某些系统上,

    LLVM:




    • pro:独立于MS。

    • con:涉及移植LLVM(?);

      C作为目标语言:

    • p>


      • pro:几乎所有目标都可能;容易代码生成

      • con:你必须实现一些VM作为运行时库(GC,dynload,dyn编译等);一些事情很难在C(连续,回溯,堆栈跟踪,异常);一些事情很难在C(GC,动态类型,堆栈布局依赖)中高效和便携。


    • Java ByteCode为目标:




      • pro:可能是最大的一套可能的目标平台(甚至手机和嵌入式东西);很多现有的工具;


    • con:有些事情很难实现或难以有效实现(动态类型,继续,回溯) / li>


    从上述所有情况来看,我认为定位Java ByteCode可能最适合您。



    EDIT:实际上是对注释的回答,但300个字符是不够的。



    JByteCode iffy-我同意(作为一个Smalltalker,JBytecode对我来说太限制)。



    VM,我认为有一个相对广泛的性能,你可以得到作为JVM,从纯慢字节码解释器到高端复杂的JITting VMs(IBM )。我想,CLR VM将赶上,因为MS迟早偷窃并集成所有创新,并且发布加速动态翻译的技术(例如阅读自我论文)。 LLVM可能会进步一点,但谁知道。使用C,您将从免费的更好的编译器中获益,但是动态重新转换等事情很难用C作为目标来实现。我自己的系统使用混合的预编译和动态编译的代码(具有:一个缓慢的字节码解释器,JITter和一个存储空间中的预编译的静态C代码)。


    I've got a few languages I've been building as interpreters. When I'm ready to take "that next step", what options are best for non-native compiled formats... what are the pros and cons of each?

    I've been looking at compiling to CLR or LLVM, and contemplated C-midcompile a few times, but I'm not completely certain.

    A few features I'm hoping to be able to port are as follows:

    1. REPL - One of the languages I'm building supports block-level evaluation during runtime.
    2. Robust Macros - One of the languages I'm building requires the ability to filter through code seperately before tokenizing, and in the midstep between tokenizing and parsing.

    Ok, not really "a few", just two. I like to think I can port any other features my languages support to "anything".

    What are my best options, and their pros/cons?

    解决方案

    pro/cons:

    • CLR:

      • pro: CLR environment readily available; a lot of stuff to bind to
      • con: bound to CLR (;-); targetting some systems will be hard or impossible (embedded, mainframes, etc. CLR impl. might be less mature on non MS systems)
    • LLVM:

      • pro: independent from MS.
      • con: targetting some systems might involve porting LLVM (?); interfacing to DOT-net, Java etc. might be troublesome (possibly needs FFI)
    • C as target language:

      • pro: almost all targets possible; easy code generation
      • con: you will have to implement some VM stuff as runtime library (GC, dynload, dyn compilation etc.); some things are hard to do in C (continuations, backtracking, stack tracing, exceptions); some things are hard to do efficiently and portable in C (GC, dynamic types, stack layout dependence).
    • Java ByteCode as target:

      • pro: probably the biggest set of possible target platforms (even mobil phones and embedded stuff); a lot of existing tools around; easy interfacing to existing libraries
      • con: some things are hard to implement or hard to implement efficiently (dynamic types, continuations, backtracking)

    From all the above, I think targeting Java ByteCode would probably be best for you.

    EDIT: actually an answer to a comment, but 300chars are not enough.

    JByteCode iffy - I agree (being a Smalltalker, JBytecode is too limiting for me).

    VM-wise, I think there is a relatively wide range of performance you can get as JVM, starting at pure slow bytecode interpreters up to high end sophisticated JITting VMs (IBM). I guess, CLR VM's will catch up, as MS is stealing and integrating all innovation anyway sooner or later, and the techniques to speedup dynamic translation are published (read the Self papers, for example). LLVM will probably progress a bit slower, but who knows. With C, you will benefit from better compilers for free, but things like dynamic retranslation etc. are hard to implement with C as target. My own system uses a mixture of precompiled and dynamically compiled code (having all: a slow bytecode interpreter, JITter and precompiled static C-code in one memory space).

    这篇关于最佳编译目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆