Facebook发布HipHop JIT(译文)

Facebook发布HipHop JIT
Fackbook 发布了PHP运行环境HipHop。HipHop提供JIT能力,替代了PHP传统运行和提供更好的页面解释性能,更低的CPU占用率。HipHop有助于提供可观的PHP可测量性和与Java,Python和C++为后端的最优的接口

倒不如说用一个结构复杂的HTML的微缓存系统,或者源码级的代码翻译器,Facebook的赵海平描述HipHop如何工作:
为PHP而产生的HipHop从技术上自身不是一个编译器。在一宽程序上它是一个源代码翻译器。HipHop程式化的翻译你的PHP代码到高性能C++,然后用g++去编译它。HipHop用一个相当语义的手法来执行源代码,并去牺牲一些极少用的特性。例如eval(),作为替代的是提高了性能。HipHop包括一个代码翻译器,一个PHP运行期系统的实现,和针对许多普通PHP扩展,利用这些性能最优化的重写模块。
翻译器处理包括三个主要步骤:
1.    静态分析,在此系统收集信息,谁宣告什么和依赖
2.    类型推断,在此将选择在C++ scalars, String, Array, classes, Object,中具体的类型
3.    代码生成,多半是一个从PHP声明和表达式到C++的声明和表达式的直接对应
总体而言,HipHop允许Facebook为PHP保持最佳表现,当利用到C++的性能优势时。总计,他们已经写了超过300,000行的代码超过5,000个单元测试,所有这些发布在开源PHP协议下面GitHub上。

Facebook Releases HipHop JIT

Posted by: Eugene Ciurana on ?? 03, 2010 DIGG
Facebook announced the HipHop for PHP runtime environment. HipHop provides JIT capabilities to PHP that supercede the traditional PHP runtime and provide better page rendering performance with lower CPU usage. HipHop helps to provide massive PHP scalability and optimal interfacing with Java, Python, and C++ back-ends.

Rather than using a complicated HTML particle caching system, or source-level code transformations, Haiping Zhao of Facebook describes how HipHop works:
HipHop for PHP isn't technically a compiler itself. Rather it is a source code transformer. HipHop programmatically transforms your PHP source code into highly optimized C++ and then uses g++ to compile it. HipHop executes the source code in a semantically equivalent manner and sacrifices some rarely used features -- such as eval() -- in exchange for improved performance. HipHop includes a code transformer, a reimplementation of PHP's runtime system, and a rewrite of many common PHP Extensions to take     advantage of these performance optimizations.

The transformation process includes three main steps:

1. Static analysis where the system collects information on who declares what and dependencies
2. Type inference where it chooses the most specific type between C++ scalars, String, Array, classes, Object, and Variant
3. Code generation which for the most part is a direct correspondence from PHP statements and expressions to C++ statements and expressions.

Overall HipHop allowed Facebook to keep the best aspects of PHP while taking advantage of the performance benefits of C++. In total, they have written over 300,000 lines of code and more than 5,000 unit tests. All of this is released on GitHub under the open source PHP license.

 

 

源文:http://www.theserverside.com/news/thread.tss?thread_id=59350

你可能感兴趣的:(C++,c,PHP,python,Facebook)