博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
NanoJIT
阅读量:7186 次
发布时间:2019-06-29

本文共 4975 字,大约阅读时间需要 16 分钟。

Tamarin Project

  •  
  •  
  •  
  •  
  •  
  •  
  •  

The goal of the "Tamarin" project is to implement a high-performance, open source implementation of the ECMAScript 4th edition (ES4) language specification. The Tamarin virtual machine will be used by Mozilla within SpiderMonkey, the core JavaScript engine embedded in Firefox®, and other products based on Mozilla technology. The code will continue to be used by Adobe as part of the ActionScript™ Virtual Machine within Adobe® Flash® Player.

The Tamarin virtual machine currently implements the ECMAScript 3rd edition language standard that is the basis for JavaScript, Adobe ActionScript, and Microsoft Jscript, plus some of the new language features proposed in the ECMAScript 4th edition specification. By working on an open source implementation of ES4 with the community, Adobe and Mozilla hope to accelerate the adoption of a standard language for creating engaging Web applications. We hope the Tamarin project accelerates the ability of developers to create and deliver richer, more interactive experiences that work across multiple platforms.

Tamarin will support the forthcoming ECMAScript Edition 4 ("JS2") language and will be integrated into SpiderMonkey as part of the Mozilla 2 project, to be released in 2008.  provides broad details on Mozilla 2 and Tamarin's role in this roadmap.

The Tamarin project is just getting started so the roadmap is not yet fully developed, but some of the technical goals include:

  1. Integrating the Tamarin VM and garbage collector within SpiderMonkey
  2. Using the SpiderMonkey compiler to generate code for Tamarin
  3. Porting the just-in-time compiler to new hardware platforms
  4. Completing the self-hosting ECMAScript 4 compiler

This page will be updated as the roadmap is defined.

The primary source code for Tamarin is available via Mercurial at . There is an experimental branch available at . This code is licensed under the same Mozilla tri-license (MPL/GPL/LGPL) as other Mozilla code.

Preliminary documentation for Tamarin, as well as build instructions, can be found at the .

The self-hosting compiler contains the foundation of a compiler but much work remains to make it fully functional.

Entries in NanoJIT (2)

Many dynamic language virtual machines (VM) written in C++ work by compiling code that passes parameters into VM C++ methods which do most of the heavy lifting. For example, adding two values becomes two x86 pushes onto the stack with a x86 call into a C++ method add. When I last looked at Apple's SquirrelFish, that's all it did. The generated x86 code in Tamarin more or less does the same thing with a few optimizations. And having such a simple compiler works surprisingly well, but it only takes you so far. Sooner or later, you'll want to generate better, faster machine code.

An effective way of generating faster code is . Instead of generating calls, the JIT should inline the methods that do the real work. The problem for Tamarin's JIT, is that it doesn't know how to inline C++ methods. NanoJIT only compiles LIR, not C++. Enter the C++ to LIR translator.

We do this by statically compiling Tamarin with . LLVM is a pretty awesome GCC replacement that is nicely designed, object oriented, and generally a pleasure to work with. The output of LLVM is like an object file, but instead contains . This new tool then translates LLVM bitcode into LIR. At runtime, Tamarin compiles the LIR, which really represents a VM C++ method. Boom, inlinable C++ methods.

We don't have to apply the translator to only method inlining. In essence, Tamarin compiles VM C++ methods as if they were ActionScript methods. Application ActionScript, such as a youtube video, prior to execution, is translated into LIR, which is then compiled into machine code. We also translate most of Tamarin, written in C++, into LIR, which is then compilable into machine code by NanoJIT. NanoJIT has the power to compile, inline, and optimize VM C++ methods for the performance win.
You may be thinking, hmm this sounds an awfully like a . A self-interpreting VM is a VM written in the language it executes. For example, writing a JavaScript VM in JavaScript would make it self-interpreting. Well, you're right. This approach hacks in self-interpreting/JITting into a VM written in C++.

Consider the three images above just to clarify the differences. The "standard" VM approach, and what Tamarin did before, is to JIT code that calls into C++ methods. The host C++ compiler (Visual Studio/GCC) does a lot of work, and the JIT has no idea what was going on. In a self-interpreting VM, the JIT compiles everything, application and VM code, and knows everything about itself. This approach mimics a self-interpreting VM by translating C++ methods into LIR, and JITing both application and VM code.

Over the next few weeks, I'll be detailing the implementation/design decisions in Tamarin.

Thanks to  for proofreading and creating the images. Checkout this  if you are wondering what More Cowbell is.

转载地址:http://xgukm.baihongyu.com/

你可能感兴趣的文章
一款jQuery满屏自适应焦点图切换特效
查看>>
python技能(2)-sys.argv
查看>>
NFS 安装问题解决
查看>>
对 Sea.js 进行配置 seajs.config
查看>>
我几次求职经验谈--智联相伴
查看>>
PHP中文乱码问题总结[转]
查看>>
IPv6系列-入门指南
查看>>
spring学习笔记(二)
查看>>
DNS智能解析的另类使用 让搜索引擎更快更好的收录您的网站
查看>>
转:java操作文件
查看>>
工具系列——eslint的使用
查看>>
思科IOS配置五大技巧
查看>>
phpwind 论坛迁移过程
查看>>
14个Web移动编程视频网站资源分享
查看>>
我的友情链接
查看>>
nonatomic,assign,copy,retain的区别(转)
查看>>
ubuntu 18.04 docker 学习经历(三)Docker mysql 及 phpmyadmin
查看>>
CentOS 7下JumpServer安装及配置
查看>>
Go36-33-临时对象池(sync.Pool)
查看>>
Android平台Firefox——Fennec编译手记
查看>>