68 Commits

Author SHA1 Message Date
brendan%mozilla.org
8f250bac4f Add exception object stack property, string valued; clean up NULL/VOID mixup, missing OOM test, etc. (123177, r=rginda, sr=shaver).
git-svn-id: svn://10.0.0.236/trunk@114140 18797224-902f-48f8-a5cc-f745e15eee43
2002-02-09 06:28:58 +00:00
brendan%mozilla.org
056cf28a63 Remove __call__ and add a callback used to check f.caller access for any function object f (109113, r=jst, sr=jband).
git-svn-id: svn://10.0.0.236/trunk@108257 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-16 02:56:49 +00:00
brendan%mozilla.org
d33cfeae5d epstein@tellme.com's patch implementing JS_ClearNewbornRoots (106790, r=brendan, sr=jband).
git-svn-id: svn://10.0.0.236/trunk@106312 18797224-902f-48f8-a5cc-f745e15eee43
2001-10-26 02:38:10 +00:00
brendan%mozilla.org
2163e55b8e Add mutable (growable or dependent, two subtypes) strings to solve O(n^2) and O(n^3) growth rates (56940, r=rogerl, sr=jband&shaver).
git-svn-id: svn://10.0.0.236/trunk@106213 18797224-902f-48f8-a5cc-f745e15eee43
2001-10-25 00:26:38 +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
5f91bd99d8 Checking in shaver's patch for bug 78100, adding JS_GetExternalStringGCType (sr=brendan&jband).
git-svn-id: svn://10.0.0.236/trunk@101473 18797224-902f-48f8-a5cc-f745e15eee43
2001-08-21 02:53:19 +00:00
brendan%mozilla.org
f031c3036a Shrink principals struct back to where it was last week -- but it could go further (93043, r=shaver, sr=jst).
git-svn-id: svn://10.0.0.236/trunk@100615 18797224-902f-48f8-a5cc-f745e15eee43
2001-08-09 01:15:57 +00:00
brendan%mozilla.org
c807c60073 Use a new JSContext option to type context-private data as nsISupports* (82845, sr=jst&waterson).
git-svn-id: svn://10.0.0.236/trunk@100474 18797224-902f-48f8-a5cc-f745e15eee43
2001-08-07 05:27:42 +00:00
brendan%mozilla.org
f5bc62edea FASTLOAD_20010703_BRANCH landing, r=dbaron, sr=shaver.
git-svn-id: svn://10.0.0.236/trunk@100030 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-31 19:05:34 +00:00
brendan%mozilla.org
24043e3212 - Don't initialize the arguments class, and do rename it to "Object" so that
arguments objects are prototyped by Object.prototype, per ECMA.  We still
  want a custom class, in order to lazily resolve active-JSStackFrame-based
  properties.
- Use a reserved slot to hold a bitmap of deleted arguments elements, so we
  don't re-resolve them after they've been deleted (which would make them seem
  to be permanent, contrary to ECMA).  This work involved sprucing up several
  fundamental types (jsbitmap) and macros (jsbitmap helper macros in jsbit.h,
  JS_HOWMANY in jstypes.h, JSVAL_INT_BITS in jsapi.h).


git-svn-id: svn://10.0.0.236/trunk@92016 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-11 23:07:26 +00:00
brendan%mozilla.org
afe0723131 Fix Function.prototype.to{Source,String} to parenthesize function objects that were expressed rather than declared (73760, r=rogerl, sr=shaver).
git-svn-id: svn://10.0.0.236/trunk@91805 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-10 01:10:28 +00:00
brendan%mozilla.org
e4c21a8200 - Add JS_GetReservedSlot, JS_SetReservedSlot, and JSCLASS_HAS_RESERVED_SLOTS(n)
to the JS API, for per class extra slots beyond JSSLOT_PRIVATE (or starting
  there for a class that lacks JSCLASS_HAS_PRIVATE).  To avoid penalizing all
  instances, these slots are allocated only upon first property-owned slot
  allocation, or upon first JS_SetReservedSlot.

  This entailed adding getRequiredSlot and setRequiredSlot hooks to the
  JSObjectOps struct, and making obj->slots self-describing, a la BSTR.  It
  also afforded me a chance to clean up obj->slots locking so that non-native
  JSObjectOps didn't risk unlocked accesses!  Now there are thread-safe hooks
  for all uses of obj.

  First consumer is the new, DOM-glue-unifying XPConnect, which needs two
  slots per wrapped function.  Hence the change to js_FunctionClass.flags'
  initializer.

- Commented the heck out of JSClass and JSObjectOps function typedefs in
  jspubtd.h.  I hope embedders see these comments!

- Fix JS_XDRValue's default case to handle int exclusively, there is no other
  possible type (and therefore no JSMSG_BAD_JVAL_TYPE error).

- Clean up tabs in select old, tab-ridden files and sections.

- s/\<fh\>/file/g for stdio FILE * canonical variable names.


git-svn-id: svn://10.0.0.236/trunk@91396 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-05 01:53:24 +00:00
shaver%mozilla.org
04121d876f 73645: use JSDHashTable for JSRuntime.gcRootsHash and .gcLocksHash.
r=waterson-the-dhash-fiend, sr=brendan-the-other-dhash-fiend


git-svn-id: svn://10.0.0.236/trunk@91247 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-04 04:30:41 +00:00
shaver%mozilla.org
44326fc42c 50602: Add support in XPConnect for sharing of refcounted string BufferHandles,
in both directions.
72552: Remedy overzealous CHECK_REQUEST placement in jsapi.c, to produce a
       minimal-but-complete set of engine entry points that require a Request
       for safe execution.
r=brendan, sr=jband, assist=scc,pinkerton


git-svn-id: svn://10.0.0.236/trunk@90483 18797224-902f-48f8-a5cc-f745e15eee43
2001-03-27 06:04:44 +00:00
mkaply%us.ibm.com
e324a073a6 #73191
r=beard, sr=brendan
Remove CRT_CALL - change to PR_CALLBACK or JS_DLL_CALLBACK appropriately


git-svn-id: svn://10.0.0.236/trunk@90446 18797224-902f-48f8-a5cc-f745e15eee43
2001-03-26 23:21:53 +00:00
brendan%mozilla.org
2cc30d28ec Add JS_MapGCRoots for complete enumeration of GC roots (72465, r/sr={shaver,jband}).
git-svn-id: svn://10.0.0.236/trunk@89955 18797224-902f-48f8-a5cc-f745e15eee43
2001-03-21 01:33:39 +00:00
jband%netscape.com
5c45f126ae part of the fix to bug 66950. Add support for cheaply tracking the lifetime of arbitrary JSObject by extending the GC callback mechanism to notify after marking is done but before sweeping, and by providing an api function that can be called at that point to determine if any given gcthing is about to be finalized. r=rogerl sr=brendan
git-svn-id: svn://10.0.0.236/trunk@86060 18797224-902f-48f8-a5cc-f745e15eee43
2001-02-02 08:44:24 +00:00
brendan%mozilla.org
60ae4af073 Followup to last checkin, comment change only, r=mccabe.
git-svn-id: svn://10.0.0.236/trunk@85201 18797224-902f-48f8-a5cc-f745e15eee43
2001-01-20 02:02:48 +00:00
brendan%mozilla.org
e92f541879 2nd attempt: Fix API botch where 'var x=0' vs. 'x=0' could put x in a different object (65553, r=mccabe, sr=jband).
git-svn-id: svn://10.0.0.236/trunk@85199 18797224-902f-48f8-a5cc-f745e15eee43
2001-01-20 01:41:55 +00:00
brendan%mozilla.org
850d9d969b JSPROP_SHARED implies no slot to entrain garbage (bug 61482, r=mccabe, sr=jband).
git-svn-id: svn://10.0.0.236/trunk@83276 18797224-902f-48f8-a5cc-f745e15eee43
2000-12-05 21:47:23 +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
f212456b5e Comments and white-space cleanup.
git-svn-id: svn://10.0.0.236/trunk@78518 18797224-902f-48f8-a5cc-f745e15eee43
2000-09-08 21:24:14 +00:00
brendan%mozilla.org
6c0556eb7c Improve a comment that implied a need to include jsstr.h.
git-svn-id: svn://10.0.0.236/trunk@78171 18797224-902f-48f8-a5cc-f745e15eee43
2000-09-05 21:39:48 +00:00
brendan%mozilla.org
822d3b3746 Support external string GC types so XPConnect and other systems can optimize away copies (50602, r=jband).
git-svn-id: svn://10.0.0.236/trunk@78026 18797224-902f-48f8-a5cc-f745e15eee43
2000-09-02 20:37:37 +00:00
brendan%mozilla.org
3c54211db3 Support ECMA reference type return from native methods (44997, r=shaver).
git-svn-id: svn://10.0.0.236/trunk@77793 18797224-902f-48f8-a5cc-f745e15eee43
2000-09-01 00:45:50 +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
ee6d41f982 Re-constipate JSClass.name.
git-svn-id: svn://10.0.0.236/trunk@76709 18797224-902f-48f8-a5cc-f745e15eee43
2000-08-19 19:17:32 +00:00
jband%netscape.com
1d8567d550 fix bustage
git-svn-id: svn://10.0.0.236/trunk@76703 18797224-902f-48f8-a5cc-f745e15eee43
2000-08-19 10:22:13 +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
2a9d76e574 Fix JS_SetPrototype and __proto__ setting to deal with shared scopes; use JSObjectOps for setProto and setParent operations, and add spare op slots (41126, r=shaver@mozilla.org,pschwartau@netscape.com).
git-svn-id: svn://10.0.0.236/trunk@73274 18797224-902f-48f8-a5cc-f745e15eee43
2000-06-27 02:37:25 +00:00
brendan%mozilla.org
d42ca5af73 JS_DestroyRuntime nukes all contexts; add JS_G/SetRuntimePrivate (r=tlundeen@webcrossing.com).
git-svn-id: svn://10.0.0.236/trunk@70340 18797224-902f-48f8-a5cc-f745e15eee43
2000-05-17 06:23:03 +00:00
brendan%mozilla.org
6d409a43c8 Comment the need for rooted JS_NewScriptObject; whitespace/comment cleanup.
git-svn-id: svn://10.0.0.236/trunk@69750 18797224-902f-48f8-a5cc-f745e15eee43
2000-05-15 06:06:12 +00:00
brendan%mozilla.org
52c90059b6 GC synchronization and lock fixes, plus comments (37983, r=waterson@netscape.com).
git-svn-id: svn://10.0.0.236/trunk@69690 18797224-902f-48f8-a5cc-f745e15eee43
2000-05-14 23:00:51 +00:00
brendan%mozilla.org
87379c9ed6 Rename stacksize formal param to stackChunkSize (27767, really a doc bug).
git-svn-id: svn://10.0.0.236/trunk@63931 18797224-902f-48f8-a5cc-f745e15eee43
2000-03-23 23:50:29 +00:00
rogerl%netscape.com
55516c09bf r=brendan@mozilla.org
bug #26857
Fix for evaluating multi-part script prologs in advance.


git-svn-id: svn://10.0.0.236/trunk@60514 18797224-902f-48f8-a5cc-f745e15eee43
2000-02-11 22:21:15 +00:00
mccabe%netscape.com
e704ac16c8 Added comment recommending rooting of new script objects, to address problems experienced by netscape.public.mozilla.jseng developers.
Also verbiage refactory.

r=brendan


git-svn-id: svn://10.0.0.236/trunk@60031 18797224-902f-48f8-a5cc-f745e15eee43
2000-02-08 01:38:20 +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
shaver%netscape.com
73c394bee1 add JS_CompileFileHandleForPrincipals, (r=rginda)
git-svn-id: svn://10.0.0.236/trunk@58131 18797224-902f-48f8-a5cc-f745e15eee43
2000-01-18 22:04:01 +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
jband%netscape.com
170ebb1f69 fixup the exported api declarations to use JS_PUBLIC_API in a consistent fashion r=mccabe
git-svn-id: svn://10.0.0.236/trunk@54224 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-23 01:02:28 +00:00
brendan%mozilla.org
5d2eac8479 XULDOMJS_19991106_BRANCH landing (15146, 18025, r=shaver@mozilla.org)
git-svn-id: svn://10.0.0.236/trunk@53326 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-12 06:03:40 +00:00
mccabe%netscape.com
f7d8c1e1aa Warning fix for uninitialized structure members. r=fur,slamm.
git-svn-id: svn://10.0.0.236/trunk@53158 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-11 01:15:43 +00:00
brendan%mozilla.org
ba803ea225 Add JS_VersionToString and JS_StringToVersion, updated Impl. Version (13163, r=shaver@mozilla.org).
git-svn-id: svn://10.0.0.236/trunk@52281 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-29 22:44:35 +00:00
jband%netscape.com
32816676db the JS engine part of the fix for bug 14738. This does two things: 1) expose the JSClass for JSError so that it is possible to detect from the outside if a given JSObject is of that JSError class, and 2) expose an api call via which the JSErrorReport can be extracted from a JSError (if present). This change required renaming the JSClass used for JSError, so many lines were touched
git-svn-id: svn://10.0.0.236/trunk@49861 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-05 21:07:23 +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
rogerl%netscape.com
17e20e67dc Mostly just some cleaning up - especially in regexp.
Merged server specific GC changes from NES branch.
Bunch o' ECMA version 3 fixes to jsregexp.


git-svn-id: svn://10.0.0.236/trunk@46219 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-07 20:34:47 +00:00
brendan%netscape.com
503f279021 Forgot externs before JS_PUBLIC_API calls for ArgumentFormatter functions.
git-svn-id: svn://10.0.0.236/trunk@37294 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-29 00:21:38 +00:00