40 Commits

Author SHA1 Message Date
brendan%mozilla.org
4b80be2931 Ensure atom strings are immutable -- duh! (107138, r=jag, sr=jband).
git-svn-id: svn://10.0.0.236/trunk@106626 18797224-902f-48f8-a5cc-f745e15eee43
2001-10-30 02:33:41 +00:00
gerv%gerv.net
ae1d5501a1 Oops.
git-svn-id: svn://10.0.0.236/trunk@103236 18797224-902f-48f8-a5cc-f745e15eee43
2001-09-20 00:02:59 +00:00
scc%mozilla.org
2281a4d137 bug #98089: ripped new license
git-svn-id: svn://10.0.0.236/trunk@103230 18797224-902f-48f8-a5cc-f745e15eee43
2001-09-19 22:39:41 +00:00
brendan%mozilla.org
d72ef6fca0 Check keyword version when scanning, not by installing different keywords on version selection (when starting to compile; bug 96562, r=rogerl, sr=shaver&jband, a=dbaron).
git-svn-id: svn://10.0.0.236/trunk@101736 18797224-902f-48f8-a5cc-f745e15eee43
2001-08-24 03:32:31 +00:00
brendan%mozilla.org
678d939e1c Lazily pin the less likely atoms when resolving standard class names (77861, r=jst, sr=jband).
git-svn-id: svn://10.0.0.236/trunk@95787 18797224-902f-48f8-a5cc-f745e15eee43
2001-05-23 04:02:06 +00:00
brendan%mozilla.org
0abf3306e0 Re-init pinned atoms after 1=>0=>1 contexts-in-runtime transition (80619, sr=jband&shaver).
git-svn-id: svn://10.0.0.236/trunk@95024 18797224-902f-48f8-a5cc-f745e15eee43
2001-05-15 19:39:16 +00:00
brendan%mozilla.org
cd44bd5351 Don't zap atom state on last destroy-context in a runtime if interned strings are held by atoms, and/or rooted objects reach atoms -- there may be a new-first-context in the future (72043, r=jband, sr=shaver).
git-svn-id: svn://10.0.0.236/trunk@92185 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-13 08:06:15 +00:00
brendan%mozilla.org
d4d7f80d47 Don't assert about leaked atoms, do DEBUG fprints instead (68765, r=timeless, sr=jband).
git-svn-id: svn://10.0.0.236/trunk@87034 18797224-902f-48f8-a5cc-f745e15eee43
2001-02-14 22:25:30 +00:00
brendan%mozilla.org
be138b52b8 - Keep interned string atoms around across zero-context episodes on a runtime,
until JS_DestroyRuntime is called (68450, r=rginda, sr=jband).
- NUL-terminate tagbuf in tagify, for the HTML helpers such as string.big()
  (66648, r=timeless, sr=jband).


git-svn-id: svn://10.0.0.236/trunk@86863 18797224-902f-48f8-a5cc-f745e15eee43
2001-02-13 00:57:10 +00:00
brendan%mozilla.org
88999be56e Fixes for bug 33390 (r=mccabe, sr=shaver)
- Optimize compile (parse+emit) operation to generate code for each top-level
  statement or function in turn, recycling JSParseNodes as we go for greatly
  reduced "long linear script" footprint.
- Fix O(n**2) growth problems in bytecode and srcnote generation.
- Add js_ParseTokenStream entry point to compiler, for tree-generation without
  code-generation.  Move JSOP_EVAL instruction selection from code-generator to
  parser, to match other such specializations and enable js_ParseTokenStream.
- Fix js_CompileTokenStream (and get it right in new js_ParseTokenStream) to
  respect JSOPTION_VAROBJFIX.
- Clean up bracing, multi-line conditions, and overlong lines.


git-svn-id: svn://10.0.0.236/trunk@85619 18797224-902f-48f8-a5cc-f745e15eee43
2001-01-27 08:00:45 +00:00
brendan%mozilla.org
ff9815b123 All this r=mccabe, r=beard, and sr=jband -- many thanks to all who helped,
especially to jband for his great stress-test setup and particularly helpful
(in terms of reproducing bugs in draft patches) MP and laptop machines.

- Radical(*) object (scope) locking optimization: don't lock if a scope is
  accessed on the context that exclusively owns it (initially, the context
  on which the scope was created).  Once a scope becomes shared among more
  than one owner-context, give it the usual thin or fat lock, per existing
  jslock.c code.

  I did this at the memory cost of another word per JSScope, ownercx, which
  raised scope size from 12 to 13 words if !DEBUG.  I also added a linked
  list head pointer, rt->scopeSharingTodo, and a scopeSharingDone condition
  variable to JSRuntime, and a scopeToShare pointer to JSContext that's
  necessary for deadlock avoidance.

  The rt->scopeSharingTodo list links JSScopes through the scope->u.link
  union arm, which overlays the pre-existing scope->count (now u.count)
  member.  This list holds scopes still exclusively owned by a context, but
  wanted by js_LockScope calls active on other threads.  Those calls wait
  on the rt->scopeSharingDone condition, which is notified every time an
  owner-context ends the request running on it, in which code active on
  that context may be using scope freely until end of request.

  The code that waits on rt->scopeSharingDone must first suspend any and
  all requests active on the calling context, and resume those contexts
  after the wait is notified.  This means a GC could happen while the
  thread locking a scope owned by another thread's context blocks; all
  calls to JS_LOCK_OBJ must therefore first home fp->sp above any live
  operands, e.g.  The interpreter takes care to do that already.

  To avoid AB-BA deadlocks, if a js_LockScope attempt on one context finds
  that the owner-context of the scope is already waiting on a scope owned
  by the current context (or indirectly depending on such a scope lock),
  the attempt converts the scope from lock-free exclusive ownership to
  shared ownership (thin or fat lock).

- Fix js_SetupLocks and the js_LockGlobal/js_UnlockGlobal code to avoid
  divmod instruction costs, strength-reducing to bit-mask instructions.

- The radical lock-free scope change required care in handling the 0=>1
  and 1=>0 transitions of cx->requestDepth, which was till now thread-local
  because part of the JSContext not manipulated by other threads.  It's
  still updated only by cx's thread, but it is read by other threads in
  the course of attempting to claim exclusive ownership of a scope for more
  lock-free JS object operations.

- The JS_SuspendRequest and JS_ResumeRequest APIs have changed incompatibly
  to require their caller to save and restore the requestCount found when
  JS_SuspendRequest is called.  This is necessary to avoid deadlock; sorry
  for the incompatible change.

- Fixed various nits in jslock.[ch], including using Init/Finish rather
  than New/Destroy for the methods that take a JSThinLock and initialize
  and finish/free its members.  Another example: JS_ATOMIC_ADDREF is now
  JS_ATOMIC_INCREMENT and JS_ATOMIC_DECREMENT, so the two cases can be
  mapped to PR_AtomicIncrement and PR_AtomicDecrement.  This entailed
  changing jsrefcount from jsword to int32 (PRInt32).

- No need to use JS_ATOMIC_INCREMENT on JSScopeProperty.nrefs, as it is
  always and everywhere protected by the property's JSScope.lock.

- Cleaned up gratuitous casts in jscntxt.c by using &cx->links, etc.

- The lock used for mutual exclusion around both request begin and end vs.
  GC synchronization is rt->gcLock, and this lock now also protects all
  scope->ownercx pointer changes from non-null (exclusive) to null (shared),
  the rt->scopeSharingTodo/scope->u.link list operations, and of course the
  rt->scopeSharingDone condition.

  But this means that js_GC cannot hold rt->gcLock across the bulk of its
  body, in particular the mark phase, during which JS_GetPrivate calls,
  e.g., may need to "promote" scope locks from lock-free to thin or fat,
  because doing so would double-trip.  There never was any good reason to
  hold rt->gcLock so long, of course -- locks are for mutual exclusion, not
  for waiting or notifying a thread -- those operations require a condition,
  rt->gcDone, which we already use along with rt->gcLevel to keep racing GC
  attempts at bay.

  So now that rt->gcLock does not protect the mark phase, the enumeration
  of rt->gcRootsHash can race badly with JS_RemoveRootRT, an API that may
  legitimately be called outside of a request, without even a context.  It
  turns out that people may be cheating on the request model even with
  JS_AddRoot, JS_AddNamedRoot, and JS_RemoveRoot calls, so we must make
  all of those interlock with the GC using gcLevel and gcDone, unless they
  are called on the gcThread.

  Also, since bug 49816 was fixed, there has been no need for a separate
  finalize phase, or for rt->gcFinalVec.  Finalizers can no longer allocate
  newborn GC-things that might be swept (because unmarked), or double-trip
  on rt->gcLock (which is no longer held).  So js_GC finalizes as it sweeps,
  just as it did in days of old.

- I added comments to jslock.h making it plain that callers of JS_LOCK_OBJ
  and JS_UNLOCK_OBJ must either be implementations of js_ObjectOps hooks,
  or code reachable only from those hooks; or else must be predicated on
  OBJ_IS_NATIVE tests.  It turns out jsinterp.c's CACHED_GET and CACHED_SET
  macros neglected to do such tests, limiting the ability of JS embeddings
  to implement JSObjectOps with their own non-JSScope JSObjectMap subclass.
  Fixed, small performance hit that the lock-free optimization should more
  than make up for.

- jslock.c now gives a #error if you try to compile it on a platform that
  lacks a compare-and-swap instruction.  The #error says to use NSPR locks.
  Before this change, some platforms would emulate compare-and-swap using
  a global PRLock, which is always worse in runtime than using per-scope
  PRLocks.


git-svn-id: svn://10.0.0.236/trunk@83229 18797224-902f-48f8-a5cc-f745e15eee43
2000-12-04 02:43:31 +00:00
brendan%mozilla.org
4e4aa590e8 Fix bungled GC_KEEP_ATOMS logic (51954, r=mccabe, a=jband).
git-svn-id: svn://10.0.0.236/trunk@80110 18797224-902f-48f8-a5cc-f745e15eee43
2000-09-29 00:18:15 +00:00
brendan%mozilla.org
c4ea797337 Fix C++ portability and AIX compilation problem due to last C++ porting attempt (48976, r=jdunn@netscape.com).
git-svn-id: svn://10.0.0.236/trunk@78593 18797224-902f-48f8-a5cc-f745e15eee43
2000-09-09 05:53:00 +00:00
brendan%mozilla.org
e85122f78b Clean up JSObjectOps layering violations by adding mark and clear ops; JSClass gets a corresponding mark op so classes with unregistered roots in private data can mark them. The JS API gets a new JS_MarkGCThing entry point for JSObjectOps.mark implementors. Prerequisite check-in for bug 49816 and others (r=shaver).
git-svn-id: svn://10.0.0.236/trunk@77238 18797224-902f-48f8-a5cc-f745e15eee43
2000-08-26 02:30:22 +00:00
brendan%mozilla.org
3802be8867 Support lazy initialization of standard classes and their associated global functions/properties (46703, r=jband,rogerl).
git-svn-id: svn://10.0.0.236/trunk@76699 18797224-902f-48f8-a5cc-f745e15eee43
2000-08-19 08:37:07 +00:00
rogerl%netscape.com
ccc73deb34 r,a=brendan@mozilla.org. Adding missing ECMA3 compliance toLocaleXXX
functions to built-in Array, Date and Object object prototypes.


git-svn-id: svn://10.0.0.236/trunk@75908 18797224-902f-48f8-a5cc-f745e15eee43
2000-08-09 21:46:03 +00:00
brendan%mozilla.org
06dce89eb2 What a dork, I didn't test-build on Linux!
git-svn-id: svn://10.0.0.236/trunk@74692 18797224-902f-48f8-a5cc-f745e15eee43
2000-07-24 21:28:08 +00:00
putterman%netscape.com
5f741e9c79 backing out brendan's changes to fix build
git-svn-id: svn://10.0.0.236/trunk@74689 18797224-902f-48f8-a5cc-f745e15eee43
2000-07-24 21:13:13 +00:00
morse%netscape.com
56e7f14d9b attempt to fix build bustage
git-svn-id: svn://10.0.0.236/trunk@74687 18797224-902f-48f8-a5cc-f745e15eee43
2000-07-24 21:03:41 +00:00
brendan%mozilla.org
1808da68e2 Micro-optimize source (compilers probably do it, but hey); fix a comment.
git-svn-id: svn://10.0.0.236/trunk@74685 18797224-902f-48f8-a5cc-f745e15eee43
2000-07-24 20:17:24 +00:00
jband%netscape.com
4ac0a9c150 drastically reduce unnecessary malloc calls from js_Atomize. r=brendan@mozilla.org. a=brendan@mozilla.org
git-svn-id: svn://10.0.0.236/trunk@74570 18797224-902f-48f8-a5cc-f745e15eee43
2000-07-21 00:57:19 +00:00
brendan%mozilla.org
e59f31abff Make it safe to nest a GC from js_AllocGCThing, ultimately from the interpreter; also make sure we collect all garbage (even garbage created by finalizers who unroot or unlock GC-things) when destroying the last context (39125, 44376, r=mccabe@netscape.com).
git-svn-id: svn://10.0.0.236/trunk@73871 18797224-902f-48f8-a5cc-f745e15eee43
2000-07-08 02:06:01 +00:00
brendan%mozilla.org
53d858c363 Fix the TOO_MUCH_GC define (optional for GC stress-testing, not part of build).
git-svn-id: svn://10.0.0.236/trunk@69053 18797224-902f-48f8-a5cc-f745e15eee43
2000-05-10 19:56:21 +00:00
rogerl%netscape.com
4b50f30017 Bug #32677, r=rginda bugs in Win32 optimized version for edge cases in
Math.exp and Math.pow
Bug #32937, r=rginda, implement missing toLocaleString


git-svn-id: svn://10.0.0.236/trunk@64520 18797224-902f-48f8-a5cc-f745e15eee43
2000-03-29 23:45:07 +00:00
rogerl%netscape.com
5433804427 r=brendan@mozilla.org
Prepare for new setter/getter syntax.


git-svn-id: svn://10.0.0.236/trunk@60513 18797224-902f-48f8-a5cc-f745e15eee43
2000-02-11 22:19:33 +00:00
brendan%mozilla.org
43d1d6a141 - Eliminate ancient, bogus proxying of function object for its call objects (23346, r=jband@netscape.com).
- Tabs expanded as much as I could stand, without taking too much cvsblame.


git-svn-id: svn://10.0.0.236/trunk@59716 18797224-902f-48f8-a5cc-f745e15eee43
2000-02-04 02:01:49 +00:00
mccabe%netscape.com
7113e5b3ae Changes to allow Spider Monkey to be compiled under C++.
Courtesy Bill Gibbons <bill@gibbons.org>

His comments:

Here are the changes to JSRef to make it compile either as C or C++. Mostly the changes are to add missing casts (since C++ doesn't have implict conversion from void* to other pointer types nor implicit casts from ints to enumerations) plus a few random things like the use of "private" as a variable name.

There are a few other minor bug fixes; in particular:

  * A long statement with and'ed conditions is reformatted to make it easier to remove other builtin objects (e.g. Date).

  * A #if was added to jsscript.c for the JS_HAS_SCRIPT_OBJECT off case.

  * In jsmath a #ifdef was changed to #if.

My notes also mention...

  * jsobj.c should include jsopcode.h

  * jsfun.c - doesn't link if JS_HAS_ARGS_OBJECT is off

  * jsarray.c - a reference to js_ValueToSource should be conditional on JS_HAS_TOSOURCE

r=mccabe


git-svn-id: svn://10.0.0.236/trunk@59455 18797224-902f-48f8-a5cc-f745e15eee43
2000-02-02 01:10:31 +00:00
brendan%mozilla.org
b7a83ca82c JS1.5 fixes (17290, 21618, plus shaver's 22243 fix, r=shaver@mozilla.org).
git-svn-id: svn://10.0.0.236/trunk@58086 18797224-902f-48f8-a5cc-f745e15eee43
2000-01-18 11:06:05 +00:00
dmose%mozilla.org
ec2434440d update license boilerplate to NPL-1.1 dual-licensed with the GPL. a=brendan, r=brendan.
git-svn-id: svn://10.0.0.236/trunk@49258 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-28 23:12:09 +00:00
brendan%mozilla.org
1041763b2e - Bumped default compile-time JS version from 1.4 to 1.5.
- Add JS1.5 getter/setter support in all its glory:

  * getter function SN() {return ++x} at top-level or as a closure binds an SN
    property getter than returns the incremented value of x.  Likewise for
    setter function SN(y) {return y = x}.

  * getters and setters may be defined in an object literal:
      o = {p getter:function() {return ++this.x},
           p setter:function(y){return this.x = y},
           x:42};

  * getter= and setter= operators (compound tokens) may be used to bind getter
    and setter properties dynamically:
      o = new Object;
      o.p getter= function() {return ++this.x};
      o.p setter= function(y){return this.x = y};
      o.x = 42;

    Waldemar is concerned that this form will collide semantically with JS2, so
    I am not committing to keeping it in JS1.5.  I'd like to check my code in
    ASAP so shaver can use it, and I'd also like to see this form get used (or
    not) during Mozilla betas.  Caveat emptor, and if you find this "dynamic"
    or "imperative" form necessary and hard to substitute, please let me know.
    If this proves important to users, then I think JS1.5 should keep it.

- Cleaned up property flags (in a binary-incompatible fashion -- who cares?) by
  eliminating JSPROP_ASSIGNHACK and JSPROP_TINYIDHACK.

- Added JS_DONT_PRETTY_PRINT flag to be ORed with the indent argument to the
  several JS_Decompile*() API calls.  This avoids any newlines or identation in
  the decompiled string.
 
- Improved and extended (for getter/setter non-reservation) scanner lookahead
  by using a circular (power-of-2 sized) token buffer.

- Fix ECMA Edition 3 deviation where function f(){function g(){}} bound f.g by
  mistake (it should arrange to make a closure named g in activations of f, but
  it should not bind a property of function f).


git-svn-id: svn://10.0.0.236/trunk@48436 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-21 00:13:48 +00:00
waldemar%netscape.com
81c94d6509 Added NaN atom
git-svn-id: svn://10.0.0.236/trunk@47751 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-16 07:09:24 +00:00
brendan%mozilla.org
691b3263fd Rip out assign hack, simplify boolean value synthesis, minor cleanups.
git-svn-id: svn://10.0.0.236/trunk@37627 18797224-902f-48f8-a5cc-f745e15eee43
1999-07-01 02:25:47 +00:00
brendan%netscape.com
af49c2cbb7 - Add (jsatomid) cast to GET_ATOM_INDEX to abate warnings.
- Fix js_GetAtom fallibility by returning &dummy on assert-botch "can't happen"
  index out of range case.
- js_InitAtomMap needn't bother nulling ale->next with tmp save
- js_InitAtomState explicit tail fusion for FROB via goto bad, and early memset
  (I know, JSRuntime is cleared already and it contains the atom state ... but
  jsatom.c doesn't know that).
- Clear all ATOM_ flags save ATOM_PINNED when creating a new atom.
- Cleanup xtra, ALIGNNUM, etc. useless variables, use JSVAL_ALIGN and JS_MAX.


git-svn-id: svn://10.0.0.236/trunk@37314 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-29 02:20:48 +00:00
fur%netscape.com
dc0c8d45d1 Merge changes from SpiderMonkey140_BRANCH. Note: none of the
added files participate in the client build.


git-svn-id: svn://10.0.0.236/trunk@29432 18797224-902f-48f8-a5cc-f745e15eee43
1999-04-27 15:18:57 +00:00
mccabe%netscape.com
a02a1efd96 Stable drop of JavaScript interpreter code from SpiderMonkey140_BRANCH
git-svn-id: svn://10.0.0.236/trunk@14116 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-05 00:08:43 +00:00
fur%netscape.com
e655606d45 Checkpoint JS1.4 from JS_STABLE_10131998_BRANCH. Changes include:
+ merging of js/src and js/ref
 + elimination of most dependencies on NSPR
 + JS1.4 feature additions and accumulated bug fixes

More details are in last week's mozilla status report.


git-svn-id: svn://10.0.0.236/trunk@12797 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-14 10:22:38 +00:00
mccabe%netscape.com
b32b6c20e8 Propagating numerous fixes from js/ref
and development branches, including but
not limited to:

- Preliminary exception handling per
ECMA proposal; try, multiple
catchblocks, and finally.  Catchblocks
are of the form catch (v) or
catch(v:<guard>), where guard is an
optional boolean expression that is
evaluated to determine whether the
exception is to be caught by that block.

- ECMA-proposed 'in' operator; "'foo' in
o" or "4 in o" asks if o has property
foo or element 4.

- Added a new set of defines in
jsconfig.h for js 1.4
features-in-progress.  (in, instanceof,
exception handling.)  Default build
version is now 1.4.  Fixed a few
conditional features that had become
broken.

- Progress towards porting to FreeBSD
and Alpha; casts of NaN and friends to
int are a little more localized.  Not
there yet...

- New config files to compile on more
OSes; various fixes to improve
portability.


git-svn-id: svn://10.0.0.236/trunk@6907 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-31 00:07:22 +00:00
fur
aea62596b0 Propagation of numerous bug fixes from 4.06 (which have been reviewed
and tested in that release):

#114564: Fix JS_Enumerate to return an empty id array instead of null
#115395: Fix JS garbage collection
#115200: Security dialog no longer blows assertion
#123211: Make sure output of sort array function is -1, 0, or 1.
#116195: Fix ImportProperty(), cope with an existing local variable
         of the same name as the imported property
         Unbusticate JS_invoke() so that closures work again
#115384,#115395: Handle bugs in toSource that strike when
         getProperty is non-idempotent.  Fix crash during JavaScript
         garbage collection after enumerating object properties.

#??????: mjudge - Win16 files to make ptrdiff_t be 32 bits on Win16


git-svn-id: svn://10.0.0.236/trunk@3573 18797224-902f-48f8-a5cc-f745e15eee43
1998-06-09 23:04:48 +00:00
fur
6e3cdaec31 Initial checkin of JavaScript 1.3, migrated from JSFUN13_BRANCH in /m/src repository
git-svn-id: svn://10.0.0.236/trunk@578 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-24 00:31:11 +00:00
ltabb
8ed5afe62c Free the lizard
git-svn-id: svn://10.0.0.236/trunk@10 18797224-902f-48f8-a5cc-f745e15eee43
1998-03-28 02:44:41 +00:00