mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-01 14:45:29 +00:00
Bug 604864 - Optimize undefined, NaN and Infinity in methodjit. r=dmandelin
This commit is contained in:
parent
5cce2a3041
commit
c402f81ebb
9
js/src/jit-test/tests/jaeger/optimize-globals-1.js
Normal file
9
js/src/jit-test/tests/jaeger/optimize-globals-1.js
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
function testLocalNames() {
|
||||
var NaN = 4;
|
||||
var undefined = 5;
|
||||
var Infinity = 6;
|
||||
return NaN + undefined + Infinity;
|
||||
}
|
||||
assertEq(testLocalNames(), 15);
|
||||
|
20
js/src/jit-test/tests/jaeger/optimize-globals-2.js
Normal file
20
js/src/jit-test/tests/jaeger/optimize-globals-2.js
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
function testNaN(x) {
|
||||
var x = NaN;
|
||||
assertEq(isNaN(x), true);
|
||||
}
|
||||
testNaN();
|
||||
|
||||
function testInfinity(x) {
|
||||
return (x === Infinity);
|
||||
}
|
||||
assertEq(testInfinity(Infinity), true);
|
||||
assertEq(testInfinity(6), false);
|
||||
assertEq(testInfinity(-Infinity), false);
|
||||
|
||||
function testUndefined(x) {
|
||||
return (x === undefined);
|
||||
}
|
||||
assertEq(testUndefined(undefined), true);
|
||||
assertEq(testUndefined(), true);
|
||||
assertEq(testUndefined(5), false);
|
9
js/src/jit-test/tests/jaeger/optimize-globals-3.js
Normal file
9
js/src/jit-test/tests/jaeger/optimize-globals-3.js
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
NaN = 4;
|
||||
undefined = 5;
|
||||
Infinity = 6;
|
||||
|
||||
assertEq(isNaN(NaN), true);
|
||||
assertEq(Infinity > 100, true);
|
||||
assertEq(undefined != 5, true);
|
||||
|
@ -1525,8 +1525,8 @@ static JSStdName standard_class_names[] = {
|
||||
{js_InitObjectClass, EAGER_ATOM(eval), CLASP(Object)},
|
||||
|
||||
/* Global properties and functions defined by the Number class. */
|
||||
{js_InitNumberClass, LAZY_ATOM(NaN), CLASP(Number)},
|
||||
{js_InitNumberClass, LAZY_ATOM(Infinity), CLASP(Number)},
|
||||
{js_InitNumberClass, EAGER_ATOM(NaN), CLASP(Number)},
|
||||
{js_InitNumberClass, EAGER_ATOM(Infinity), CLASP(Number)},
|
||||
{js_InitNumberClass, LAZY_ATOM(isNaN), CLASP(Number)},
|
||||
{js_InitNumberClass, LAZY_ATOM(isFinite), CLASP(Number)},
|
||||
{js_InitNumberClass, LAZY_ATOM(parseFloat), CLASP(Number)},
|
||||
|
@ -181,6 +181,8 @@ const char *const js_common_atom_names[] = {
|
||||
"use strict", /* useStrictAtom */
|
||||
"loc", /* locAtom */
|
||||
"line", /* lineAtom */
|
||||
"Infinity", /* InfinityAtom */
|
||||
"NaN", /* NaNAtom */
|
||||
|
||||
#if JS_HAS_XML_SUPPORT
|
||||
js_etago_str, /* etagoAtom */
|
||||
|
@ -373,6 +373,8 @@ struct JSAtomState
|
||||
JSAtom *useStrictAtom;
|
||||
JSAtom *locAtom;
|
||||
JSAtom *lineAtom;
|
||||
JSAtom *InfinityAtom;
|
||||
JSAtom *NaNAtom;
|
||||
|
||||
#if JS_HAS_XML_SUPPORT
|
||||
JSAtom *etagoAtom;
|
||||
@ -407,8 +409,6 @@ struct JSAtomState
|
||||
|
||||
/* Less frequently used atoms, pinned lazily by JS_ResolveStandardClass. */
|
||||
struct {
|
||||
JSAtom *InfinityAtom;
|
||||
JSAtom *NaNAtom;
|
||||
JSAtom *XMLListAtom;
|
||||
JSAtom *decodeURIAtom;
|
||||
JSAtom *decodeURIComponentAtom;
|
||||
|
@ -4336,6 +4336,20 @@ mjit::Compiler::jsop_bindgname()
|
||||
void
|
||||
mjit::Compiler::jsop_getgname(uint32 index)
|
||||
{
|
||||
/* Optimize undefined, NaN and Infinity. */
|
||||
JSAtom *atom = script->getAtom(index);
|
||||
if (atom == cx->runtime->atomState.typeAtoms[JSTYPE_VOID]) {
|
||||
frame.push(UndefinedValue());
|
||||
return;
|
||||
}
|
||||
if (atom == cx->runtime->atomState.NaNAtom) {
|
||||
frame.push(cx->runtime->NaNValue);
|
||||
return;
|
||||
}
|
||||
if (atom == cx->runtime->atomState.InfinityAtom) {
|
||||
frame.push(cx->runtime->positiveInfinityValue);
|
||||
return;
|
||||
}
|
||||
#if defined JS_MONOIC
|
||||
jsop_bindgname();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user