62 Commits

Author SHA1 Message Date
brendan%mozilla.org
2532d3d12a Big dynamic footprint win via script filename caching, plus line number fix for strict/const diags (see http://bugzilla.mozilla.org/attachment.cgi?id=127130&action=view for detailed checkin comments; 208030, r/rs=shaver, r=rginda on the jsd change, r=jst on the dom change).
git-svn-id: svn://10.0.0.236/trunk@145239 18797224-902f-48f8-a5cc-f745e15eee43
2003-07-26 22:37:11 +00:00
brendan%mozilla.org
c339a9649c Fixed so overriding Function.prototype.toSource doesn't mess up F.p.toString output, which should decompile the function, including nested function expressions (178389, r=shaver).
git-svn-id: svn://10.0.0.236/trunk@135535 18797224-902f-48f8-a5cc-f745e15eee43
2002-12-21 02:14:53 +00:00
brendan%mozilla.org
a15af1d979 Better macro name, nit-pick on last checkin.
git-svn-id: svn://10.0.0.236/trunk@129601 18797224-902f-48f8-a5cc-f745e15eee43
2002-09-14 06:40:59 +00:00
brendan%mozilla.org
1f4ca86d7b Followup fix for 168347, r=rogerl: avoid temporary bloat due to QuoteString without sprinter offset retract.
git-svn-id: svn://10.0.0.236/trunk@129575 18797224-902f-48f8-a5cc-f745e15eee43
2002-09-13 22:40:27 +00:00
brendan%mozilla.org
4d0bfed156 Reorder QuoteString calls added for bug 58274 to avoid overwriting just-popped strings in the string-stack (168347, r=shaver).
git-svn-id: svn://10.0.0.236/trunk@129507 18797224-902f-48f8-a5cc-f745e15eee43
2002-09-13 06:58:24 +00:00
rogerl%netscape.com
5fe48eddea Bug 58274. Support double byte characters for toSource identifiers.
r=khanson, sr=brendan.


git-svn-id: svn://10.0.0.236/trunk@128139 18797224-902f-48f8-a5cc-f745e15eee43
2002-08-26 20:07:58 +00:00
timeless%mac.com
69ae314807 Bug 106386 rid source of misspellings
r=db48x sr=blake a=asa


git-svn-id: svn://10.0.0.236/trunk@116832 18797224-902f-48f8-a5cc-f745e15eee43
2002-03-19 04:30:17 +00:00
brendan%mozilla.org
c4c296cdeb khanson@netscape.com's patch to switch from QuickSort to heap-sort, plus a crucial ECMA-purity/property-tree-perf fix to InitArrayObject (to SET rather than DEFINE; bug 99120, r=waldemar, sr=shaver&brendan, a=asa).
git-svn-id: svn://10.0.0.236/trunk@116457 18797224-902f-48f8-a5cc-f745e15eee43
2002-03-13 01:50:13 +00:00
brendan%mozilla.org
64c95321b5 Fix stale comment about duplicate formal params (a=drivers, comment-only followup to 62164's big patch).
git-svn-id: svn://10.0.0.236/trunk@115288 18797224-902f-48f8-a5cc-f745e15eee43
2002-02-24 00:26:57 +00:00
brendan%mozilla.org
f780c9a84e Major footprint/perf win: share property state using a tree whose root represents empty scopes, and whose non-root nodes represent scopes with properties added in order from the root to that node; to use double hashing to map these tree-paths for per-scope property lookup; and avoid locking where possible through immutability and mostly-benign&rare race tolerance (62164, r=shaver, sr=jband).
git-svn-id: svn://10.0.0.236/trunk@115266 18797224-902f-48f8-a5cc-f745e15eee43
2002-02-23 03:49:27 +00:00
brendan%mozilla.org
82236d9ede Fix try/finally and try/guarded-catches/finally hard cases (104077, r=jband, sr=shaver).
git-svn-id: svn://10.0.0.236/trunk@110362 18797224-902f-48f8-a5cc-f745e15eee43
2001-12-12 05:00:29 +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
brendan%mozilla.org
69d4fd60de Fixes for bug 80981 (``Need extended jump bytecode to avoid "script too large"
errors, etc.''):

We now ReportStatementTooLarge only if
- a jump offset overflows 32 bits, signed;
- there are 2**32 or more span dependencies in a script;
- a backpatch chain link is more than (2**30 - 1) bytecodes long;
- a source note's distance from the last note, or from script main entry
  point, is > 0x7fffff bytes.

Narrative of the patch, by file:

- js.c
  The js_SrcNoteName array of const char * is now a js_SrcNoteSpec array of
  "specifiers", structs that include a const char *name member.  Also, due to
  span-dependent jumps at the ends of basic blocks where the decompiler knows
  the basic block length, but not the jump format, we need an offset operand
  for SRC_COND, SRC_IF_ELSE, and SRC_WHILE (to tell the distance from the
  branch bytecode after the condition expression to the span-dependent jump).

- jsarena.[ch]
  JS arenas are used mainly for last-in-first-out allocation with _en masse_
  release to the malloc pool (or, optionally, to a private freelist).  But
  the code generator needs to allocate and grow (by doubling, to avoid O(n^2)
  growth) allocations that hold bytecode, source notes, and span-dependency
  records.  This exception to LIFO allocation works by claiming an entire
  arena from the pool and realloc'ing it, as soon as the allocation size
  reaches the pool's default arena size.  Call such an allocation a "large
  single allocation".

  This patch adds a new arena API, JS_ArenaFreeAllocation, which can be used
  to free a large single allocation.  If called with an allocation that's not
  a large single allocation, it will nevertheless attempt to retract the arena
  containing that allocation, if the allocation is last within its arena.
  Thus JS_ArenaFreeAllocation adds a non-LIFO "free" special case to match the
  non-LIFO "grow" special case already implemented under JS_ARENA_GROW for
  large single allocations.

  The code generator still benefits via this extension to arenas, over purely
  manual malloc/realloc/free, by virtue of _en masse_ free (JS_ARENA_RELEASE
  after code generation has completed, successfully or not).

  To avoid searching for the previous arena, in order to update its next
  member upon reallocation of the arena containing a large single allocation,
  the oversized arena has a back-pointer to that next member stored (but not
  as allocable space within the arena) in a (JSArena **) footer at its end.

- jscntxt.c
  I've observed for many scripts that the bytes of source notes and bytecode
  are of comparable lengths, but only now am I fixing the default arena size
  for cx->notePool to match the size for cx->codePool (1024 instead of 256).

- jsemit.c
  Span-dependent instructions in JS bytecode consist of the jump (JOF_JUMP)
  and switch (JOF_LOOKUPSWITCH, JOF_TABLESWITCH) format opcodes, subdivided
  into unconditional (gotos and gosubs), and conditional jumps or branches
  (which pop a value, test it, and jump depending on its value).  Most jumps
  have just one immediate operand, a signed offset from the jump opcode's pc
  to the target bytecode.  The lookup and table switch opcodes may contain
  many jump offsets.

  This patch adds "X" counterparts to the opcodes/formats (X is suffixed, btw,
  to prefer JSOP_ORX and thereby to avoid colliding on the JSOP_XOR name for
  the extended form of the JSOP_OR branch opcode).  The unextended or short
  formats have 16-bit signed immediate offset operands, the extended or long
  formats have 32-bit signed immediates.  The span-dependency problem consists
  of selecting as few long instructions as possible, or about as few -- since
  jumps can span other jumps, extending one jump may cause another to need to
  be extended.

  Most JS scripts are short, so need no extended jumps.  We optimize for this
  case by generating short jumps until we know a long jump is needed.  After
  that point, we keep generating short jumps, but each jump's 16-bit immediate
  offset operand is actually an unsigned index into cg->spanDeps, an array of
  JSSpanDep structs.  Each struct tells the top offset in the script of the
  opcode, the "before" offset of the jump (which will be the same as top for
  simplex jumps, but which will index further into the bytecode array for a
  non-initial jump offset in a lookup or table switch), the after "offset"
  adjusted during span-dependent instruction selection (initially the same
  value as the "before" offset), and the jump target (more below).

  Since we generate cg->spanDeps lazily, from within js_SetJumpOffset, we must
  ensure that all bytecode generated so far can be inspected to discover where
  the jump offset immediate operands lie within CG_CODE(cg).  But the bonus is
  that we generate span-dependency records sorted by their offsets, so we can
  binary-search when trying to find a JSSpanDep for a given bytecode offset,
  or the nearest JSSpanDep at or above a given pc.

  To avoid limiting scripts to 64K jumps, if the cg->spanDeps index overflows
  65534, we store SPANDEP_INDEX_HUGE in the jump's immediate operand.  This
  tells us that we need to binary-search for the cg->spanDeps entry by the
  jump opcode's bytecode offset (sd->before).

  Jump targets need to be maintained in a data structure that lets us look
  up an already-known target by its address (jumps may have a common target),
  and that also lets us update the addresses (script-relative, a.k.a. absolute
  offsets) of targets that come after a jump target (for when a jump below
  that target needs to be extended).  We use an AVL tree, implemented using
  recursion, but with some tricky optimizations to its height-balancing code
  (see http://www.enteract.com/~bradapp/ftp/src/libs/C++/AvlTrees.html).

  A final wrinkle: backpatch chains are linked by jump-to-jump offsets with
  positive sign, even though they link "backward" (i.e., toward lower bytecode
  address).  We don't want to waste space and search time in the AVL tree for
  such temporary backpatch deltas, so we use a single-bit wildcard scheme to
  tag true JSJumpTarget pointers and encode untagged, signed (positive) deltas
  in JSSpanDep.target pointers, depending on whether the JSSpanDep has a known
  target, or is still awaiting backpatching.

  Note that backpatch chains would present a problem for BuildSpanDepTable,
  which inspects bytecode to build cg->spanDeps on demand, when the first
  short jump offset overflows.  To solve this temporary problem, we emit a
  proxy bytecode (JSOP_BACKPATCH; JSOP_BACKPATCH_PUSH for jumps that push a
  result on the interpreter's stack, namely JSOP_GOSUB; or JSOP_BACKPATCH_POP
  for branch ops) whose nuses/ndefs counts help keep the stack balanced, but
  whose opcode format distinguishes its backpatch delta immediate operand from
  a normal jump offset.

  The cg->spanDeps array and JSJumpTarget structs are allocated from the
  cx->tempPool arena-pool.  This created a LIFO vs. non-LIFO conflict: there
  were two places under the TOK_SWITCH case in js_EmitTree that used tempPool
  to allocate and release a chunk of memory, during whose lifetime JSSpanDep
  and/or JSJumpTarget structs might also be allocated from tempPool -- the
  ensuing release would prove disastrous.  These bitmap and table temporaries
  are now allocated from the malloc heap.

- jsinterp.c
  Straightforward cloning and JUMP => JUMPX mutating of the jump and switch
  format bytecode cases.

- jsobj.c
  Silence warnings about %p used without (void *) casts.

- jsopcode.c
  Massive and scary decompiler whackage to cope with extended jumps, using
  source note offsets to help find jumps whose format (short or long) can't
  be discovered from properties of prior instructions in the script.

  One cute hack here: long || and && expressions are broken up to wrap before
  the 80th column, with the operator at the end of each non-terminal line.

- jsopcode.h, jsopcode.tbl
  The new extended jump opcodes, formats, and fundamental parameterization
  macros.  Also, more comments.

- jsparse.c
  Random and probably only aesthetic fix to avoid decorating a foo[i]++ or
  --foo[i] parse tree node with JSOP_SETCALL, wrongly (only foo(i)++ or
  --foo(i), or the other post- or prefix form operator, should have such an
  opcode decoration on its parse tree).

- jsscript.h
  Random macro naming sanity: use trailing _ rather than leading _ for macro
  local variables in order to avoid invading the standard C global namespace.


git-svn-id: svn://10.0.0.236/trunk@105588 18797224-902f-48f8-a5cc-f745e15eee43
2001-10-17 03:16:48 +00:00
brendan%mozilla.org
726006598c Fix for bug 99663 (for loop resolves properties of the object being enumerated
with JSRESOLVE_ASSIGNING, wrongly), plus a few miscellaneous bugfixes.

- Combine the JSStackFrame members constructing, special, overrides, and
  reserved into a uint32 flags member.

- Separate JOF_ASSIGNING from the JOF_SET bytecode format flag, and impute
  JSRESOLVE_ASSIGNING from the presence of JOF_ASSIGNING among the current
  opcode's format flags.  To handle the for-in loop opcodes, which do more
  than simply assign -- in particular, they do property lookups whose resolve
  hook outcalls should not be flagged with JSRESOLVE_ASSIGNING -- a new frame
  flag, JSFRAME_ASSIGNING, has been added.

- Fix interpreter version selection to respect JS_SetVersion, whose effect on
  cx->version is "sticky".

- Fix js_DecompileValueGenerator to deal with JSOP_ENUMELEM -- it never had,
  as this testcase shows (it crashes without this patch):

    version(120);
    eval("function fe(s) { for (it[s] in this); }");
    try { fe('rdonly'); } catch (e) { print(e); }


git-svn-id: svn://10.0.0.236/trunk@104525 18797224-902f-48f8-a5cc-f745e15eee43
2001-10-03 06:39:30 +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
9bf59a0feb Checking in khanson's patch with whitespace cleanups for bug 89443, to avoid stack overflow on too many || operators in one expression (r=rogerl, sr=me).
git-svn-id: svn://10.0.0.236/trunk@101294 18797224-902f-48f8-a5cc-f745e15eee43
2001-08-17 10:29:59 +00:00
brendan%mozilla.org
f54563bd60 Restore ECMA-required Function.prototype.toString while keeping toSource/uneval fix for bug 73760 (76634, r=beard, sr=shaver, a=asa).
git-svn-id: svn://10.0.0.236/trunk@92759 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-19 21:57:25 +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
713ac17d77 - Shaver hacked this fix with advice from me, and I carried it to check-in. We now avoid a heavyweight outer function when the inner one is defined at top-level or in an expression (is not a JSOP_CLOSURE, IOW), and it doesn't refer to any non-local names. See bug 65308 for details on the win. (r=rogerl, sr=brendan)
- Fix scope chain for nested functions at top-level (JSOP_DEFFUN), in a part of another statement (JSOP_CLOSURE), and unnamed in an expression (JSOP_ANONFUNOBJ) to match ECMA-262 13.2.  My bad: fp->varobj was used up till now, instead of fp->scopeChain; we still *bind* the name of a statement-level (top or not) nested function in fp->varobj.  This fixes bug 69559.  (r=rogerl, sr=jband)
- Add an Intern command to the shell, for GC vs. intern'ed atom testing.


git-svn-id: svn://10.0.0.236/trunk@87871 18797224-902f-48f8-a5cc-f745e15eee43
2001-02-24 03:00:56 +00:00
brendan%mozilla.org
1c7d4471fa Fixes for bug 61898 (which has morphed), r=rogerl, sr=jband.
- Optimize integer ++ and -- to avoid double-to-int, which is quite costly for
  some compilers (ftol on Windows with MSVC).
- Optimized arguments[i] and arguments.length references to use bytecodes that
  avoid creating an arguments object for the current frame.  This entailed
  simplifying the compiler to avoid flagging functions and scripts that set
  arguments, since we have code in jsfun.c to catch such sets at runtime.
- The code generator now eliminates useless expression statements, giving a
  strict warning about them.
- Rationalized jsemit.c's LookupArgOrVar to have well-defined results in *pn.
  Eliminate bytecode specializations for argument and local variable gets and
  sets from jsparse.c -- these precede jsemit.c's LookupArgOrVar and frustrate
  it, by setting pn_slot non-negative too early.
- Code generation errors set report->filename and report->lineno, rather than
  hacking "{0}, line {1}: " into the localized message.
- Bogus JSFRAME_VAROBJBUG removed, JSOPTION_VAROBJFIX is sufficient.
- Spruce up jsinterp.c macros to use JS_BEGIN/END_MACRO brackets if possible.
- Avoid calling JS_PropertyStub.  The call is too costly compared to a branch
  in the caller.


git-svn-id: svn://10.0.0.236/trunk@85537 18797224-902f-48f8-a5cc-f745e15eee43
2001-01-26 00:59:50 +00:00
sspitzer%netscape.com
7305affabb back out brendan (Career Limiting Move) to fix blocker bug #66545.
a=leaf


git-svn-id: svn://10.0.0.236/trunk@85497 18797224-902f-48f8-a5cc-f745e15eee43
2001-01-25 18:06:57 +00:00
brendan%mozilla.org
c1463a8801 Fixes for bug 61898 (which has morphed), r=rogerl, sr=jband.
- Optimize integer ++ and -- to avoid double-to-int, which is quite costly for
  some compilers (ftol on Windows with MSVC).
- Optimized arguments[i] and arguments.length references to use bytecodes that
  avoid creating an arguments object for the current frame.  This entailed
  simplifying the compiler to avoid flagging functions and scripts that set
  arguments, since we have code in jsfun.c to catch such sets at runtime.
- The code generator now eliminates useless expression statements, giving a
  strict warning about them.
- Rationalized jsemit.c's LookupArgOrVar to have well-defined results in *pn.
- Code generation errors set report->filename and report->lineno, rather than
  hacking "{0}, line {1}: " into the localized message.
- Bogus JSFRAME_VAROBJBUG removed, JSOPTION_VAROBJFIX is sufficient.
- Spruce up jsinterp.c macros to use JS_BEGIN/END_MACRO brackets if possible.
- Avoid calling JS_PropertyStub.  The call is too costly compared to a branch
  in the caller.


git-svn-id: svn://10.0.0.236/trunk@85488 18797224-902f-48f8-a5cc-f745e15eee43
2001-01-25 09:22:19 +00:00
brendan%mozilla.org
55b0ba4585 Fixes to make JS GC truly exact:
- All jsvals for which JSVAL_IS_GCTHING evaluates to true must contain tagged
pointers into the GC heap -- therefore jsapi.c's JS_DefineConstDoubles cannot
"cheat" by tagging addresses of static jsdoubles to avoid js_NewNumberValue.

- Finalization is now interleaved with the Sweep phase, to avoid allocating
memory for finalization records while sweeping.  Instead, the JSRuntime holds a
preallocated JSGCThing vector (gcFinalVec) that the Sweep phase fills and
flushes via gc_finalize_phase, repeatedly.

This means that finalizers cannot allocate a new GC thing, an incompatible but
plausible change.  js_AllocGCThing asserts and then checks whether it is called
while rt->gcLevel is non-zero, and fails the allocation attempt if so.  But this
fixes bug 38942, where the old sweep-then-finalize with a sweep => malloc
dependency could lead to memory exhaustion.

- Instead of scanning whole stackPool arenas, which led to UMRs (bug 27924) and
sometimes to gross over-scanning that depended on the GC bounds-checking all
thing pointers against its heap, we scan exactly those stack slots in use:
  - arguments reachable from fp->argv;
  - variables reachable from fp->vars;
  - operands now reachable from fp->spbase, bounded above by the lesser of
    fp->sp or fp->spbase + fp->script->depth for an interpreted frame; if the
    latter, fp->sp has advanced logically above the operand budget, in order to
    call a native method, and all unused slots from fp->sp up to depth slots
    above fp->spbase must be set to JSVAL_VOID;
  - stack segments pushed when calling native methods, prefixed by JSStackHeader
    structs and linked from cx->stackSegments through each header.
The stack segment headers help the GC avoid scanning unused portions of the
stack: the generating pc slots running depth slots below fp->spbase, and slots
at the end of an arena that aren't sufficient to satisfy a contiguous allocation
for more args, vars, or operands.

- Exact GC means the stack pointer must remain above live operands until the
interpreter is done with them, so jsinterp.c got heavily whacked.  Instead of
POPs of various kinds followed by a PUSH for binary operators (e.g.), we use
FETCH and STORE macros that index by -1 and -2 from sp, and minimize adjustments
to sp.  When sp is homed to fp->sp, this allows js_DecompileValueGenerator to
find the value reliably, and if possible its generating pc.

- Finally, the O(n**2) growth rate of gc_find_flags has been fixed, using the
scheme sketched in bug 49816 and documented in a new major comment in jsgc.c.
Briefly, by allocating flags and things from one arena, we can align things on
1024-byte "thing page" boundaries, and use JSGCPageInfo headers in each page to
find a given thing's flags in O(1) time.

/be


git-svn-id: svn://10.0.0.236/trunk@79087 18797224-902f-48f8-a5cc-f745e15eee43
2000-09-14 06:14:45 +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
b0b7fd8115 Followup for 44997, r=shaver:
- #if JS_HAS_LVALUE_RETURN around cx->rval2/rval2set defs and uses.
- Instrument different kinds of invocations, #ifdef DEBUG only.
- Clean up basis case of empty switch statement to use high = -1, low = 0,
  requiring care when optimizing in-range tests using unsigned casts, but
  freeing the interpreter and decompiler from having to do an extra test
  before looping from low to high.
- Clean up all codegen to use JUMP_OFFSET_LEN, ATOM_INDEX_LEN, etc. instead of
  magic 2 or 4.
- Add JSOP_TRY and JSOP_FINALLY no-ops to save a srcnote per JSOP_NOP, and to
  make decompilation and jit'ing easier.
- Minimize number of source notes to maximize SRC_XDELTA span.
- Use JSSCRIPT_FIND_CATCH_START in throw code.
- Indentation and bracing nits picked.


git-svn-id: svn://10.0.0.236/trunk@77900 18797224-902f-48f8-a5cc-f745e15eee43
2000-09-01 18:42:22 +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
c80feb7387 Comply with weird ECMA nit: call (o.f)() (note parens around the function expression) must bind 'this' to the global object, not to o\! (41864, r=shaver).
git-svn-id: svn://10.0.0.236/trunk@71779 18797224-902f-48f8-a5cc-f745e15eee43
2000-06-08 06:46:18 +00:00
brendan%mozilla.org
4a68c03a16 Fix ECMA DontDelete compliance problems, which create getter/setter security holes (40760, r=shaver).
git-svn-id: svn://10.0.0.236/trunk@71309 18797224-902f-48f8-a5cc-f745e15eee43
2000-06-02 00:02:46 +00:00
brendan%mozilla.org
66bc1e6c09 Clean up ugly whitespace, some of which survived my r=brendan comments.
git-svn-id: svn://10.0.0.236/trunk@65282 18797224-902f-48f8-a5cc-f745e15eee43
2000-04-05 02:17:38 +00:00
rogerl%netscape.com
663a94b57f r=brendan,rginda
Added ECMA3 compliant getter/setter syntax.
Fixed bugs
	- #28686, mishandling of \$ in replace()
	- #27902, eval not detected as heavyweight indicator for non ECMA
			context version.


git-svn-id: svn://10.0.0.236/trunk@62083 18797224-902f-48f8-a5cc-f745e15eee43
2000-03-02 23:21:03 +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
brendan%mozilla.org
49a807da2d Fix decompiler to search function clone prototypes for args and vars (20160, r=rginda@netscape.com).
git-svn-id: svn://10.0.0.236/trunk@54531 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-28 09:46:33 +00:00
brendan%mozilla.org
ca2032e66d Eliminate Closure per ECMA ed. 3, fix brutal sharing of lambdas (20076, r=rogerl,shaver).
git-svn-id: svn://10.0.0.236/trunk@54474 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-25 03:25:30 +00:00
brendan%mozilla.org
f02610dd2c Fix exception bytecodes to use script->main (18926, r=jband@netscape.com).
git-svn-id: svn://10.0.0.236/trunk@53602 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-16 02:15:22 +00:00
brendan%mozilla.org
52c12d5bf6 Disassembler uses ToSource, not ToString, where appropriate (DEBUG only change).
git-svn-id: svn://10.0.0.236/trunk@53532 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-15 21:11:59 +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
b31e8409ff Fix most remaining warnings in js/src. Patch courtesy slamm.
r=mccabe.


git-svn-id: svn://10.0.0.236/trunk@53245 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-11 21:52:35 +00:00
brendan%mozilla.org
bed10de2c0 Fixed getter/setters, pave way for brutal sharing (15146, r=shaver@mozilla.org,rogerl@netscape.com)
git-svn-id: svn://10.0.0.236/trunk@52487 18797224-902f-48f8-a5cc-f745e15eee43
1999-11-02 02:23:50 +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
d9de75afbd Added ECMA number formatting
git-svn-id: svn://10.0.0.236/trunk@47753 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-16 07:12:30 +00:00
brendan%mozilla.org
e0f64c2c6e Fix warnings reported at http://tinderbox.mozilla.org/SeaMonkey/warnings.html, mostly unsigned/signed bothers.
git-svn-id: svn://10.0.0.236/trunk@41445 18797224-902f-48f8-a5cc-f745e15eee43
1999-07-28 06:48:44 +00:00
brendan%mozilla.org
5f949724de Eliminate warning about unsigned/signed == comparison.
git-svn-id: svn://10.0.0.236/trunk@40868 18797224-902f-48f8-a5cc-f745e15eee43
1999-07-23 08:25:03 +00:00
brendan%mozilla.org
2d15291e31 Bugs, bugs bugs:
- js_DecompileValueGenerator had rusted due to bytecode/source-note changes,
  or maybe parts of it never worked right.  Anyway, it now does not induce a
  crashing underflow in the decompiler.  As part of this fix, it now takes a
  checkStack flag telling whether to look for the jsval v argument on the JS
  stack.  The calls from ImportProperty, js_SetProperty, and js_DeleteProperty
  pass in v a jsval for the property id, which should not be sought after on
  the stack (it might happen to be there due to o['p'] = 2, but we want to
  decompile o["p"], not "p").
- js_DecompileValueGenerator would load a generating pc even if the value v
  did not match the pc's corresponding stack item!  Oops.  This lead to less
  than idea diagnostics.
- js_DecompileValueGenerator was also not mapping JSOP_TRAP to the real op at
  a sufficiently early and univeral point in its control flow.
- Fix PopOff to assert and check for stack underflow in the decompiler, and
  beef up PushOff too (it asserted, but did not check).
- js_ReportIsNotFunction now avoids JS_InternString by indexing directly into
  cx->runtime->atomState.typeAtoms with the result of JS_TypeOfValue.
- Removed unnecessary local GC root reserved by non-zero trailing member of
  obj_eval's JSFunctionSpec initializer.


git-svn-id: svn://10.0.0.236/trunk@40864 18797224-902f-48f8-a5cc-f745e15eee43
1999-07-23 08:01:54 +00:00
brendan%mozilla.org
b80a05e8e8 - Fix for..in bug where ECMA 12.6.3 steps 5 and 6 are reversed: the effect was
to define an unbound global variable used to enumerate an empty object, when
  the standard says no variable should be defined.
- Clean up minor nits, make comment style match prevailing, tighten up for..in
  element-indexing special case comments.
- Fix js_Invoke to take CONSTRUCT and INTERNAL flags arg instead of a construct
  boolean arg and the JSStackFrame internalCall mis-located boolean non-arg.
  Use these flags correctly in all calls (previous version failed to set the
  bogus frame.internalCall around js_Invoke calls from jsfun.c and jsstr.c).


git-svn-id: svn://10.0.0.236/trunk@39473 18797224-902f-48f8-a5cc-f745e15eee43
1999-07-15 02:24:23 +00:00
briano%netscape.com
ff16da1eef Fix for QNX, and any other platform that doesn't have memory.h. Thanks to fur@netscape.com for allowing this change.
git-svn-id: svn://10.0.0.236/trunk@31423 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-13 08:46:41 +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