WebKit是Mac OS X v10.3及以上版本所包含的软件框架(对v10.2.7及以上版本也可通过软件更新获取)。 同时,WebKit也是Mac OS X的Safari网页浏览器的基础。WebKit是一个开源项目,主要由KDE的KHTML修改而來並且包含了一些来自苹果公司的一些组件。
传统上,WebKit包含一个网页引擎WebCore和一个脚本引擎JavaScriptCore,它们分别对应的是KDE的KHTML和KJS。不过,随着JavaScript引擎的独立性越来越强,现在WebKit和WebCore已经基本上混用不分(例如Google Chrome采用V8引擎,却仍然宣称自己是WebKit内核)。
V8 是 Google 的开源 JavaScript 引擎。
V8 采用 C++ 编写,可在 Google Chrome()中使用。
V8 根据 ECMA-262 第三版中的说明使用 ECMAScript,并在使用 IA-32 或 ARM 处理器的 Windows XP 和 Vista、Mac OS X 10.5 (Leopard) 以及 Linux 系统中运行。
V8 可以独立运行,也可以嵌入任何 C++ 应用程序中。
/* Eratosthenes Sieve prime number calculation. */ size = 8190; sizepl = 8191; var flags = new Array(sizepl); var i, prime, k, count, iter; print("10 iterations\n"); starttime = new Date(); for (iter = 1; iter <= 10; iter++) { count = 0; for (i = 0; i <= size; i++) flags[i] = true; for (i = 0; i <= size; i++) { if (flags[i]) { prime = i + i + 3; k = i + prime; while (k <= size) { flags[k] = false; k += prime; } count += 1; } } } elapsedtime = new Date() - starttime; print("\n" + count + " primes\n"); print("elapsed time = " + elapsedtime + "\n");
Google Chrome, Google's open source browser.
This documentation is aimed at C++ developers who want to use V8 in their applications, as well as anyone interested in V8's design and performance. This document introduces you to V8, while the remaining documentation shows you how to use V8 in your code and describes some of its design details, as well as providing a set of JavaScript benchmarks for measuring V8's performance.
V8 implements ECMAScript as specified in ECMA-262, 3rd edition, and runs on Windows XP and Vista, Mac OS X 10.5 (Leopard), and Linux systems that use IA-32 or ARM processors.
V8 compiles and executes JavaScript source code, handles memory allocation for objects, and garbage collects objects it no longer needs. V8's stop-the-world, generational, accurate garbage collector is one of the keys to V8's performance. You can learn about this and other performance aspects in V8 Design Elements.
JavaScript is most commonly used for client-side scripting in a browser, being used to manipulate Document Object Model (DOM) objects for example. The DOM is not, however, typically provided by the JavaScript engine but instead by a browser. The same is true of V8—Google Chrome provides the DOM. V8 does however provide all the data types, operators, objects and functions specified in the ECMA standard.
V8 enables any C++ application to expose its own objects and functions to JavaScript code. It's up to you to decide on the objects and functions you would like to expose to JavaScript. There are many examples of applications that do this, for example: Adobe Flash and the Dashboard Widgets in Apple's Mac OS X and Yahoo! Widgets.
First you'll need to download the V8 source code and build V8, following the download and build instructions. Then see Getting Started for an introduction to V8 code with a quick "Hello World" example.