зеркало из https://github.com/mozilla/pjs.git
Merge mozilla-central to tracemonkey.
This commit is contained in:
Коммит
1189e52a80
|
@ -91,6 +91,24 @@ function checkModification(e, funcName, argument, expectedRes, before, after) {
|
|||
}
|
||||
}
|
||||
|
||||
function assignToClassListStrict(e) {
|
||||
"use strict";
|
||||
try {
|
||||
e.classList = "foo";
|
||||
ok(false, "assigning to classList didn't throw");
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
function assignToClassList(e) {
|
||||
try {
|
||||
var expect = e.classList;
|
||||
e.classList = "foo";
|
||||
is(e.classList, expect, "classList should be unchanged after assignment");
|
||||
} catch (e) {
|
||||
ok(false, "assigning to classList threw");
|
||||
}
|
||||
}
|
||||
|
||||
function testClassList(e) {
|
||||
|
||||
// basic tests
|
||||
|
@ -101,10 +119,9 @@ function testClassList(e) {
|
|||
is(typeof(e.classList.add), "function", "no classList.add function");
|
||||
is(typeof(e.classList.remove), "function", "no classList.remove function");
|
||||
is(typeof(e.classList.toggle), "function", "no classList.toggle function");
|
||||
try {
|
||||
e.classList = "foo";
|
||||
ok(false, "assigning to classList didn't throw");
|
||||
} catch (e) { }
|
||||
|
||||
assignToClassListStrict(e);
|
||||
assignToClassList(e);
|
||||
|
||||
// length attribute
|
||||
|
||||
|
|
|
@ -12,13 +12,13 @@ function startTest() {
|
|||
return false;
|
||||
ok(!v.seeking, "seeking should default to false");
|
||||
try {
|
||||
v.seeking = 1;
|
||||
readonly = false;
|
||||
v.seeking = true;
|
||||
readonly = v.seeking === false;
|
||||
}
|
||||
catch(e) {
|
||||
readonly = true;
|
||||
readonly = "threw exception: " + e;
|
||||
}
|
||||
ok(readonly, "seeking should be readonly");
|
||||
is(readonly, true, "seeking should be readonly");
|
||||
|
||||
v.play();
|
||||
v.currentTime=seekTime;
|
||||
|
|
|
@ -10,17 +10,37 @@
|
|||
<video id='v1' onerror="event.stopPropagation();"></video><audio id='a1' onerror="event.stopPropagation();"></audio>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
"use strict";
|
||||
var v1 = document.getElementById('v1');
|
||||
var a1 = document.getElementById('a1');
|
||||
var passed = true;
|
||||
var passed = "truthy";
|
||||
|
||||
try {
|
||||
v1.networkState = 0;
|
||||
} catch (e) {
|
||||
passed = !passed;
|
||||
}
|
||||
try {
|
||||
a1.networkState = 0;
|
||||
passed = false;
|
||||
} catch(e) { }
|
||||
ok(passed, "Should not be able to set networkState (readonly attribute)");
|
||||
} catch (e) {
|
||||
passed = !passed;
|
||||
}
|
||||
ok(passed === true,
|
||||
"Setting networkState throws in strict mode (readonly attribute)");
|
||||
</script>
|
||||
|
||||
<script class="testbody" type="text/javascript">
|
||||
var v1 = document.getElementById('v1');
|
||||
var a1 = document.getElementById('a1');
|
||||
var passed = false;
|
||||
|
||||
var oldv1ns = v1.networkState, olda1ns = a1.networkState;
|
||||
try {
|
||||
v1.networkState = 0;
|
||||
a1.networkState = 0;
|
||||
passed = v1.networkState === oldv1ns && a1.networkState === olda1ns;
|
||||
} catch (e) { }
|
||||
ok(passed, "Should not be able to modify networkState (readonly attribute)");
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -10,20 +10,42 @@
|
|||
<video id='v1' onerror="event.stopPropagation();"></video><audio id='a1' onerror="event.stopPropagation();"></audio>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
"use strict";
|
||||
var v1 = document.getElementById('v1');
|
||||
var a1 = document.getElementById('a1');
|
||||
var passed = true;
|
||||
var passed = "truthy";
|
||||
|
||||
is(v1.readyState, 0);
|
||||
is(a1.readyState, 0);
|
||||
|
||||
try {
|
||||
v1.readyState = 0;
|
||||
} catch (e) {
|
||||
passed = !passed;
|
||||
}
|
||||
try {
|
||||
a1.readyState = 0;
|
||||
passed = false;
|
||||
} catch (e) {
|
||||
passed = !passed;
|
||||
}
|
||||
ok(passed === true,
|
||||
"Setting readyState throws in strict mode (readonly attribute)");
|
||||
</script>
|
||||
|
||||
<script class="testbody" type="text/javascript">
|
||||
var v1 = document.getElementById('v1');
|
||||
var a1 = document.getElementById('a1');
|
||||
var passed = false;
|
||||
|
||||
is(v1.readyState, 0);
|
||||
is(a1.readyState, 0);
|
||||
|
||||
try {
|
||||
v1.readyState = 1;
|
||||
a1.readyState = 1;
|
||||
passed = v1.readyState === 0 && a1.readyState === 0;
|
||||
} catch(e) { }
|
||||
ok(passed, "Should not be able to set readyState (readonly attribute)");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -24,17 +24,35 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=371724
|
|||
<script class="testbody" type="text/javascript">
|
||||
/** Test for Bug 371724 **/
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
function doe() {
|
||||
var isException = false;
|
||||
function checkReadOnly() {
|
||||
var elt = document.getElementById('a');
|
||||
var oldValue = elt.hallo;
|
||||
var actual;
|
||||
try {
|
||||
document.getElementById('a').hallo = false;
|
||||
elt.hallo = false;
|
||||
actual = elt.hallo;
|
||||
} catch (ex) {
|
||||
isException = ex.name;
|
||||
actual = "" + ex;
|
||||
}
|
||||
ok(isException == "TypeError", "Setting a readonly xbl property should throw a TypeError exception");
|
||||
is(actual, true,
|
||||
"Setting a readonly xbl property should do nothing if !strict");
|
||||
checkReadOnlyStrict();
|
||||
}
|
||||
function checkReadOnlyStrict() {
|
||||
"use strict";
|
||||
var elt = document.getElementById('a');
|
||||
var actual;
|
||||
try {
|
||||
elt.hallo = false;
|
||||
actual = "should have thrown";
|
||||
} catch (ex) {
|
||||
actual = ex instanceof TypeError;
|
||||
}
|
||||
is(actual, true,
|
||||
"Setting a readonly xbl property should throw a TypeError exception if strict");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
setTimeout(doe, 600);
|
||||
addLoadEvent(checkReadOnly);
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -57,7 +57,9 @@ CPPSRCS = \
|
|||
testPropCache.cpp \
|
||||
testTrap.cpp \
|
||||
testSameValue.cpp \
|
||||
testSeal.cpp \
|
||||
testXDR.cpp \
|
||||
testSetPropertyWithNativeGetterStubSetter.cpp \
|
||||
$(NULL)
|
||||
|
||||
DEFINES += -DEXPORT_JS_API
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#include "tests.h"
|
||||
|
||||
BEGIN_TEST(testSeal_bug535703)
|
||||
{
|
||||
JSObject *obj = JS_NewObject(cx, NULL, NULL, NULL);
|
||||
CHECK(obj);
|
||||
JS_SealObject(cx, obj, JS_TRUE); // don't crash
|
||||
return true;
|
||||
}
|
||||
END_TEST(testSeal_bug535703)
|
|
@ -0,0 +1,62 @@
|
|||
#include "tests.h"
|
||||
#include "jsxdrapi.h"
|
||||
|
||||
static JSBool
|
||||
nativeGet(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
*vp = INT_TO_JSVAL(17);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
BEGIN_TEST(testSetPropertyWithNativeGetterStubSetter)
|
||||
{
|
||||
jsvalRoot vobj(cx);
|
||||
JSObject *obj = JS_NewObject(cx, NULL, NULL, NULL);
|
||||
CHECK(obj);
|
||||
vobj = OBJECT_TO_JSVAL(obj);
|
||||
|
||||
CHECK(JS_DefineProperty(cx, global, "globalProp", vobj,
|
||||
JS_PropertyStub, JS_PropertyStub,
|
||||
JSPROP_ENUMERATE));
|
||||
|
||||
CHECK(JS_DefineProperty(cx, obj, "prop", JSVAL_VOID,
|
||||
nativeGet, JS_PropertyStub,
|
||||
JSPROP_SHARED));
|
||||
|
||||
EXEC("'use strict'; \n"
|
||||
"var error, passed = false; \n"
|
||||
"try \n"
|
||||
"{ \n"
|
||||
" this.globalProp.prop = 42; \n"
|
||||
" throw new Error('setting property succeeded!'); \n"
|
||||
"} \n"
|
||||
"catch (e) \n"
|
||||
"{ \n"
|
||||
" error = e; \n"
|
||||
" if (e instanceof TypeError) \n"
|
||||
" passed = true; \n"
|
||||
"} \n"
|
||||
" \n"
|
||||
"if (!passed) \n"
|
||||
" throw error; \n");
|
||||
|
||||
EXEC("var error, passed = false; \n"
|
||||
"try \n"
|
||||
"{ \n"
|
||||
" this.globalProp.prop = 42; \n"
|
||||
" if (this.globalProp.prop === 17) \n"
|
||||
" passed = true; \n"
|
||||
" else \n"
|
||||
" throw new Error('bad value after set!'); \n"
|
||||
"} \n"
|
||||
"catch (e) \n"
|
||||
"{ \n"
|
||||
" error = e; \n"
|
||||
"} \n"
|
||||
" \n"
|
||||
"if (!passed) \n"
|
||||
" throw error; \n");
|
||||
|
||||
return true;
|
||||
}
|
||||
END_TEST(testSetPropertyWithNativeGetterStubSetter)
|
|
@ -2604,6 +2604,14 @@ JS_GetGCParameterForThread(JSContext *cx, JSGCParamKey key)
|
|||
#endif
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_FlushCaches(JSContext *cx)
|
||||
{
|
||||
#ifdef JS_TRACER
|
||||
js_FlushJITCache(cx);
|
||||
#endif
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(intN)
|
||||
JS_AddExternalStringFinalizer(JSStringFinalizeOp finalizer)
|
||||
{
|
||||
|
@ -2947,6 +2955,8 @@ JS_SealObject(JSContext *cx, JSObject *obj, JSBool deep)
|
|||
nslots = scope->freeslot;
|
||||
for (i = 0; i != nslots; ++i) {
|
||||
v = STOBJ_GET_SLOT(obj, i);
|
||||
if (i == JSSLOT_PRIVATE && (obj->getClass()->flags & JSCLASS_HAS_PRIVATE))
|
||||
continue;
|
||||
if (JSVAL_IS_PRIMITIVE(v))
|
||||
continue;
|
||||
if (!JS_SealObject(cx, JSVAL_TO_OBJECT(v), deep))
|
||||
|
|
|
@ -1324,6 +1324,15 @@ JS_SetGCParameterForThread(JSContext *cx, JSGCParamKey key, uint32 value);
|
|||
extern JS_PUBLIC_API(uint32)
|
||||
JS_GetGCParameterForThread(JSContext *cx, JSGCParamKey key);
|
||||
|
||||
/*
|
||||
* Flush the code cache for the current thread. The operation might be
|
||||
* delayed if the cache cannot be flushed currently because native
|
||||
* code is currently executing.
|
||||
*/
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_FlushCaches(JSContext *cx);
|
||||
|
||||
/*
|
||||
* Add a finalizer for external strings created by JS_NewExternalString (see
|
||||
* below) using a type-code returned from this function, and that understands
|
||||
|
|
|
@ -4390,11 +4390,12 @@ js_NativeSet(JSContext *cx, JSObject *obj, JSScopeProperty *sprop, bool added,
|
|||
} else {
|
||||
/*
|
||||
* Allow API consumers to create shared properties with stub setters.
|
||||
* Such properties lack value storage, so setting them is like writing
|
||||
* to /dev/null.
|
||||
* Such properties effectively function as data descriptors which are
|
||||
* not writable, so attempting to set such a property should do nothing
|
||||
* or throw if we're in strict mode.
|
||||
*/
|
||||
if (SPROP_HAS_STUB_SETTER(sprop))
|
||||
return true;
|
||||
if (!(sprop->attrs & JSPROP_GETTER) && SPROP_HAS_STUB_SETTER(sprop))
|
||||
return js_ReportGetterOnlyAssignment(cx);
|
||||
}
|
||||
|
||||
sample = cx->runtime->propertyRemovals;
|
||||
|
@ -6121,17 +6122,20 @@ js_IsCallable(JSObject *obj, JSContext *cx)
|
|||
return callable;
|
||||
}
|
||||
|
||||
void
|
||||
JSBool
|
||||
js_ReportGetterOnlyAssignment(JSContext *cx)
|
||||
{
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_GETTER_ONLY, NULL);
|
||||
return JS_ReportErrorFlagsAndNumber(cx,
|
||||
JSREPORT_WARNING | JSREPORT_STRICT |
|
||||
JSREPORT_STRICT_MODE_ERROR,
|
||||
js_GetErrorMessage, NULL,
|
||||
JSMSG_GETTER_ONLY);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSBool)
|
||||
js_GetterOnlyPropertyStub(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
js_ReportGetterOnlyAssignment(cx);
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_GETTER_ONLY);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -990,7 +990,7 @@ js_ComputeFilename(JSContext *cx, JSStackFrame *caller,
|
|||
extern JSBool
|
||||
js_IsCallable(JSObject *obj, JSContext *cx);
|
||||
|
||||
void
|
||||
extern JSBool
|
||||
js_ReportGetterOnlyAssignment(JSContext *cx);
|
||||
|
||||
extern JS_FRIEND_API(JSBool)
|
||||
|
|
|
@ -3267,7 +3267,7 @@ class RegExpNativeCompiler {
|
|||
js_FragProfiling_FragFinalizer(frag, tm);
|
||||
}
|
||||
)
|
||||
js_ResetJIT(cx);
|
||||
js_FlushJITCache(cx);
|
||||
} else {
|
||||
if (!guard) insertGuard(loopLabel, re_chars, re_length);
|
||||
re->flags |= JSREG_NOCOMPILE;
|
||||
|
|
|
@ -853,10 +853,8 @@ JSScopeProperty::set(JSContext* cx, JSObject* obj, jsval* vp)
|
|||
return js_InternalGetOrSet(cx, obj, id, fval, JSACC_WRITE, 1, vp, vp);
|
||||
}
|
||||
|
||||
if (attrs & JSPROP_GETTER) {
|
||||
js_ReportGetterOnlyAssignment(cx);
|
||||
return false;
|
||||
}
|
||||
if (attrs & JSPROP_GETTER)
|
||||
return !!js_ReportGetterOnlyAssignment(cx);
|
||||
|
||||
/* See the comment in JSScopeProperty::get as to why we can check for With. */
|
||||
if (STOBJ_GET_CLASS(obj) == &js_WithClass)
|
||||
|
|
|
@ -2293,6 +2293,12 @@ ResetJIT(JSContext* cx, TraceVisFlushReason r)
|
|||
#define ResetJIT(cx, r) ResetJITImpl(cx)
|
||||
#endif
|
||||
|
||||
void
|
||||
js_FlushJITCache(JSContext *cx)
|
||||
{
|
||||
ResetJIT(cx, FR_OOM);
|
||||
}
|
||||
|
||||
static void
|
||||
TrashTree(JSContext* cx, TreeFragment* f);
|
||||
|
||||
|
|
|
@ -1479,7 +1479,7 @@ extern bool
|
|||
js_OverfullJITCache(JSTraceMonitor* tm);
|
||||
|
||||
extern void
|
||||
js_ResetJIT(JSContext* cx);
|
||||
js_FlushJITCache(JSContext* cx);
|
||||
|
||||
extern void
|
||||
js_PurgeJITOracle();
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -0,0 +1,111 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/licenses/publicdomain/
|
||||
* Contributor:
|
||||
* Jason Orendorff
|
||||
* Jeff Walden <jwalden+code@mit.edu>
|
||||
*/
|
||||
|
||||
var gTestfile = "template.js";
|
||||
//-----------------------------------------------------------------------------
|
||||
var BUGNUMBER = 523846;
|
||||
var summary =
|
||||
"Assignments to a property that has a getter but not a setter should not " +
|
||||
"throw a TypeError per ES5 (at least not until strict mode is supported)";
|
||||
var actual = "Early failure";
|
||||
var expect = "No errors";
|
||||
|
||||
|
||||
printBugNumber(BUGNUMBER);
|
||||
printStatus(summary);
|
||||
|
||||
var o = { get p() { return "a"; } };
|
||||
|
||||
function test1()
|
||||
{
|
||||
o.p = "b";
|
||||
assertEq(o.p, "a");
|
||||
}
|
||||
|
||||
function test2()
|
||||
{
|
||||
function T() {}
|
||||
T.prototype = o;
|
||||
y = new T();
|
||||
y.p = "b";
|
||||
assertEq(y.p, "a");
|
||||
}
|
||||
|
||||
function strictTest1()
|
||||
{
|
||||
"use strict";
|
||||
|
||||
o.p = "b"; // strict-mode violation here
|
||||
assertEq(o.p, "a");
|
||||
}
|
||||
|
||||
function strictTest2()
|
||||
{
|
||||
"use strict";
|
||||
|
||||
function T() {}
|
||||
T.prototype = o;
|
||||
y = new T;
|
||||
y.p = "b"; // strict-mode violation here
|
||||
assertEq(y.p, "a");
|
||||
}
|
||||
|
||||
var errors = [];
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
test1();
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
errors.push(e);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
test2();
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
errors.push(e);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
strictTest1();
|
||||
errors.push("strictTest1 didn't fail");
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
if (!(e instanceof TypeError))
|
||||
errors.push("strictTest1 didn't fail with a TypeError: " + e);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
strictTest2();
|
||||
errors.push("strictTest2 didn't fail");
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
if (!(e instanceof TypeError))
|
||||
errors.push("strictTest2 didn't fail with a TypeError: " + e);
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
errors.push("Unexpected error: " + e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
actual = errors.length > 0 ? errors.join(", ") : "No errors";
|
||||
}
|
||||
|
||||
reportCompare(expect, actual, summary);
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
url-prefix ../../jsreftest.html?test=ecma_5/Types/
|
||||
script 8.12.5-01.js
|
|
@ -0,0 +1 @@
|
|||
gTestsubsuite='Types';
|
|
@ -0,0 +1,98 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/licenses/publicdomain/
|
||||
* Contributor:
|
||||
* Jason Orendorff
|
||||
* Jeff Walden <jwalden+code@mit.edu>
|
||||
*/
|
||||
|
||||
var gTestfile = "template.js";
|
||||
//-----------------------------------------------------------------------------
|
||||
var BUGNUMBER = 523846;
|
||||
var summary =
|
||||
"Assignments to a property that has a getter but not a setter should not " +
|
||||
"throw a TypeError per ES5 (at least not until strict mode is supported)";
|
||||
var actual = "Early failure";
|
||||
var expect = "No errors";
|
||||
|
||||
|
||||
printBugNumber(BUGNUMBER);
|
||||
printStatus(summary);
|
||||
|
||||
var o = { get p() { return "a"; } };
|
||||
|
||||
function test1()
|
||||
{
|
||||
o.p = "b"; // strict-mode violation here
|
||||
assertEq(o.p, "a");
|
||||
}
|
||||
|
||||
function test2()
|
||||
{
|
||||
function T() {}
|
||||
T.prototype = o;
|
||||
y = new T();
|
||||
y.p = "b"; // strict-mode violation here
|
||||
assertEq(y.p, "a");
|
||||
}
|
||||
|
||||
|
||||
var errors = [];
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
test1();
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
errors.push(e);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
test2();
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
errors.push(e);
|
||||
}
|
||||
|
||||
options("strict");
|
||||
options("werror");
|
||||
try
|
||||
{
|
||||
test1();
|
||||
errors.push("strict+werror didn't make test1 fail");
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
if (!(e instanceof TypeError))
|
||||
errors.push("test1 with strict+werror failed without a TypeError: " + e);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
test2();
|
||||
errors.push("strict+werror didn't make test2 fail");
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
if (!(e instanceof TypeError))
|
||||
errors.push("test2 with strict+werror failed without a TypeError: " + e);
|
||||
}
|
||||
|
||||
options("strict");
|
||||
options("werror");
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
errors.push("Unexpected error: " + e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
actual = errors.length > 0 ? errors.join(", ") : "No errors";
|
||||
}
|
||||
|
||||
reportCompare(expect, actual, summary);
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
url-prefix ../../jsreftest.html?test=ecma_5/extensions/
|
||||
script 8.12.5-01.js
|
|
@ -0,0 +1 @@
|
|||
gTestsubsuite='extensions';
|
|
@ -67,6 +67,7 @@ CPPSRCS = \
|
|||
nsXREDirProvider.cpp \
|
||||
nsNativeAppSupportBase.cpp \
|
||||
nsAppData.cpp \
|
||||
nsSigHandlers.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_SPLASHSCREEN
|
||||
|
@ -120,10 +121,6 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
|
|||
CMMSRCS += MacApplicationDelegate.mm
|
||||
endif
|
||||
|
||||
ifneq (,$(filter-out OS2 WINNT,$(OS_ARCH)))
|
||||
CPPSRCS += nsSigHandlers.cpp
|
||||
endif
|
||||
|
||||
SHARED_LIBRARY_LIBS += ../profile/src/$(LIB_PREFIX)profile_s.$(LIB_SUFFIX)
|
||||
|
||||
ifdef MOZ_ENABLE_XREMOTE
|
||||
|
|
|
@ -239,9 +239,7 @@ protected:
|
|||
};
|
||||
#endif
|
||||
|
||||
#if defined(XP_UNIX) || defined(XP_BEOS)
|
||||
extern void InstallUnixSignalHandlers(const char *ProgramName);
|
||||
#endif
|
||||
extern void InstallSignalHandlers(const char *ProgramName);
|
||||
|
||||
#define FILE_COMPATIBILITY_INFO NS_LITERAL_CSTRING("compatibility.ini")
|
||||
|
||||
|
@ -2678,9 +2676,7 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(XP_UNIX) || defined(XP_BEOS)
|
||||
InstallUnixSignalHandlers(argv[0]);
|
||||
#endif
|
||||
InstallSignalHandlers(argv[0]);
|
||||
|
||||
#ifdef MOZ_ACCESSIBILITY_ATK
|
||||
// Reset GTK_MODULES, strip atk-bridge if exists
|
||||
|
|
|
@ -42,6 +42,10 @@
|
|||
* platforms that do not support it.
|
||||
*/
|
||||
|
||||
#include "nsSigHandlers.h"
|
||||
|
||||
#ifdef XP_UNIX
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -55,6 +59,7 @@
|
|||
#include <sys/resource.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h> // atoi
|
||||
#include <ucontext.h>
|
||||
#endif
|
||||
|
||||
#if defined(SOLARIS)
|
||||
|
@ -204,7 +209,53 @@ my_glib_log_func(const gchar *log_domain, GLogLevelFlags log_level,
|
|||
|
||||
#endif
|
||||
|
||||
void InstallUnixSignalHandlers(const char *ProgramName)
|
||||
static void fpehandler(int signum, siginfo_t *si, void *context)
|
||||
{
|
||||
#ifdef XP_MACOSX
|
||||
ucontext_t *uc = (ucontext_t *)context;
|
||||
|
||||
#if defined(__i386__) || defined(__amd64__)
|
||||
_STRUCT_FP_CONTROL *ctrl = &uc->uc_mcontext->__fs.__fpu_fcw;
|
||||
ctrl->__invalid = ctrl->__denorm = ctrl->__zdiv = ctrl->__ovrfl = ctrl->__undfl = ctrl->__precis = 1;
|
||||
|
||||
_STRUCT_FP_STATUS *status = &uc->uc_mcontext->__fs.__fpu_fsw;
|
||||
status->__invalid = status->__denorm = status->__zdiv = status->__ovrfl = status->__undfl =
|
||||
status->__precis = status->__stkflt = status->__errsumm = 0;
|
||||
|
||||
__uint32_t *mxcsr = &uc->uc_mcontext->__fs.__fpu_mxcsr;
|
||||
*mxcsr |= SSE_EXCEPTION_MASK; /* disable all SSE exceptions */
|
||||
*mxcsr &= ~SSE_STATUS_FLAGS; /* clear all pending SSE exceptions */
|
||||
#endif
|
||||
#endif
|
||||
#ifdef LINUX
|
||||
ucontext_t *uc = (ucontext_t *)context;
|
||||
|
||||
#if defined(__i386__)
|
||||
/*
|
||||
* It seems that we have no access to mxcsr on Linux. libc
|
||||
* seems to be translating cw/sw to mxcsr.
|
||||
*/
|
||||
unsigned long int *cw = &uc->uc_mcontext.fpregs->cw;
|
||||
*cw |= FPU_EXCEPTION_MASK;
|
||||
|
||||
unsigned long int *sw = &uc->uc_mcontext.fpregs->sw;
|
||||
*sw &= ~FPU_STATUS_FLAGS;
|
||||
#endif
|
||||
#if defined(__amd64__)
|
||||
__uint16_t *cw = &uc->uc_mcontext.fpregs->cwd;
|
||||
*cw |= FPU_EXCEPTION_MASK;
|
||||
|
||||
__uint16_t *sw = &uc->uc_mcontext.fpregs->swd;
|
||||
*sw &= ~FPU_STATUS_FLAGS;
|
||||
|
||||
__uint32_t *mxcsr = &uc->uc_mcontext.fpregs->mxcsr;
|
||||
*mxcsr |= SSE_EXCEPTION_MASK; /* disable all SSE exceptions */
|
||||
*mxcsr &= ~SSE_STATUS_FLAGS; /* clear all pending SSE exceptions */
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void InstallSignalHandlers(const char *ProgramName)
|
||||
{
|
||||
PL_strncpy(_progname,ProgramName, (sizeof(_progname)-1) );
|
||||
|
||||
|
@ -226,15 +277,19 @@ void InstallUnixSignalHandlers(const char *ProgramName)
|
|||
signal(SIGSEGV, abnormal_exit_handler);
|
||||
signal(SIGILL, abnormal_exit_handler);
|
||||
signal(SIGABRT, abnormal_exit_handler);
|
||||
signal(SIGFPE, abnormal_exit_handler);
|
||||
|
||||
#elif defined(CRAWL_STACK_ON_SIGSEGV)
|
||||
signal(SIGSEGV, ah_crap_handler);
|
||||
signal(SIGILL, ah_crap_handler);
|
||||
signal(SIGABRT, ah_crap_handler);
|
||||
signal(SIGFPE, ah_crap_handler);
|
||||
#endif // CRAWL_STACK_ON_SIGSEGV
|
||||
|
||||
/* Install a handler for floating point exceptions and disable them if they occur. */
|
||||
struct sigaction sa, osa;
|
||||
sa.sa_flags = SA_ONSTACK | SA_RESTART | SA_SIGINFO;
|
||||
sa.sa_sigaction = fpehandler;
|
||||
sigaction(SIGFPE, &sa, &osa);
|
||||
|
||||
#if defined(DEBUG) && defined(LINUX)
|
||||
const char *memLimit = PR_GetEnv("MOZ_MEM_LIMIT");
|
||||
if (memLimit && *memLimit)
|
||||
|
@ -289,3 +344,78 @@ void InstallUnixSignalHandlers(const char *ProgramName)
|
|||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#elif XP_WIN
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#ifdef _M_IX86
|
||||
/*
|
||||
* WinNT.h prior to SDK7 does not expose the structure of the ExtendedRegisters for ia86.
|
||||
* We known that MxCsr is at offset 0x18 and is a DWORD.
|
||||
*/
|
||||
#define MXCSR(ctx) (*(DWORD *)(((BYTE *)(ctx)->ExtendedRegisters) + 0x18))
|
||||
#endif
|
||||
|
||||
#ifdef _M_X64
|
||||
#define MXCSR(ctx) (ctx)->MxCsr
|
||||
#endif
|
||||
|
||||
#if defined(_M_IA32) || define(_M_X64)
|
||||
|
||||
#define X87CW(ctx) (ctx)->FloatSave.ControlWord
|
||||
#define X87SW(ctx) (ctx)->FloatSave.StatusWord
|
||||
|
||||
/*
|
||||
* SSE traps raise these exception codes, which are defined in internal NT headers
|
||||
* but not winbase.h
|
||||
*/
|
||||
#define STATUS_FLOAT_MULTIPLE_FAULTS 0xC00002B4
|
||||
#define STATUS_FLOAT_MULTIPLE_TRAPS 0xC00002B5
|
||||
|
||||
LONG __stdcall FpeHandler(PEXCEPTION_POINTERS pe)
|
||||
{
|
||||
PEXCEPTION_RECORD e = (PEXCEPTION_RECORD)pe->ExceptionRecord;
|
||||
CONTEXT *c = (CONTEXT*)pe->ContextRecord;
|
||||
|
||||
switch (e->ExceptionCode) {
|
||||
case STATUS_FLOAT_DENORMAL_OPERAND:
|
||||
case STATUS_FLOAT_DIVIDE_BY_ZERO:
|
||||
case STATUS_FLOAT_INEXACT_RESULT:
|
||||
case STATUS_FLOAT_INVALID_OPERATION:
|
||||
case STATUS_FLOAT_OVERFLOW:
|
||||
case STATUS_FLOAT_STACK_CHECK:
|
||||
case STATUS_FLOAT_UNDERFLOW:
|
||||
case STATUS_FLOAT_MULTIPLE_FAULTS:
|
||||
case STATUS_FLOAT_MULTIPLE_TRAPS:
|
||||
X87CW(c) |= FPU_EXCEPTION_MASK; /* disable all FPU exceptions */
|
||||
X86SW(c) &= ~FPU_STATUS_FLAGS; /* clear all pending FPU exceptions */
|
||||
#ifdef _M_IA32
|
||||
if (c->ContextFlags & CONTEXT_EXTENDED_REGISTERS) {
|
||||
#endif
|
||||
MXCSR(c) |= SSE_EXCEPTION_MASK; /* disable all SSE exceptions */
|
||||
MXCSR(c) &= ~SSE_STATUS_FLAGS; /* clear all pending SSE exceptions */
|
||||
#ifdef _M_IA32
|
||||
}
|
||||
#endif
|
||||
return EXCEPTION_CONTINUE_EXECUTION;
|
||||
}
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
|
||||
void InstallSignalHandlers(const char *ProgramName)
|
||||
{
|
||||
SetUnhandledExceptionFilter(FpeHandler);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void InstallSignalHandlers(const char *ProgramName)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
#error No signal handling implementation for this platform.
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
/* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corp
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Andreas Gal <gal@uci.edu>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#if defined(_M_IA32) || defined(_M_X86) || defined(__i386__) || defined(__amd64__)
|
||||
|
||||
/*
|
||||
* x87 FPU Control Word:
|
||||
*
|
||||
* 0 -> IM Invalid Operation
|
||||
* 1 -> DM Denormalized Operand
|
||||
* 2 -> ZM Zero Divide
|
||||
* 3 -> OM Overflow
|
||||
* 4 -> UM Underflow
|
||||
* 5 -> PM Precision
|
||||
*/
|
||||
#define FPU_EXCEPTION_MASK 0x3f
|
||||
|
||||
/*
|
||||
* x86 FPU Status Word:
|
||||
*
|
||||
* 0..5 -> Exception flags (see x86 FPU Control Word)
|
||||
* 6 -> SF Stack Fault
|
||||
* 7 -> ES Error Summary Status
|
||||
*/
|
||||
#define FPU_STATUS_FLAGS 0xff
|
||||
|
||||
/*
|
||||
* MXCSR Control and Status Register:
|
||||
*
|
||||
* 0..5 -> Exception flags (see x86 FPU Control Word)
|
||||
* 6 -> DAZ Denormals Are Zero
|
||||
* 7..12 -> Exception mask (see x86 FPU Control Word)
|
||||
*/
|
||||
#define SSE_STATUS_FLAGS FPU_EXCEPTION_MASK
|
||||
#define SSE_EXCEPTION_MASK (FPU_EXCEPTION_MASK << 7)
|
||||
|
||||
#endif
|
Загрузка…
Ссылка в новой задаче