Backed out 7 changesets (bug 1066234) for bustage

CLOSED TREE

Backed out changeset ce28663e61d4 (bug 1066234)
Backed out changeset e06ad6b69b25 (bug 1066234)
Backed out changeset 99933582c7d8 (bug 1066234)
Backed out changeset a40045b47bba (bug 1066234)
Backed out changeset f6b44a3c3c6f (bug 1066234)
Backed out changeset 478d797266b1 (bug 1066234)
Backed out changeset 73f4dd8f8d97 (bug 1066234)
This commit is contained in:
Phil Ringnalda 2015-03-10 20:44:12 -07:00
Родитель a5af76c3cf
Коммит c9d7caebde
15 изменённых файлов: 31 добавлений и 291 удалений

Просмотреть файл

@ -5360,7 +5360,7 @@ EmitFor(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn, ptrdiff_t top
}
static MOZ_NEVER_INLINE bool
EmitFunc(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn, bool needsProto = false)
EmitFunc(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn)
{
FunctionBox *funbox = pn->pn_funbox;
RootedFunction fun(cx, funbox->function());
@ -5459,13 +5459,7 @@ EmitFunc(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn, bool needsPr
MOZ_ASSERT(fun->isArrow() == (pn->getOp() == JSOP_LAMBDA_ARROW));
if (fun->isArrow() && Emit1(cx, bce, JSOP_THIS) < 0)
return false;
if (needsProto) {
MOZ_ASSERT(pn->getOp() == JSOP_LAMBDA);
pn->setOp(JSOP_FUNWITHPROTO);
}
return EmitIndex32(cx, pn->getOp(), index, bce);
} else {
MOZ_ASSERT(!needsProto);
}
/*
@ -6948,7 +6942,7 @@ EmitClass(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn)
ClassNames *names = classNode.names();
ParseNode *heritageExpression = classNode.heritage();
MOZ_ASSERT(!classNode.heritage(), "For now, no heritage expressions");
LexicalScopeNode *innerBlock = classNode.scope();
ParseNode *classMethods = innerBlock->pn_expr;
@ -6973,27 +6967,11 @@ EmitClass(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn)
if (!EnterBlockScope(cx, bce, &stmtInfo, innerBlock->pn_objbox, JSOP_UNINITIALIZED))
return false;
if (heritageExpression) {
if (!EmitTree(cx, bce, heritageExpression))
return false;
if (Emit1(cx, bce, JSOP_CLASSHERITAGE) < 0)
return false;
}
if (!EmitFunc(cx, bce, constructor, !!heritageExpression))
if (!EmitFunc(cx, bce, constructor))
return false;
if (heritageExpression) {
// JSOP_CLASSHERITAGE leaves both prototypes on the stack. After
// creating the constructor, trickly it to the bottom to make the object.
if (Emit1(cx, bce, JSOP_SWAP) < 0)
return false;
if (Emit1(cx, bce, JSOP_OBJWITHPROTO) < 0)
return false;
} else {
if (!EmitNewInit(cx, bce, JSProto_Object))
return false;
}
if (!EmitNewInit(cx, bce, JSProto_Object))
return false;
if (Emit1(cx, bce, JSOP_DUP2) < 0)
return false;

Просмотреть файл

@ -5851,6 +5851,13 @@ Parser<FullParseHandler>::classStatement()
return null();
}
// Because the binding definitions keep track of their blockId, we need to
// create at least the inner binding later. Keep track of the name's position
// in order to provide it for the nodes created later.
TokenPos namePos = pos();
MUST_MATCH_TOKEN(TOK_LC, JSMSG_CURLY_BEFORE_CLASS);
bool savedStrictness = setLocalStrictMode(true);
StmtInfoPC classStmt(context);
@ -5858,25 +5865,6 @@ Parser<FullParseHandler>::classStatement()
if (!classBlock)
return null();
// Because the binding definitions keep track of their blockId, we need to
// create at least the inner binding later. Keep track of the name's position
// in order to provide it for the nodes created later.
TokenPos namePos = pos();
ParseNode *classHeritage = null();
bool hasHeritage;
if (!tokenStream.matchToken(&hasHeritage, TOK_EXTENDS))
return false;
if (hasHeritage) {
if (!tokenStream.getToken(&tt))
return null();
classHeritage = memberExpr(tt, true);
if (!classHeritage)
return null();
}
MUST_MATCH_TOKEN(TOK_LC, JSMSG_CURLY_BEFORE_CLASS);
ParseNode *classMethods = propertyList(ClassBody);
if (!classMethods)
return null();
@ -5898,7 +5886,7 @@ Parser<FullParseHandler>::classStatement()
MOZ_ALWAYS_TRUE(setLocalStrictMode(savedStrictness));
return handler.newClass(nameNode, classHeritage, classBlock);
return handler.newClass(nameNode, null(), classBlock);
}
template <>

Просмотреть файл

@ -111,7 +111,6 @@
macro(EXPORT, "keyword 'export'") \
macro(IMPORT, "keyword 'import'") \
macro(CLASS, "keyword 'class'") \
macro(EXTENDS, "keyword 'extends'") \
macro(RESERVED, "reserved keyword") \
/* reserved keywords in strict mode */ \
macro(STRICT_RESERVED, "reserved keyword") \

Просмотреть файл

@ -979,7 +979,6 @@ TokenStream::checkForKeyword(const KeywordInfo *kw, TokenKind *ttp)
if (kw->tokentype == TOK_RESERVED
#ifndef JS_HAS_CLASSES
|| kw->tokentype == TOK_CLASS
|| kw->tokentype == TOK_EXTENDS
#endif
)
{

Просмотреть файл

@ -100,7 +100,6 @@ MSG_DEF(JSMSG_CANT_SET_PROTO_OF, 1, JSEXN_TYPEERR, "can't set prototype of
MSG_DEF(JSMSG_CANT_SET_PROTO_CYCLE, 0, JSEXN_TYPEERR, "can't set prototype: it would cause a prototype chain cycle")
MSG_DEF(JSMSG_INVALID_ARG_TYPE, 3, JSEXN_TYPEERR, "Invalid type: {0} can't be a{1} {2}")
MSG_DEF(JSMSG_TERMINATED, 1, JSEXN_ERR, "Script terminated by timeout at:\n{0}")
MSG_DEF(JSMSG_PROTO_NOT_OBJORNULL, 1, JSEXN_TYPEERR, "{0}.prototype is not an object or null")
// JSON
MSG_DEF(JSMSG_JSON_BAD_PARSE, 3, JSEXN_SYNTAXERR, "JSON.parse: {0} at line {1} column {2} of the JSON data")

Просмотреть файл

@ -2076,9 +2076,7 @@ js::CloneFunctionObjectUseSameScript(JSCompartment *compartment, HandleFunction
JSFunction *
js::CloneFunctionObject(JSContext *cx, HandleFunction fun, HandleObject parent,
gc::AllocKind allocKind,
NewObjectKind newKindArg /* = GenericObject */,
HandleObject proto)
gc::AllocKind allocKind, NewObjectKind newKindArg /* = GenericObject */)
{
MOZ_ASSERT(parent);
MOZ_ASSERT(!fun->isBoundFunction());
@ -2089,8 +2087,8 @@ js::CloneFunctionObject(JSContext *cx, HandleFunction fun, HandleObject parent,
return nullptr;
NewObjectKind newKind = useSameScript ? newKindArg : SingletonObject;
RootedObject cloneProto(cx, proto);
if (!cloneProto && fun->isStarGenerator()) {
RootedObject cloneProto(cx);
if (fun->isStarGenerator()) {
cloneProto = GlobalObject::getOrCreateStarGeneratorFunctionPrototype(cx, cx->global());
if (!cloneProto)
return nullptr;

Просмотреть файл

@ -578,8 +578,7 @@ CloneFunctionObjectUseSameScript(JSCompartment *compartment, HandleFunction fun)
extern JSFunction *
CloneFunctionObject(JSContext *cx, HandleFunction fun, HandleObject parent,
gc::AllocKind kind = JSFunction::FinalizeKind,
NewObjectKind newKindArg = GenericObject,
HandleObject proto = NullPtr());
NewObjectKind newKindArg = GenericObject);
extern bool
FindBody(JSContext *cx, HandleFunction fun, HandleLinearString src, size_t *bodyStart,

Просмотреть файл

@ -53,7 +53,6 @@ CanReuseFunctionForClone(JSContext *cx, HandleFunction fun)
inline JSFunction *
CloneFunctionObjectIfNotSingleton(JSContext *cx, HandleFunction fun, HandleObject parent,
HandleObject proto = NullPtr(),
NewObjectKind newKind = GenericObject)
{
/*
@ -72,10 +71,6 @@ CloneFunctionObjectIfNotSingleton(JSContext *cx, HandleFunction fun, HandleObjec
RootedObject obj(cx, SkipScopeParent(parent));
if (!JSObject::setParent(cx, fun, obj))
return nullptr;
ObjectOpResult succeeded;
if (proto && !SetPrototype(cx, fun, proto, succeeded))
return nullptr;
MOZ_ASSERT(!proto || succeeded);
fun->setEnvironment(parent);
return fun;
}
@ -87,7 +82,7 @@ CloneFunctionObjectIfNotSingleton(JSContext *cx, HandleFunction fun, HandleObjec
gc::AllocKind kind = fun->isExtended()
? extendedFinalizeKind
: finalizeKind;
return CloneFunctionObject(cx, fun, parent, kind, newKind, proto);
return CloneFunctionObject(cx, fun, parent, kind, newKind);
}
} /* namespace js */

Просмотреть файл

@ -1,74 +0,0 @@
var test = `
// It's an error to have a non-constructor as your heritage
assertThrowsInstanceOf(() => eval(\`class a extends Math.sin {
constructor() { }
}\`), TypeError);
// Unless it's null, in which case it works like a normal class, except that
// the prototype object does not inherit from Object.prototype.
class basic {
constructor() { }
}
class nullExtends extends null {
constructor() { }
}
assertEq(Object.getPrototypeOf(basic), Function.prototype);
assertEq(Object.getPrototypeOf(nullExtends), Function.prototype);
assertEq(Object.getPrototypeOf(basic.prototype), Object.prototype);
assertEq(Object.getPrototypeOf(nullExtends.prototype), null);
var baseMethodCalled = false;
var staticMethodCalled = false;
var overrideCalled = "";
class base {
constructor() { };
method() { baseMethodCalled = true; }
static staticMethod() { staticMethodCalled = true; }
override() { overrideCalled = "base" }
}
class derived extends base {
constructor() { };
override() { overrideCalled = "derived"; }
}
// Make sure we get the right object layouts.
assertEq(Object.getPrototypeOf(derived), base);
assertEq(Object.getPrototypeOf(derived.prototype), base.prototype);
// We do inherit the methods, right?
(new derived()).method();
assertEq(baseMethodCalled, true);
// But we can still override them?
(new derived()).override();
assertEq(overrideCalled, "derived");
// What about the statics?
derived.staticMethod();
assertEq(staticMethodCalled, true);
// Gotta extend an object, or null.
function nope() {
class Foo extends "Bar" {
constructor() { }
}
}
assertThrowsInstanceOf(nope, TypeError);
// The .prototype of the extension must be an object, or null.
nope.prototype = "not really, no";
function stillNo() {
class Foo extends nope {
constructor() { }
}
}
assertThrowsInstanceOf(stillNo, TypeError);
`;
if (classesEnabled())
eval(test);
if (typeof reportCompare === "function")
reportCompare(0, 0, "OK");

Просмотреть файл

@ -1,5 +1,4 @@
// Classes are always strict mode. Check computed property names and heritage
// expressions as well.
// Classes are always strict mode. Check computed property names as well.
var test = `
class a { constructor() { Object.preventExtensions({}).prop = 0; } }
@ -12,13 +11,6 @@ function shouldThrow() {
}
}
assertThrowsInstanceOf(shouldThrow, TypeError);
function shouldThrow2() {
class b extends (Object.preventExtensions({}).prop = 4) {
constructor() { }
}
}
assertThrowsInstanceOf(shouldThrow2, TypeError);
`;
if (classesEnabled())

Просмотреть файл

@ -1178,9 +1178,6 @@ function testClasses() {
function setClassMethods(class_, methods) {
class_.template.body = methods;
}
function setClassHeritage(class_, heritage) {
class_.template.heritage = heritage;
}
let simpleConstructor = simpleMethod("constructor", "method", false);
let emptyFooClass = classStmt(ident("Foo"), null, [simpleConstructor]);
@ -1320,51 +1317,6 @@ function testClasses() {
// Can't make a lexical binding inside a block.
assertError("if (1) class Foo { constructor() { } }", SyntaxError);
/* Heritage Expressions */
// It's illegal to have things that look like "multiple inheritance":
// non-parenthesized comma expressions.
assertError("class Foo extends null, undefined { constructor() { } }", SyntaxError);
// Again check for strict-mode in heritage expressions
assertError("class Foo extends (delete x) { constructor() { } }", SyntaxError);
// You must specify an inheritance if you say "extends"
assertError("class Foo extends { constructor() { } }", SyntaxError);
// "extends" is still a valid name for a method
setClassMethods(stmt, [simpleConstructor, simpleMethod("extends", "method", false)]);
assertStmt("class Foo { constructor() { }; extends() { } }", stmt);
// Immediate expression
setClassMethods(stmt, [simpleConstructor]);
setClassHeritage(stmt, lit(null));
assertStmt("class Foo extends null { constructor() { } }", stmt);
// Sequence expresson
setClassHeritage(stmt, seqExpr([ident("undefined"), ident("undefined")]));
assertStmt("class Foo extends (undefined, undefined) { constructor() { } }", stmt);
// Function expression
let emptyFunction = funExpr(null, [], blockStmt([]));
setClassHeritage(stmt, emptyFunction);
assertStmt("class Foo extends function(){ } { constructor() { } }", stmt);
// New expression
setClassHeritage(stmt, newExpr(emptyFunction, []));
assertStmt("class Foo extends new function(){ }() { constructor() { } }", stmt);
// Call expression
setClassHeritage(stmt, callExpr(emptyFunction, []));
assertStmt("class Foo extends function(){ }() { constructor() { } }", stmt);
// Dot expression
setClassHeritage(stmt, dotExpr(objExpr([]), ident("foo")));
assertStmt("class Foo extends {}.foo { constructor() { } }", stmt);
// Member expression
setClassHeritage(stmt, memExpr(objExpr([]), ident("foo")));
assertStmt("class Foo extends {}[foo] { constructor() { } }", stmt);
/* EOF */
// Clipped classes should throw a syntax error
assertError("class Foo {", SyntaxError);
@ -1381,7 +1333,6 @@ function testClasses() {
assertError("class Foo { static *y", SyntaxError);
assertError("class Foo { static get", SyntaxError);
assertError("class Foo { static get y", SyntaxError);
assertError("class Foo extends", SyntaxError);
}

Просмотреть файл

@ -1650,6 +1650,9 @@ CASE(EnableInterruptsPseudoOpcode)
/* Various 1-byte no-ops. */
CASE(JSOP_NOP)
CASE(JSOP_UNUSED2)
CASE(JSOP_UNUSED51)
CASE(JSOP_UNUSED52)
CASE(JSOP_UNUSED83)
CASE(JSOP_UNUSED92)
CASE(JSOP_UNUSED103)
CASE(JSOP_UNUSED104)
@ -3524,70 +3527,6 @@ CASE(JSOP_ARRAYPUSH)
}
END_CASE(JSOP_ARRAYPUSH)
CASE(JSOP_CLASSHERITAGE)
{
RootedValue &val = rootValue0;
val = REGS.sp[-1];
RootedValue &objProto = rootValue1;
RootedObject &funcProto = rootObject0;
if (val.isNull()) {
objProto.setNull();
if (!GetBuiltinPrototype(cx, JSProto_Function, &funcProto))
goto error;
} else {
if (!val.isObject() || !val.toObject().isConstructor()) {
ReportIsNotFunction(cx, val, 0, CONSTRUCT);
goto error;
}
funcProto = &val.toObject();
if (!GetProperty(cx, funcProto, funcProto, cx->names().prototype, &objProto))
goto error;
if (!objProto.isObjectOrNull()) {
ReportValueError(cx, JSMSG_PROTO_NOT_OBJORNULL, -1, objProto, NullPtr());
goto error;
}
}
REGS.sp[-1] = objProto;
PUSH_OBJECT(*funcProto);
}
END_CASE(JSOP_CLASSHERITAGE)
CASE(JSOP_FUNWITHPROTO)
{
RootedObject &proto = rootObject1;
proto = &REGS.sp[-1].toObject();
/* Load the specified function object literal. */
RootedFunction &fun = rootFunction0;
fun = script->getFunction(GET_UINT32_INDEX(REGS.pc));
JSObject *obj = CloneFunctionObjectIfNotSingleton(cx, fun, REGS.fp()->scopeChain(),
proto, GenericObject);
if (!obj)
goto error;
REGS.sp[-1].setObject(*obj);
}
END_CASE(JSOP_FUNWITHPROTO)
CASE(JSOP_OBJWITHPROTO)
{
RootedObject &proto = rootObject0;
proto = REGS.sp[-1].toObjectOrNull();
JSObject *obj = NewObjectWithGivenProto<PlainObject>(cx, proto, cx->global());
if (!obj)
goto error;
REGS.sp[-1].setObject(*obj);
}
END_CASE(JSOP_OBJWITHPROTO)
DEFAULT()
{
char numBuf[12];
@ -3770,8 +3709,7 @@ js::LambdaArrow(JSContext *cx, HandleFunction fun, HandleObject parent, HandleVa
{
MOZ_ASSERT(fun->isArrow());
RootedObject clone(cx, CloneFunctionObjectIfNotSingleton(cx, fun, parent, NullPtr(),
TenuredObject));
RootedObject clone(cx, CloneFunctionObjectIfNotSingleton(cx, fun, parent, TenuredObject));
if (!clone)
return nullptr;
@ -3797,7 +3735,7 @@ js::DefFunOperation(JSContext *cx, HandleScript script, HandleObject scopeChain,
*/
RootedFunction fun(cx, funArg);
if (fun->isNative() || fun->environment() != scopeChain) {
fun = CloneFunctionObjectIfNotSingleton(cx, fun, scopeChain, NullPtr(), TenuredObject);
fun = CloneFunctionObjectIfNotSingleton(cx, fun, scopeChain, TenuredObject);
if (!fun)
return false;
} else {

Просмотреть файл

@ -44,9 +44,9 @@
macro(import, import, TOK_IMPORT, JSVERSION_DEFAULT) \
macro(export, export, TOK_EXPORT, JSVERSION_DEFAULT) \
macro(class, class_, TOK_CLASS, JSVERSION_DEFAULT) \
macro(extends, extends, TOK_EXTENDS, JSVERSION_DEFAULT) \
/* Reserved keywords. */ \
macro(enum, enum_, TOK_RESERVED, JSVERSION_DEFAULT) \
macro(extends, extends, TOK_RESERVED, JSVERSION_DEFAULT) \
macro(super, super, TOK_RESERVED, JSVERSION_DEFAULT) \
/* Future reserved keywords, but only in strict mode. */ \
macro(implements, implements, TOK_STRICT_RESERVED, JSVERSION_DEFAULT) \

Просмотреть файл

@ -480,23 +480,8 @@
* Stack: callee, this, args => rval
*/ \
macro(JSOP_STRICTSPREADEVAL, 50, "strict-spreadeval", NULL, 1, 3, 1, JOF_BYTE|JOF_INVOKE|JOF_TYPESET|JOF_CHECKSTRICT) \
/*
* Writes the [[Prototype]] objects for both a class and its .prototype to
* the stack, given the result of a heritage expression.
* Category: Literals
* Type: Object
* Operands:
* Stack: heritage => objProto, funcProto
*/ \
macro(JSOP_CLASSHERITAGE, 51, "classheritage", NULL, 1, 1, 2, JOF_BYTE) \
/*
* Pushes a clone of a function with a given [[Prototype]] onto the stack.
* Category: Statements
* Type: Function
* Operands: uint32_t funcIndex
* Stack: proto => obj
*/ \
macro(JSOP_FUNWITHPROTO, 52, "funwithproto", NULL, 5, 1, 1, JOF_OBJECT) \
macro(JSOP_UNUSED51, 51, "unused51", NULL, 1, 0, 0, JOF_BYTE) \
macro(JSOP_UNUSED52, 52, "unused52", NULL, 1, 0, 0, JOF_BYTE) \
\
/*
* Pops the top of stack value, pushes property of it onto the stack.
@ -768,15 +753,8 @@
* nuses: (argc+2)
*/ \
macro(JSOP_NEW, 82, js_new_str, NULL, 3, -1, 1, JOF_UINT16|JOF_INVOKE|JOF_TYPESET) \
/*
* Pushes newly created object onto the stack with provided [[Prototype]].
*
* Category: Literals
* Type: Object
* Operands:
* Stack: proto => obj
*/ \
macro(JSOP_OBJWITHPROTO, 83, "objwithproto", NULL, 1, 1, 1, JOF_BYTE) \
\
macro(JSOP_UNUSED83, 83, "unused83", NULL, 1, 0, 0, JOF_BYTE) \
\
/*
* Fast get op for function arguments and local variables.

Просмотреть файл

@ -29,11 +29,11 @@ namespace js {
*
* https://developer.mozilla.org/en-US/docs/SpiderMonkey/Internals/Bytecode
*/
static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 255;
static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 252;
static const uint32_t XDR_BYTECODE_VERSION =
uint32_t(0xb973c0de - XDR_BYTECODE_VERSION_SUBTRAHEND);
static_assert(JSErr_Limit == 385,
static_assert(JSErr_Limit == 384,
"GREETINGS, POTENTIAL SUBTRAHEND INCREMENTER! If you added or "
"removed MSG_DEFs from js.msg, you should increment "
"XDR_BYTECODE_VERSION_SUBTRAHEND and update this assertion's "