Re: [chromium-discuss] javascript libraries in V8 engine
Regarding the JavaScript files in the V8 source code:
1. They are in JS rather than C because they are simpler to code in
JS.  JS provides facilities like property assignment, object
allocation, etc. at a native level with the correct semantics needed
to implement the complicated builtin functions.  The compiler should
do a good job optimizing these functions for performance.

2. If snapshots are used, some are compiled at browser compile time,
and put in a snapshot.  Others are lazily compiled.  If snapshots are
not used, they are compiled at browser runtime.

3. Extending V8 with C language functions, to be called from the built-
in JS files, is easy using the "intrinsics" or "builtins" notation:
functions starting with % or %_ are compiled as a call to a C function
(%) or by calling a custom C function at compile time (%_).  These are
in src/runtime.h.  The best way for an embedder to add C functions to
V8, though, is through the API.  A function template can be created
that specifies a C function to be called when a function is called, or
when properties of an object are accessed.  Functions or objects
created from this template then call that C code at runtime.  This
does not require changes to the V8 source.

This thread will also be posted to the v8-dev mailing list.

>>Hi, all

>>I have some questions for v8 engine.

>>In the chrome source located in the following directory,
>>src/v8/src

>>there are some javascript files (may be they are javascript libraries)
>>such as array.js, string.js, math.js, date.js etc.

>>my questions are,
>>1. why they are coded with javascript language not with c/c++?
>>2. are they compiled during browser's running-time, not during browser
>>compile-time?
>>3. is it possible to extend the javascript files (in V8) with some
>>functions coded with c language using JNI?

>>Thank you in advance.
>>jjyoo

-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to