diff --git a/mozilla/js/src/README.html b/mozilla/js/src/README.html index 3dc49b3d19b..2132cea2029 100644 --- a/mozilla/js/src/README.html +++ b/mozilla/js/src/README.html @@ -73,7 +73,8 @@ Table of Contents
JSRef builds a library or DLL containing the @@ -81,12 +82,13 @@ JavaScript runtime (compiler, interpreter, decompiler, garbage collector, atom manager, standard classes). It then compiles a small "shell" program and links that with the library to make an interpreter that can be used interactively and with test .js files to run scripts. The code has -no dependencies on the Navigator code. +no dependencies on the rest of the Mozilla codebase.
Quick start tip: skip to "Using the JS API" below, build the js shell, and play with the object named "it" (start by setting 'it.noisy = true').
/* For each context you've created: */ JS_DestroyContext(cx); + /* For each runtime: */ + JS_DestroyRuntime(rt); + /* And finally: */ - JS_Finish(rt);+ JS_ShutDown();
The decompiler translates postfix bytecode into infix source by consulting a separate byte-sized code, called source notes, to disambiguate bytecodes that result from more than one grammatical production. -
The GC is a mark-and-sweep, non-conservative (perfect) collector. It +
The GC is a mark-and-sweep, non-conservative (exact) collector. It can allocate only fixed-sized things -- the current size is two machine words. It is used to hold JS object and string descriptors (but not property lists or string bytes), and double-precision floating point numbers. It -runs automatically only when maxbytes (as passed to JS_Init()) +runs automatically only when maxbytes (as passed to JS_NewRuntime()) bytes of GC things have been allocated and another thing-allocation request is made. JS API users should call JS_GC() or JS_MaybeGC() between script executions or from the branch callback, as often as necessary. -
An important point about the GC's "perfection": you must add roots for +
An important point about the GC's "exactness": you must add roots for new objects created by your native methods if you store references to them into a non-JS structure in the malloc heap or in static data. Also, if you make a new object in a native method, but do not store it through the @@ -523,14 +540,14 @@ so that it is in a known root, the object is guaranteed to survive only until another new object is created. Either lock the first new object when making two in a row, or store it in a root you've added, or store it via rval. +See the GC tips +document for more.
The atom manager consists of a hash table associating strings uniquely with scanner/parser information such as keyword type, index in script or function literal pool, etc. Atoms play three roles in JSRef: as literals referred to by unaligned 16-bit immediate bytecode operands, as unique string descriptors for efficient property name hashing, and as members -of the root GC set for perfect GC. This design therefore requires atoms -to be manually reference counted, from script literal pools (JSAtomMap) -and object symbol (JSSymbol) entry keys. +of the root GC set for exact GC.
Native objects and methods for arrays, booleans, dates, functions, numbers, and strings are implemented using the JS API and certain internal interfaces used as "fast paths". @@ -541,7 +558,7 @@ code can substitute its own error reporting function and suppress errors, or reflect them into Java or some other runtime system as exceptions, GUI dialogs, etc..