1232 Commits

Author SHA1 Message Date
jband%netscape.com
8d3833cb33 Much of this is under the auspices of bug 15794. r=mccabe.
- map xpcshell's 'quit()' to a loop exit rather than calling
'exit(0)' so that the cleanup and leak detection code will still
get called.

- add NS_InitXPCOM and NS_ShutdownXPCOM to xpcshell to run said
cleanup and leak detection code.

- use more NS_IF_* macros

- fix numerous places where code assumed that
nsXPConnect::GetXPConnect() does not add a new ref on the
xpconnect singleton object (the behavior changed some time back
but not all the uses did - brainfade!).

- fix nsXPCException::NewException to automatically trim
'dataless' native stackframes off of the front of a stack trace.
The old system of manually telling it how many frames to trim was
not working well. We really want the first frame showing to be an
'interesting' frame so that callers who get exceptions thrown at
them will see some useful information rather than an empty native
frame that represents (but says nothing about) some native frame
in the xpconnect runtime.

- remove an extra addref from the trimming loop in
nsXPCException::NewException.

- Stop building XPCJSStack objects. XPConnect stacks are singly
linked lists of XPCJSStackFrame objects with refcounted links. I
had this stupid idea that each object would have a refcounted
link to a XPCJSStack object that would tie together the lifetimes
of all objects in the chain. This was overcomplex and
unnecessary. The linked list was enough. Any frame without a
refcount deserved to be deleted because it is simply unreachable.
There was no reason to tie together all the lifetimes of each
object in the chain. So this has been simplified in a big way.

- fixed place in xpcthrower.cpp where we were leaking a refcount
on the xpconnect singleton each time an xpcexception was thrown.

- do cleanup and gc() at the end of xpctest_echo.js to use for
leak testing - all wrappers should go away.


git-svn-id: svn://10.0.0.236/trunk@50309 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-09 06:01:57 +00:00
rogerl%netscape.com
5e3057bc5f Fixed 14060 - calling exec on java methods was gettmg caught by exec
trapping nonsense.


git-svn-id: svn://10.0.0.236/trunk@50266 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-08 22:55:33 +00:00
cbegle%netscape.com
6389e9eed1 Adding new files. Tests for XPConnect. These files are not part of the
build.  R=jband@netscape.com


git-svn-id: svn://10.0.0.236/trunk@50245 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-08 20:45:37 +00:00
kipp%netscape.com
e18af2d0ee Cleanup moz-decl-counter usage and fix NS_LOG_ADDREF usage
git-svn-id: svn://10.0.0.236/trunk@50239 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-08 20:41:19 +00:00
warren%netscape.com
c9fbdb8075 Fixed AddRef/Release problems to eliminate negative refcounts in Bloaty.
git-svn-id: svn://10.0.0.236/trunk@50188 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-08 01:49:06 +00:00
jband%netscape.com
1c2af52291 fix warning of old style C++ variable scope declared in 'for'. bug 15778. r=slamm
git-svn-id: svn://10.0.0.236/trunk@50176 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-08 00:11:05 +00:00
rogerl%netscape.com
e143bf497c Fixed build failures - these files are NOT part of the seamonkey build.
git-svn-id: svn://10.0.0.236/trunk@50125 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-07 20:45:27 +00:00
rogerl%netscape.com
750861810b Fixed error reporting to not smack the source line with a zero, but use
copyN instead - things were failing when very last line of input had an
error and didn't end with '\n'. r=mccabe


git-svn-id: svn://10.0.0.236/trunk@50124 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-07 20:44:40 +00:00
rogerl%netscape.com
df73818e4c Fixed build warnings by removing macros with '{..}'.
Made str_escape available for jsfile.
r=mccabe


git-svn-id: svn://10.0.0.236/trunk@50122 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-07 20:42:20 +00:00
rogerl%netscape.com
7ba994995c Making str_escape available for jsfile use. r=mccabe.
git-svn-id: svn://10.0.0.236/trunk@50121 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-07 20:41:15 +00:00
rogerl%netscape.com
cfd4889e52 Bug #12168. Catch new Array(NaN). r=mccabe.
git-svn-id: svn://10.0.0.236/trunk@50120 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-07 20:40:17 +00:00
norris%netscape.com
9754a010ca Fix 15711 Can't call java.lang.Class methods from JS
git-svn-id: svn://10.0.0.236/trunk@50112 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-07 18:27:21 +00:00
norris%netscape.com
5ca75e8020 Subject:
Re: NPL vs. MPL
       Date:
            Wed, 06 Oct 1999 18:30:34 -0400
      From:
            "Ian D. Stewart" <idstewart@softhome.net>
        To:
            Norris Boyd <norris@netscape.com>
 References:
            1 , 2 , 3




Norris Boyd wrote:

  Great. So I'd like to change this copyright text

  /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset:
  4 -*-
   *
   * The contents of this file are subject to the Mozilla Public License
   * Version 1.0 (the "MozPL"); you may not use this file except in
   * compliance with the MozPL.  You may obtain a copy of the MozPL at
   * http://www.mozilla.org/NPL/
   *
   * Software distributed under the MozPL is distributed on an "AS IS"
  basis,
   * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
  MozPL
   * for the specific language governing rights and limitations under the
   * MozPL.
   *
   * The Initial Developer of this code under the MozPL is Ian D. Stewart.

   * Portions created by Ian D. Stewart are Copyright (C) 1998, 1999
   * Ian D. Stewart.
   * All Rights Reserved.
   */

  to this:

  /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset:
  4 -*-
   *
   * The contents of this file are subject to the Netscape Public
   * License Version 1.1 (the "License"); you may not use this file
   * except in compliance with the License. You may obtain a copy of
   * the License at http://www.mozilla.org/NPL/
   *
   * Software distributed under the License is distributed on an "AS
   * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express oqr
   * implied. See the License for the specific language governing
   * rights and limitations under the License.
   *
   * The Original Code is ListenerCollection, released
   * May 15, 1998.
   *
   * The Initial Developer of the Original Code is Ian D. Stewart.
   * Portions created by Ian D. Stewart are Copyright (C) 1998, 1999
   * Ian D. Stewart.
   * Rights Reserved.
   *
   * Contributor(s):
   * Ian D. Stewart
   *
   * Alternatively, the contents of this file may be used under the
   * terms of the GNU Public License (the "GPL"), in which case the
   * provisions of the GPL are applicable instead of those above.
   * If you wish to allow use of your version of this file only
   * under the terms of the GPL and not to allow others to use your
   * version of this file under the NPL, indicate your decision by
   * deleting the provisions above and replace them with the notice
   * and other provisions required by the GPL.  If you do not delete
   * the provisions above, a recipient may use your version of this
   * file under either the NPL or the GPL.
   */

  Can you give me your approval for this change?

Make it so.


Ian


git-svn-id: svn://10.0.0.236/trunk@50111 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-07 16:57:01 +00:00
rogerl%netscape.com
b1873070a7 More errors-as-exceptions stuff
git-svn-id: svn://10.0.0.236/trunk@50054 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-06 23:55:33 +00:00
norris%netscape.com
48f3a0603c More license wrangling: fix the release date (1999, not 1998).
git-svn-id: svn://10.0.0.236/trunk@50031 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-06 21:52:17 +00:00
jband%netscape.com
cd534a023e - the rest of the fix for bug 14738 - detect JSErrors with
JSErrorReports when thrown as exceptions. Extract JSErrorReport
and convert to an xpcexception. This restores functionality that
was whacked when JS errors-as-exceptions was enabled in the JS
engine.
- add conversion support for string-with-length as part of array
support mentioned in bug 13420. All the array stuff is basically
in with minimal testcases. More comprehensive tests need to be
written to verify and tune the code.
- fix a broken #undef
- switch to using PR_Alloc/PR_Free internally in nsjsid where we
were using new/delete before. This is prompted by warren's change
to nsID::ToString that uses PR_Alloc were before it used new.
This fixes an alloc/delete mismatch detected by Purify.
r=mccabe


git-svn-id: svn://10.0.0.236/trunk@50024 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-06 21:35:27 +00:00
sspitzer%netscape.com
ac743ecce8 fix for #15197 (and a whole bunch of duplicates).
fix by vidur, r=rogerl


git-svn-id: svn://10.0.0.236/trunk@50023 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-06 21:31:34 +00:00
beard%netscape.com
e6c61c5ffe added EcmaError.java, NativeError.java
git-svn-id: svn://10.0.0.236/trunk@50017 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-06 21:07:04 +00:00
norris%netscape.com
734f2fb55c Update contributors, add some license text.
git-svn-id: svn://10.0.0.236/trunk@50012 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-06 20:50:04 +00:00
cbegle%netscape.com
4cdb11b194 tests for javascript errors as exceptions, a feature that was recently
added to the javascript engine.

not part of the build.


git-svn-id: svn://10.0.0.236/trunk@50011 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-06 20:45:44 +00:00
norris%netscape.com
522636a5de Make sure creation of class loader is inside a try block to handle security exceptions.
git-svn-id: svn://10.0.0.236/trunk@49979 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-06 17:39:48 +00:00
brendan%mozilla.org
3188df57a2 Fix Object.prototype.toSource so it parenthesizes outermost-toSource literals for eval roundtrips.
git-svn-id: svn://10.0.0.236/trunk@49971 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-06 09:09:31 +00:00
brendan%mozilla.org
a17b679975 Top-level ToSource function for primitive type roundtrips.
git-svn-id: svn://10.0.0.236/trunk@49958 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-06 06:37:55 +00:00
brendan%mozilla.org
e8d09fd3a6 Fix two multi-threaded GC-rooting bugs:
- js_NewFunction wasn't initializing (clearing) JSFunction members before it
  linked the JSFunction to a JSObject that the GC could reach from a root.
- Make sure frame.scopeChain is cleared before linking frame via cx->fp, even
  though we set frame.scopeChain to some object later (another signal that we
  should rework js_Invoke to inline it and otherwise optimize it).


git-svn-id: svn://10.0.0.236/trunk@49957 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-06 06:29:43 +00:00
rogerl%netscape.com
74e6cc86a3 Added version 150, changed version testing in regexp
git-svn-id: svn://10.0.0.236/trunk@49911 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-06 00:10:27 +00:00
rogerl%netscape.com
ac914fc99e Bug #14545 - get array length exceptions working with non-Number array
contructor arguments.


git-svn-id: svn://10.0.0.236/trunk@49874 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-05 22:11:57 +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
rogerl%netscape.com
51378fb74f Errors as exceptions working from generated code.
git-svn-id: svn://10.0.0.236/trunk@49848 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-05 19:44:24 +00:00
kipp%netscape.com
feff21ed38 r=jband; fixed a memory leak
git-svn-id: svn://10.0.0.236/trunk@49841 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-05 14:56:41 +00:00
mccabe%netscape.com
1664bd1228 Initial checkin of TestScan.java, a simple driver for generating and printing various kinds of parse trees, and for profiling scanning, parsing and compiling.
git-svn-id: svn://10.0.0.236/trunk@49792 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-05 03:47:04 +00:00
dmose%mozilla.org
de7b2e5e74 update license boilerplate to NPL dual w/GPL, r=norris@netscape,a=norris@netscape.com
git-svn-id: svn://10.0.0.236/trunk@49783 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-05 01:42:01 +00:00
dmose%mozilla.org
239d60872d update license boilerplate to NPL dual w/GPL, r=norris@netscape,a=norris@netscape.com
git-svn-id: svn://10.0.0.236/trunk@49766 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-05 00:44:05 +00:00
rogerl%netscape.com
4c19332cbb First cut at errors as exceptions - These changes should be benign since
the errors are being wrapped by runtime exceptions and still need to be
explicitly caught (this is happening in the interpreter, but not in
generated code).


git-svn-id: svn://10.0.0.236/trunk@49760 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-05 00:21:07 +00:00
waterson%netscape.com
9145c77cc4 Bug 15367. Dump 'class' instead of 'file/line' for NS_LOG_REFCNT. r=shaver,dp
git-svn-id: svn://10.0.0.236/trunk@49757 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-05 00:07:54 +00:00
norris%netscape.com
288c2fdcfb Fix up makefiles; previous patch was mis-applied.
git-svn-id: svn://10.0.0.236/trunk@49733 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-04 21:31:21 +00:00
norris%netscape.com
19a71ea13f Fix bug found by Andrew Wason (see below).
Problem was that one transformation of a node to GETVAR wasn't protected by a check of inWithStatement().

======================================
Subject:
        multiple scopes
   Date:
        Fri, 01 Oct 1999 12:39:14 -0400
   From:
        Andrew Wason <aw@softcom.com>
     To:
        norris@netscape.com
    CC:
        Howard Lin <howard@softcom.com>




When I create two scopes, and one scope evaulates a string in the other
scope, it works.  However, if I do this while handling an exception thrown
within a JavaAdapter method, it fails with an exception.

Run the attached Java program with the two script files.  scope1.js
evaluates a string "printMessage" in the scope of scope2.js.  This returns
a function object which is then invoked.  This works in 3 cases, but fails
in the 4th (in the catch in the JavaAdapter).  Even in the 4th case where
it fails, printing the function object looks normal.

Am I doing something wrong, or is there a bug here?

java CrossScope scope1.js scope2.js

Outside of JavaAdapter
works before exception
works after exception
Inside of JavaAdapter
works before exception
Caught exception
pma=
function printMessage(msg) {
     java.lang.System.out.println(msg);
}

Exception in thread "main" org.mozilla.javascript.JavaScriptException:
org.mozilla.javascript.EvaluatorException: The undefined value has no
properties.
         at
org.mozilla.javascript.JavaScriptException.wrapException(JavaScriptException
.java:61)
         at
org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java,
Compiled Code)
         at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1256)
         at org.mozilla.javascript.Interpreter.interpret(Interpreter.java,
Compiled Code)
         at
org.mozilla.javascript.InterpretedScript.call(InterpretedScript.java:49)
         at
org.mozilla.javascript.InterpretedScript.exec(InterpretedScript.java:37)
         at org.mozilla.javascript.Context.evaluateReader(Context.java:697)
         at CrossScope.<init>(CrossScope.java:30)
         at CrossScope.main(CrossScope.java:10)


Thanks,
Andrew

import java.io.*;
import org.mozilla.javascript.*;

public class CrossScope {
	private Context m_jsContext;
	private Scriptable m_scope1;
	private Scriptable m_scope2;

	public static void main(String args[]) throws Exception {
		new CrossScope(args[0], args[1]);
	}

	private CrossScope(String strFile1, String strFile2) throws Exception {
		// Associate Context with main thread
		m_jsContext = Context.enter();
                m_jsContext.setOptimizationLevel(-1);

		// Init scope1, expose Scope object
  		m_scope1 = m_jsContext.initStandardObjects(new ImporterTopLevel());
		m_scope1.put("Scope", m_scope1, this);

		// Init scope2
		m_scope2 = m_jsContext.initStandardObjects(new ImporterTopLevel());

		// Run script in scope2
		Reader r2 = new FileReader(strFile2);
		m_jsContext.evaluateReader(m_scope2, r2, strFile2, 1, null);

		// Eval input JS in scope1 - it can in turn eval JS over in scope2
		Reader r1 = new FileReader(strFile1);
		Object obj = m_jsContext.evaluateReader(m_scope1, r1, strFile1, 1, null);
		if (obj instanceof Throwable)
			((Throwable)obj).printStackTrace();

		m_jsContext.exit();
	}

	public Object scope1Eval(String str) throws JavaScriptException {
			Context cx = Context.enter(m_jsContext);
			Object objResult = cx.evaluateString(m_scope1, str, "scope1EvalString", 1, null);
			cx.exit();
			return objResult;
	}

	public Object scope2Eval(String str) throws JavaScriptException {
			Context cx = Context.enter(m_jsContext);
			Object objResult = cx.evaluateString(m_scope2, str, "scope2EvalString", 1, null);
			cx.exit();
			return objResult;
	}
}


// Scope1

importPackage(java.lang);

System.out.println("Outside of JavaAdapter");

try {
	var pm = Scope.scope2Eval("printMessage");
	pm("works before exception");
	System.arraycopy(null, 5, null, 5, 100);
} catch (e) {
	var pma = Scope.scope2Eval("printMessage");
	pma("works after exception");
}

var obj = new Runnable() {
	run: function() {
		System.out.println("Inside of JavaAdapter");
		try {
			var pm = Scope.scope2Eval("printMessage");
			pm("works before exception");
			System.arraycopy(null, 5, null, 5, 100);
		} catch (e) {
			System.out.println("Caught exception");
			var pma = Scope.scope2Eval("printMessage");
			System.out.println("pma=" + pma);
			pma("works after exception");
		}
	}
};

obj.run();



// Scope2

function printMessage(msg) {
	java.lang.System.out.println(msg);
}


git-svn-id: svn://10.0.0.236/trunk@49726 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-04 18:27:30 +00:00
beard%netscape.com
75c8c9cd12 changed from directly using "MSL ShLibRuntime.Lib" to using "NSLibraryStartup.o" to enable GC leak detector. r=smfr
git-svn-id: svn://10.0.0.236/trunk@49691 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-03 20:47:12 +00:00
beard%netscape.com
da97767078 changed from directly using "MSL DropInRuntime.Lib" to using "NSComponentStartup.o" to enable GC leak detector. r=smfr
git-svn-id: svn://10.0.0.236/trunk@49690 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-03 20:46:23 +00:00
beard%netscape.com
cd941313ec changed from directly using "MSL ShLibRuntime.Lib" to using "NSLibraryStartup.o" to enable GC leak detector. r=smfr
git-svn-id: svn://10.0.0.236/trunk@49686 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-03 20:23:01 +00:00
norris%netscape.com
c3494a9ffb Fix the following bugs:
14443 "Same origin" security policy may be circumvented using docu
14820 Fixing up the relationship between nsCodeBasePrincipal and n
14919 Crash in JS MM code
Reviewed by mstoltz, approved by scc.


git-svn-id: svn://10.0.0.236/trunk@49647 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-02 03:41:37 +00:00
norris%netscape.com
69ec6c9b26 Contribution from Andrew Wason:
Subject:
        optimizer Makefiles
   Date:
        Fri, 01 Oct 1999 14:50:05 -0400
   From:
        Andrew Wason <aw@softcom.com>
     To:
        norris@netscape.com
    CC:
        Howard Lin <howard@softcom.com>




Norris,

Here are patches to the Rhino Makefiles to build the optimizer package and
the jsc compiler.  They also fix a problem with "gmake clean".

Andrew
--
Andrew Wason
SoftCom, Inc.
aw@softcom.com


git-svn-id: svn://10.0.0.236/trunk@49613 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-01 22:58:48 +00:00
norris%netscape.com
34f7a63ece \t doesn't work on Windows.
git-svn-id: svn://10.0.0.236/trunk@49612 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-01 22:56:30 +00:00
kipp%netscape.com
29f22b7a81 Convert to a module from a component
git-svn-id: svn://10.0.0.236/trunk@49497 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-30 21:47:04 +00:00
kipp%netscape.com
72f4eb33d6 Fixed shutdown related memory leaks
git-svn-id: svn://10.0.0.236/trunk@49462 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-30 21:12:33 +00:00
beard%netscape.com
a2370105c8 fixed output directory
git-svn-id: svn://10.0.0.236/trunk@49308 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-29 16:11:58 +00:00
beard%netscape.com
8ce70dfe45 fixed source folder name
git-svn-id: svn://10.0.0.236/trunk@49307 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-29 16:10:25 +00:00
beard%netscape.com
ea14ed5e8f build debugger with CW Pro 4.
git-svn-id: svn://10.0.0.236/trunk@49306 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-29 16:07:22 +00:00
beard%netscape.com
b828a0f15c builds the optimizer using CW Pro 4.
git-svn-id: svn://10.0.0.236/trunk@49305 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-29 15:55:29 +00:00
sfraser%netscape.com
7c61e9da87 More type mismatch fixing for shavear
git-svn-id: svn://10.0.0.236/trunk@49279 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-29 03:07:27 +00:00
shaver%netscape.com
a2616788dd nsIRegistry scriptability update, r=dveditz,dp,alecf a=leaf,chofmann
git-svn-id: svn://10.0.0.236/trunk@49273 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-29 02:36:54 +00:00