Bug 568953 - Back out obsolete module code; r=jorendorff
authorEddy Bruel <ejpbruel@mozilla.com>
Tue, 05 Nov 2013 16:10:34 +0100
changeset 153628 82c3097bb8b3513e9d4acf9d62c43e9f6100cb3e
parent 153627 599442dc0da7a9c99e64ce39c5d4df21436aa2f8
child 153629 b85a27bdccfe95b21fcb4a335d374f474813bd95
push id25596
push userryanvm@gmail.com
push dateTue, 05 Nov 2013 20:28:59 +0000
treeherdermozilla-central@8b89e6626298 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs568953
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 568953 - Back out obsolete module code; r=jorendorff
js/src/builtin/Module.cpp
js/src/builtin/Module.h
js/src/frontend/BytecodeEmitter.cpp
js/src/frontend/FoldConstants.cpp
js/src/frontend/NameFunctions.cpp
js/src/frontend/ParseNode-inl.h
js/src/frontend/ParseNode.cpp
js/src/frontend/ParseNode.h
js/src/frontend/Parser.cpp
js/src/frontend/Parser.h
js/src/frontend/SharedContext.h
js/src/jit-test/tests/modules/moduleDeclaration.js
js/src/jit-test/tests/modules/nonkeyword.js
js/src/js.msg
js/src/jsreflect.cpp
js/src/moz.build
deleted file mode 100644
--- a/js/src/builtin/Module.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim: set ts=8 sts=4 et sw=4 tw=99:
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "builtin/Module.h"
-
-#include "jsobjinlines.h"
-
-using namespace js;
-
-namespace js {
-typedef Rooted<Module*> RootedModule;
-}
-
-const Class Module::class_ = {
-    "Module",
-    JSCLASS_HAS_RESERVED_SLOTS(2) | JSCLASS_IS_ANONYMOUS,
-    JS_PropertyStub,        /* addProperty */
-    JS_DeletePropertyStub,  /* delProperty */
-    JS_PropertyStub,        /* getProperty */
-    JS_StrictPropertyStub,  /* setProperty */
-    JS_EnumerateStub,
-    JS_ResolveStub,
-    JS_ConvertStub
-};
-
-inline void
-Module::setAtom(JSAtom *atom)
-{
-    setReservedSlot(ATOM_SLOT, StringValue(atom));
-}
-
-inline void
-Module::setScript(JSScript *script)
-{
-    setReservedSlot(SCRIPT_SLOT, PrivateValue(script));
-}
-
-Module *
-Module::create(ExclusiveContext *cx, HandleAtom atom)
-{
-    RootedObject object(cx, NewBuiltinClassInstance(cx, &class_));
-    if (!object)
-        return nullptr;
-    RootedModule module(cx, &object->as<Module>());
-    module->setAtom(atom);
-    module->setScript(nullptr);
-    return module;
-}
deleted file mode 100644
--- a/js/src/builtin/Module.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim: set ts=8 sts=4 et sw=4 tw=99:
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef builtin_Module_h
-#define builtin_Module_h
-
-#include "jsobj.h"
-
-namespace js {
-
-class Module : public JSObject {
-  public:
-    static Module *create(ExclusiveContext *cx, js::HandleAtom atom);
-
-    JSAtom *atom() {
-        return &getReservedSlot(ATOM_SLOT).toString()->asAtom();
-    };
-
-    JSScript *script() {
-        return (JSScript *) getReservedSlot(SCRIPT_SLOT).toPrivate();
-    }
-
-    static const Class class_;
-
-  private:
-    inline void setAtom(JSAtom *atom);
-    inline void setScript(JSScript *script);
-
-    static const uint32_t ATOM_SLOT = 0;
-    static const uint32_t SCRIPT_SLOT = 1;
-};
-
-} // namespace js
-
-#endif /* builtin_Module_h */
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -1715,20 +1715,17 @@ BytecodeEmitter::checkSingletonContext()
 }
 
 bool
 BytecodeEmitter::needsImplicitThis()
 {
     if (!script->compileAndGo)
         return true;
 
-    if (sc->isModuleBox()) {
-        /* Modules can never occur inside a with-statement */
-        return false;
-    } if (sc->isFunctionBox()) {
+    if (sc->isFunctionBox()) {
         if (sc->asFunctionBox()->inWith)
             return true;
     } else {
         JSObject *scope = sc->asGlobalSharedContext()->scopeChain();
         while (scope) {
             if (scope->is<WithObject>())
                 return true;
             scope = scope->enclosingScope();
@@ -6503,21 +6500,16 @@ frontend::EmitTree(ExclusiveContext *cx,
         if (Emit1(cx, bce, JSOP_DEBUGGER) < 0)
             return false;
         break;
 
       case PNK_NOP:
         JS_ASSERT(pn->getArity() == PN_NULLARY);
         break;
 
-      case PNK_MODULE:
-        // TODO: Add emitter support for modules
-        bce->reportError(nullptr, JSMSG_SYNTAX_ERROR);
-        return false;
-
       default:
         JS_ASSERT(0);
     }
 
     /* bce->emitLevel == 1 means we're last on the stack, so finish up. */
     if (ok && bce->emitLevel == 1) {
         if (!UpdateSourceCoordNotes(cx, bce, pn->pn_pos.end))
             return false;
--- a/js/src/frontend/FoldConstants.cpp
+++ b/js/src/frontend/FoldConstants.cpp
@@ -259,20 +259,16 @@ Fold(ExclusiveContext *cx, ParseNode **p
 
     // First, recursively fold constants on the children of this node.
     switch (pn->getArity()) {
       case PN_CODE:
         if (pn->isKind(PNK_FUNCTION) &&
             pn->pn_funbox->useAsmOrInsideUseAsm() && options.asmJSOption)
         {
             return true;
-        }
-        if (pn->getKind() == PNK_MODULE) {
-            if (!Fold(cx, &pn->pn_body, handler, options, false, SyntacticContext::Other))
-                return false;
         } else {
             // Note: pn_body is nullptr for functions which are being lazily parsed.
             JS_ASSERT(pn->getKind() == PNK_FUNCTION);
             if (pn->pn_body) {
                 if (!Fold(cx, &pn->pn_body, handler, options, pn->pn_funbox->inGenexpLambda,
                           SyntacticContext::Other))
                     return false;
             }
--- a/js/src/frontend/NameFunctions.cpp
+++ b/js/src/frontend/NameFunctions.cpp
@@ -311,17 +311,17 @@ class NameResolver
                 resolve(cur->pn_right, prefix);
             break;
           case PN_TERNARY:
             resolve(cur->pn_kid1, prefix);
             resolve(cur->pn_kid2, prefix);
             resolve(cur->pn_kid3, prefix);
             break;
           case PN_CODE:
-            JS_ASSERT(cur->isKind(PNK_MODULE) || cur->isKind(PNK_FUNCTION));
+            JS_ASSERT(cur->isKind(PNK_FUNCTION));
             resolve(cur->pn_body, prefix);
             break;
           case PN_LIST:
             for (ParseNode *nxt = cur->pn_head; nxt; nxt = nxt->pn_next)
                 resolve(nxt, prefix);
             break;
         }
         nparents--;
--- a/js/src/frontend/ParseNode-inl.h
+++ b/js/src/frontend/ParseNode-inl.h
@@ -20,16 +20,16 @@ ParseNode::name() const
     JS_ASSERT(isKind(PNK_FUNCTION) || isKind(PNK_NAME));
     JSAtom *atom = isKind(PNK_FUNCTION) ? pn_funbox->function()->atom() : pn_atom;
     return atom->asPropertyName();
 }
 
 inline JSAtom *
 ParseNode::atom() const
 {
-    JS_ASSERT(isKind(PNK_MODULE) || isKind(PNK_STRING));
-    return isKind(PNK_MODULE) ? pn_modulebox->module()->atom() : pn_atom;
+    JS_ASSERT(isKind(PNK_STRING));
+    return pn_atom;
 }
 
 } /* namespace frontend */
 } /* namespace js */
 
 #endif /* frontend_ParseNode_inl_h */
--- a/js/src/frontend/ParseNode.cpp
+++ b/js/src/frontend/ParseNode.cpp
@@ -1,17 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "frontend/ParseNode-inl.h"
 
-#include "builtin/Module.h"
 #include "frontend/Parser.h"
 
 #include "jscntxtinlines.h"
 
 using namespace js;
 using namespace js::frontend;
 
 using mozilla::IsFinite;
@@ -380,19 +379,16 @@ Parser<FullParseHandler>::cloneParseTree
     pn->setInParens(opn->isInParens());
     pn->setDefn(opn->isDefn());
     pn->setUsed(opn->isUsed());
 
     switch (pn->getArity()) {
 #define NULLCHECK(e)    JS_BEGIN_MACRO if (!(e)) return nullptr; JS_END_MACRO
 
       case PN_CODE:
-        if (pn->getKind() == PNK_MODULE) {
-            MOZ_ASSUME_UNREACHABLE("module nodes cannot be cloned");
-        }
         NULLCHECK(pn->pn_funbox = newFunctionBox(pn, opn->pn_funbox->function(), pc,
                                                  Directives(/* strict = */ opn->pn_funbox->strict),
                                                  opn->pn_funbox->generatorKind()));
         NULLCHECK(pn->pn_body = cloneParseTree(opn->pn_body));
         pn->pn_cookie = opn->pn_cookie;
         pn->pn_dflags = opn->pn_dflags;
         pn->pn_blockid = opn->pn_blockid;
         break;
@@ -762,43 +758,26 @@ ObjectBox::ObjectBox(JSFunction *functio
   : object(function),
     traceLink(traceLink),
     emitLink(nullptr)
 {
     JS_ASSERT(object->is<JSFunction>());
     JS_ASSERT(asFunctionBox()->function() == function);
 }
 
-ModuleBox *
-ObjectBox::asModuleBox()
-{
-    JS_ASSERT(isModuleBox());
-    return static_cast<ModuleBox *>(this);
-}
-
 FunctionBox *
 ObjectBox::asFunctionBox()
 {
     JS_ASSERT(isFunctionBox());
     return static_cast<FunctionBox *>(this);
 }
 
-ObjectBox::ObjectBox(Module *module, ObjectBox* traceLink)
-  : object(module),
-    traceLink(traceLink),
-    emitLink(nullptr)
-{
-    JS_ASSERT(object->is<Module>());
-}
-
 void
 ObjectBox::trace(JSTracer *trc)
 {
     ObjectBox *box = this;
     while (box) {
         MarkObjectRoot(trc, &box->object, "parser.object");
-        if (box->isModuleBox())
-            box->asModuleBox()->bindings.trace(trc);
         if (box->isFunctionBox())
             box->asFunctionBox()->bindings.trace(trc);
         box = box->traceLink;
     }
 }
--- a/js/src/frontend/ParseNode.h
+++ b/js/src/frontend/ParseNode.h
@@ -4,17 +4,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef frontend_ParseNode_h
 #define frontend_ParseNode_h
 
 #include "mozilla/Attributes.h"
 
-#include "builtin/Module.h"
 #include "frontend/TokenStream.h"
 
 namespace js {
 namespace frontend {
 
 template <typename ParseHandler>
 struct ParseContext;
 
@@ -130,17 +129,16 @@ class UpvarCookie
     F(LEXICALSCOPE) \
     F(LET) \
     F(SEQ) \
     F(FORIN) \
     F(FOROF) \
     F(FORHEAD) \
     F(ARGSBODY) \
     F(SPREAD) \
-    F(MODULE) \
     \
     /* Unary operators. */ \
     F(TYPEOF) \
     F(VOID) \
     F(NOT) \
     F(BITNOT) \
     \
     /* \
@@ -426,17 +424,16 @@ enum ParseNodeArity
 struct Definition;
 
 class LabeledStatement;
 class LoopControlStatement;
 class BreakStatement;
 class ContinueStatement;
 class ConditionalExpression;
 class PropertyAccess;
-class ModuleBox;
 
 class ParseNode
 {
     uint32_t            pn_type   : 16, /* PNK_* type */
                         pn_op     : 8,  /* see JSOp enum and jsopcode.tbl */
                         pn_arity  : 5,  /* see ParseNodeArity enum */
                         pn_parens : 1,  /* this expr was enclosed in parens */
                         pn_used   : 1,  /* name node is on a use-chain */
@@ -521,17 +518,16 @@ class ParseNode
             bool        hidden;         /* hidden genexp-induced JSOP_YIELD
                                            or directive prologue member (as
                                            pn_prologue) */
         } unary;
         struct {                        /* name, labeled statement, etc. */
             union {
                 JSAtom      *atom;      /* lexical name or label atom */
                 ObjectBox   *objbox;    /* block or regexp object */
-                ModuleBox   *modulebox; /* module object */
                 FunctionBox *funbox;    /* function object */
             };
             union {
                 ParseNode   *expr;      /* module or function body, var
                                            initializer, argument default, or
                                            base object of PNK_DOT */
                 Definition  *lexdef;    /* lexical definition for this use */
             };
@@ -1423,30 +1419,27 @@ ParseNode::isConstant()
 }
 
 class ObjectBox
 {
   public:
     JSObject *object;
 
     ObjectBox(JSObject *object, ObjectBox *traceLink);
-    bool isModuleBox() { return object->is<Module>(); }
     bool isFunctionBox() { return object->is<JSFunction>(); }
-    ModuleBox *asModuleBox();
     FunctionBox *asFunctionBox();
     void trace(JSTracer *trc);
 
   protected:
     friend struct CGObjectList;
 
     ObjectBox *traceLink;
     ObjectBox *emitLink;
 
     ObjectBox(JSFunction *function, ObjectBox *traceLink);
-    ObjectBox(Module *module, ObjectBox *traceLink);
 };
 
 enum ParseReportKind
 {
     ParseError,
     ParseWarning,
     ParseExtraWarning,
     ParseStrictError
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -546,49 +546,16 @@ Parser<ParseHandler>::newFunctionBox(Nod
 
     traceListHead = funbox;
     if (fn)
         handler.setFunctionBox(fn, funbox);
 
     return funbox;
 }
 
-ModuleBox::ModuleBox(ExclusiveContext *cx, ObjectBox *traceListHead, Module *module,
-                     ParseContext<FullParseHandler> *pc, bool extraWarnings)
-  : ObjectBox(module, traceListHead),
-      SharedContext(cx, Directives(/* strict = */ true), extraWarnings)
-{
-}
-
-template <>
-ModuleBox *
-Parser<FullParseHandler>::newModuleBox(Module *module, ParseContext<FullParseHandler> *outerpc)
-{
-    JS_ASSERT(module && !IsPoisonedPtr(module));
-
-    /*
-     * We use JSContext.tempLifoAlloc to allocate parsed objects and place them
-     * on a list in this Parser to ensure GC safety. Thus the tempLifoAlloc
-     * arenas containing the entries must be alive until we are done with
-     * scanning, parsing and code generation for the whole script or top-level
-     * function.
-     */
-    ModuleBox *modulebox =
-        alloc.new_<ModuleBox>(context, traceListHead, module, outerpc,
-                              options().extraWarningsOption);
-    if (!modulebox) {
-        js_ReportOutOfMemory(context);
-        return nullptr;
-    }
-
-    traceListHead = modulebox;
-
-    return modulebox;
-}
-
 template <typename ParseHandler>
 void
 Parser<ParseHandler>::trace(JSTracer *trc)
 {
     traceListHead->trace(trc);
 }
 
 void
@@ -2340,62 +2307,16 @@ Parser<ParseHandler>::functionArgsAndBod
         if (kind == Statement && !MatchOrInsertSemicolon(tokenStream))
             return false;
     }
 #endif
 
     return finishFunctionDefinition(pn, funbox, prelude, body);
 }
 
-template <>
-ParseNode *
-Parser<FullParseHandler>::moduleDecl()
-{
-    JS_ASSERT(tokenStream.currentName() == context->names().module);
-    if (!((pc->sc->isGlobalSharedContext() || pc->sc->isModuleBox()) && pc->atBodyLevel()))
-    {
-        report(ParseError, false, nullptr, JSMSG_MODULE_STATEMENT);
-        return nullptr;
-    }
-
-    ParseNode *pn = CodeNode::create(PNK_MODULE, &handler);
-    if (!pn)
-        return nullptr;
-    JS_ALWAYS_TRUE(tokenStream.matchToken(TOK_STRING));
-    RootedAtom atom(context, tokenStream.currentToken().atom());
-    Module *module = Module::create(context, atom);
-    if (!module)
-        return nullptr;
-    ModuleBox *modulebox = newModuleBox(module, pc);
-    if (!modulebox)
-        return nullptr;
-    pn->pn_modulebox = modulebox;
-
-    ParseContext<FullParseHandler> modulepc(this, pc, /* function = */ nullptr, modulebox,
-                                            /* newDirectives = */ nullptr, pc->staticLevel + 1,
-                                            pc->blockidGen);
-    if (!modulepc.init(tokenStream))
-        return nullptr;
-    MUST_MATCH_TOKEN(TOK_LC, JSMSG_CURLY_BEFORE_MODULE);
-    pn->pn_body = statements();
-    if (!pn->pn_body)
-        return nullptr;
-    MUST_MATCH_TOKEN(TOK_RC, JSMSG_CURLY_AFTER_MODULE);
-
-    return pn;
-}
-
-template <>
-SyntaxParseHandler::Node
-Parser<SyntaxParseHandler>::moduleDecl()
-{
-    JS_ALWAYS_FALSE(abortIfSyntaxParser());
-    return SyntaxParseHandler::NodeFailure;
-}
-
 template <typename ParseHandler>
 bool
 Parser<ParseHandler>::checkYieldNameValidity()
 {
     // In star generators and in JS >= 1.7, yield is a keyword.  Otherwise in
     // strict mode, yield is a future reserved word.
     if (pc->isStarGenerator() || versionNumber() >= JSVERSION_1_7 || pc->sc->strict) {
         report(ParseError, false, null(), JSMSG_RESERVED_ID, "yield");
@@ -5042,21 +4963,16 @@ Parser<ParseHandler>::statement(bool can
                 return null();
             return labeledStatement();
         }
         return expressionStatement();
 
       case TOK_NAME:
         if (tokenStream.peekToken() == TOK_COLON)
             return labeledStatement();
-        if (tokenStream.currentName() == context->names().module
-            && tokenStream.peekTokenSameLine() == TOK_STRING)
-        {
-            return moduleDecl();
-        }
         return expressionStatement();
 
       default:
         return expressionStatement();
     }
 }
 
 template <typename ParseHandler>
--- a/js/src/frontend/Parser.h
+++ b/js/src/frontend/Parser.h
@@ -403,17 +403,16 @@ class Parser : private AutoGCRooter, pub
      */
     Node parse(JSObject *chain);
 
     /*
      * Allocate a new parsed object or function container from
      * cx->tempLifoAlloc.
      */
     ObjectBox *newObjectBox(JSObject *obj);
-    ModuleBox *newModuleBox(Module *module, ParseContext<ParseHandler> *pc);
     FunctionBox *newFunctionBox(Node fn, JSFunction *fun, ParseContext<ParseHandler> *pc,
                                 Directives directives, GeneratorKind generatorKind);
 
     /*
      * Create a new function object given parse context (pc) and a name (which
      * is optional if this is a function expression).
      */
     JSFunction *newFunction(GenericParseContext *pc, HandleAtom atom, FunctionSyntaxKind kind,
@@ -488,17 +487,16 @@ class Parser : private AutoGCRooter, pub
      * Parsers whose name has a '1' suffix leave the TokenStream state
      * pointing to the token one past the end of the parsed fragment.  For a
      * number of the parsers this is convenient and avoids a lot of
      * unnecessary ungetting and regetting of tokens.
      *
      * Some parsers have two versions:  an always-inlined version (with an 'i'
      * suffix) and a never-inlined version (with an 'n' suffix).
      */
-    Node moduleDecl();
     Node functionStmt();
     Node functionExpr();
     Node statements();
 
     Node blockStatement();
     Node ifStatement();
     Node doWhileStatement();
     Node whileStatement();
--- a/js/src/frontend/SharedContext.h
+++ b/js/src/frontend/SharedContext.h
@@ -8,17 +8,16 @@
 #define frontend_SharedContext_h
 
 #include "jsatom.h"
 #include "jsopcode.h"
 #include "jspubtd.h"
 #include "jsscript.h"
 #include "jstypes.h"
 
-#include "builtin/Module.h"
 #include "frontend/ParseMaps.h"
 #include "frontend/ParseNode.h"
 #include "frontend/TokenStream.h"
 #include "vm/ScopeObject.h"
 
 namespace js {
 namespace frontend {
 
@@ -184,20 +183,18 @@ class SharedContext
       : context(cx),
         anyCxFlags(),
         strict(directives.strict()),
         extraWarnings(extraWarnings)
     {}
 
     virtual ObjectBox *toObjectBox() = 0;
     inline bool isGlobalSharedContext() { return toObjectBox() == nullptr; }
-    inline bool isModuleBox() { return toObjectBox() && toObjectBox()->isModuleBox(); }
     inline bool isFunctionBox() { return toObjectBox() && toObjectBox()->isFunctionBox(); }
     inline GlobalSharedContext *asGlobalSharedContext();
-    inline ModuleBox *asModuleBox();
     inline FunctionBox *asFunctionBox();
 
     bool hasExplicitUseStrict()        const { return anyCxFlags.hasExplicitUseStrict; }
     bool bindingsAccessedDynamically() const { return anyCxFlags.bindingsAccessedDynamically; }
     bool hasDebuggerStatement()        const { return anyCxFlags.hasDebuggerStatement; }
 
     void setExplicitUseStrict()           { anyCxFlags.hasExplicitUseStrict        = true; }
     void setBindingsAccessedDynamically() { anyCxFlags.bindingsAccessedDynamically = true; }
@@ -227,34 +224,16 @@ class GlobalSharedContext : public Share
 
 inline GlobalSharedContext *
 SharedContext::asGlobalSharedContext()
 {
     JS_ASSERT(isGlobalSharedContext());
     return static_cast<GlobalSharedContext*>(this);
 }
 
-class ModuleBox : public ObjectBox, public SharedContext
-{
-  public:
-    Bindings bindings;
-
-    ModuleBox(ExclusiveContext *cx, ObjectBox *traceListHead, Module *module,
-              ParseContext<FullParseHandler> *pc, bool extraWarnings);
-    ObjectBox *toObjectBox() { return this; }
-    Module *module() const { return &object->as<Module>(); }
-};
-
-inline ModuleBox *
-SharedContext::asModuleBox()
-{
-    JS_ASSERT(isModuleBox());
-    return static_cast<ModuleBox*>(this);
-}
-
 class FunctionBox : public ObjectBox, public SharedContext
 {
   public:
     Bindings        bindings;               /* bindings for this function */
     uint32_t        bufStart;
     uint32_t        bufEnd;
     uint32_t        startLine;
     uint32_t        startColumn;
deleted file mode 100644
--- a/js/src/jit-test/tests/modules/moduleDeclaration.js
+++ /dev/null
@@ -1,34 +0,0 @@
-load(libdir + "asserts.js");
-
-assertThrowsInstanceOf(function () {
-    Reflect.parse("module foo { }");
-}, SyntaxError);
-
-assertThrowsInstanceOf(function () {
-    Reflect.parse("function foo() { module 'bar' {} }");
-}, SyntaxError);
-
-assertThrowsInstanceOf(function () {
-    Reflect.parse("if (true) { module 'foo' {} }");
-}, SyntaxError);
-
-assertThrowsInstanceOf(function () {
-    Reflect.parse("module 'foo' { if (true) { module 'bar' {} } }");
-}, SyntaxError);
-
-var node = Reflect.parse("module 'foo' {}");
-assertEq(typeof node == "object" && node != null, true);
-assertEq(node.type, "Program");
-node = node.body;
-assertEq(typeof node == "object" && node != null, true);
-assertEq(node.length, 1);
-node = node[0];
-assertEq(typeof node == "object" && node != null, true);
-assertEq(node.type, "ModuleDeclaration");
-assertEq(node.name, "foo");
-node = node.body;
-assertEq(typeof node == "object" && node != null, true);
-assertEq(node.type, "BlockStatement");
-node = node.body;
-assertEq(typeof node == "object" && node != null, true);
-assertEq(node.length, 0);
deleted file mode 100644
--- a/js/src/jit-test/tests/modules/nonkeyword.js
+++ /dev/null
@@ -1,8 +0,0 @@
-// 'module' is not a keyword in these contexts.
-
-module = {};
-module.p = 0;
-assertEq(this.module.p, 0);
-
-assertEq(eval('module \n "hello"'), "hello");
-assertEq(eval('module \n "world" \n {}'), "world");
--- a/js/src/js.msg
+++ b/js/src/js.msg
@@ -383,40 +383,37 @@ MSG_DEF(JSMSG_INVALID_LANGUAGE_TAG,   32
 MSG_DEF(JSMSG_INVALID_LOCALE_MATCHER, 330, 1, JSEXN_RANGEERR, "invalid locale matcher in supportedLocalesOf(): {0}")
 MSG_DEF(JSMSG_INVALID_OPTION_VALUE,   331, 2, JSEXN_RANGEERR, "invalid value {1} for option {0}")
 MSG_DEF(JSMSG_INVALID_DIGITS_VALUE,   332, 1, JSEXN_RANGEERR, "invalid digits value: {0}")
 MSG_DEF(JSMSG_INTL_OBJECT_REINITED,   333, 0, JSEXN_TYPEERR, "can't initialize object twice as an object of an Intl constructor")
 MSG_DEF(JSMSG_INVALID_CURRENCY_CODE,  334, 1, JSEXN_RANGEERR, "invalid currency code in NumberFormat(): {0}")
 MSG_DEF(JSMSG_UNDEFINED_CURRENCY,     335, 0, JSEXN_TYPEERR, "undefined currency in NumberFormat() with currency style")
 MSG_DEF(JSMSG_INVALID_TIME_ZONE,      336, 1, JSEXN_RANGEERR, "invalid time zone in DateTimeFormat(): {0}")
 MSG_DEF(JSMSG_DATE_NOT_FINITE,        337, 0, JSEXN_RANGEERR, "date value is not finite in DateTimeFormat.format()")
-MSG_DEF(JSMSG_MODULE_STATEMENT,       338, 0, JSEXN_SYNTAXERR, "module declarations may only appear at the top level of a program or module body")
-MSG_DEF(JSMSG_CURLY_BEFORE_MODULE,    339, 0, JSEXN_SYNTAXERR, "missing { before module body")
-MSG_DEF(JSMSG_CURLY_AFTER_MODULE,     340, 0, JSEXN_SYNTAXERR, "missing } after module body")
-MSG_DEF(JSMSG_USE_ASM_DIRECTIVE_FAIL, 341, 0, JSEXN_SYNTAXERR, "\"use asm\" is only meaningful in the Directive Prologue of a function body")
-MSG_DEF(JSMSG_USE_ASM_TYPE_FAIL,      342, 1, JSEXN_TYPEERR, "asm.js type error: {0}")
-MSG_DEF(JSMSG_USE_ASM_LINK_FAIL,      343, 1, JSEXN_TYPEERR, "asm.js link error: {0}")
-MSG_DEF(JSMSG_USE_ASM_TYPE_OK,        344, 1, JSEXN_ERR,     "successfully compiled asm.js code ({0})")
-MSG_DEF(JSMSG_BAD_ARROW_ARGS,         345, 0, JSEXN_SYNTAXERR, "invalid arrow-function arguments (parentheses around the arrow-function may help)")
-MSG_DEF(JSMSG_YIELD_IN_ARROW,         346, 0, JSEXN_SYNTAXERR, "arrow function may not contain yield")
-MSG_DEF(JSMSG_WRONG_VALUE,            347, 2, JSEXN_ERR, "expected {0} but found {1}")
-MSG_DEF(JSMSG_PAR_ARRAY_SCATTER_BAD_TARGET, 348, 1, JSEXN_ERR, "target for index {0} is not an integer")
-MSG_DEF(JSMSG_SELFHOSTED_UNBOUND_NAME,349, 0, JSEXN_TYPEERR, "self-hosted code may not contain unbound name lookups")
-MSG_DEF(JSMSG_DEPRECATED_PRAGMA,  350, 1, JSEXN_SYNTAXERR, "Using //@ to indicate {0} pragmas is deprecated. Use //# instead")
-MSG_DEF(JSMSG_BAD_DESTRUCT_ASSIGN,    351, 1, JSEXN_SYNTAXERR, "can't assign to {0} using destructuring assignment")
-MSG_DEF(JSMSG_TYPEDOBJECT_ARRAYTYPE_BAD_ARGS, 352, 0, JSEXN_ERR, "Invalid arguments")
-MSG_DEF(JSMSG_TYPEDOBJECT_BINARYARRAY_BAD_INDEX, 353, 0, JSEXN_RANGEERR, "invalid or out-of-range index")
-MSG_DEF(JSMSG_TYPEDOBJECT_STRUCTTYPE_BAD_ARGS, 354, 0, JSEXN_RANGEERR, "invalid field descriptor")
-MSG_DEF(JSMSG_TYPEDOBJECT_NOT_BINARYSTRUCT,   355, 1, JSEXN_TYPEERR, "{0} is not a BinaryStruct")
-MSG_DEF(JSMSG_TYPEDOBJECT_SUBARRAY_INTEGER_ARG, 356, 1, JSEXN_ERR, "argument {0} must be an integer")
-MSG_DEF(JSMSG_TYPEDOBJECT_STRUCTTYPE_EMPTY_DESCRIPTOR, 357, 0, JSEXN_ERR, "field descriptor cannot be empty")
-MSG_DEF(JSMSG_TYPEDOBJECT_STRUCTTYPE_BAD_FIELD, 358, 1, JSEXN_ERR, "field {0} is not a valid BinaryData Type descriptor")
-MSG_DEF(JSMSG_GENERATOR_FINISHED,     359, 0, JSEXN_TYPEERR, "generator has already finished")
-MSG_DEF(JSMSG_TYPEDOBJECT_TOO_BIG, 360, 0, JSEXN_ERR, "Type is too large to allocate")
-MSG_DEF(JSMSG_TYPEDOBJECT_NOT_TYPE_OBJECT, 361, 0, JSEXN_ERR, "Expected a type object")
-MSG_DEF(JSMSG_TOO_MANY_CON_SPREADARGS, 362, 0, JSEXN_RANGEERR, "too many constructor arguments")
-MSG_DEF(JSMSG_TOO_MANY_FUN_SPREADARGS, 363, 0, JSEXN_RANGEERR, "too many function arguments")
+MSG_DEF(JSMSG_USE_ASM_DIRECTIVE_FAIL, 338, 0, JSEXN_SYNTAXERR, "\"use asm\" is only meaningful in the Directive Prologue of a function body")
+MSG_DEF(JSMSG_USE_ASM_TYPE_FAIL,      339, 1, JSEXN_TYPEERR, "asm.js type error: {0}")
+MSG_DEF(JSMSG_USE_ASM_LINK_FAIL,      340, 1, JSEXN_TYPEERR, "asm.js link error: {0}")
+MSG_DEF(JSMSG_USE_ASM_TYPE_OK,        341, 1, JSEXN_ERR,     "successfully compiled asm.js code ({0})")
+MSG_DEF(JSMSG_BAD_ARROW_ARGS,         342, 0, JSEXN_SYNTAXERR, "invalid arrow-function arguments (parentheses around the arrow-function may help)")
+MSG_DEF(JSMSG_YIELD_IN_ARROW,         343, 0, JSEXN_SYNTAXERR, "arrow function may not contain yield")
+MSG_DEF(JSMSG_WRONG_VALUE,            344, 2, JSEXN_ERR, "expected {0} but found {1}")
+MSG_DEF(JSMSG_PAR_ARRAY_SCATTER_BAD_TARGET, 345, 1, JSEXN_ERR, "target for index {0} is not an integer")
+MSG_DEF(JSMSG_SELFHOSTED_UNBOUND_NAME,346, 0, JSEXN_TYPEERR, "self-hosted code may not contain unbound name lookups")
+MSG_DEF(JSMSG_DEPRECATED_PRAGMA,  347, 1, JSEXN_SYNTAXERR, "Using //@ to indicate {0} pragmas is deprecated. Use //# instead")
+MSG_DEF(JSMSG_BAD_DESTRUCT_ASSIGN,    348, 1, JSEXN_SYNTAXERR, "can't assign to {0} using destructuring assignment")
+MSG_DEF(JSMSG_TYPEDOBJECT_ARRAYTYPE_BAD_ARGS, 349, 0, JSEXN_ERR, "Invalid arguments")
+MSG_DEF(JSMSG_TYPEDOBJECT_BINARYARRAY_BAD_INDEX, 350, 0, JSEXN_RANGEERR, "invalid or out-of-range index")
+MSG_DEF(JSMSG_TYPEDOBJECT_STRUCTTYPE_BAD_ARGS, 351, 0, JSEXN_RANGEERR, "invalid field descriptor")
+MSG_DEF(JSMSG_TYPEDOBJECT_NOT_BINARYSTRUCT,   352, 1, JSEXN_TYPEERR, "{0} is not a BinaryStruct")
+MSG_DEF(JSMSG_TYPEDOBJECT_SUBARRAY_INTEGER_ARG, 353, 1, JSEXN_ERR, "argument {0} must be an integer")
+MSG_DEF(JSMSG_TYPEDOBJECT_STRUCTTYPE_EMPTY_DESCRIPTOR, 354, 0, JSEXN_ERR, "field descriptor cannot be empty")
+MSG_DEF(JSMSG_TYPEDOBJECT_STRUCTTYPE_BAD_FIELD, 355, 1, JSEXN_ERR, "field {0} is not a valid BinaryData Type descriptor")
+MSG_DEF(JSMSG_GENERATOR_FINISHED,     356, 0, JSEXN_TYPEERR, "generator has already finished")
+MSG_DEF(JSMSG_TYPEDOBJECT_TOO_BIG, 357, 0, JSEXN_ERR, "Type is too large to allocate")
+MSG_DEF(JSMSG_TYPEDOBJECT_NOT_TYPE_OBJECT, 358, 0, JSEXN_ERR, "Expected a type object")
+MSG_DEF(JSMSG_TOO_MANY_CON_SPREADARGS, 359, 0, JSEXN_RANGEERR, "too many constructor arguments")
+MSG_DEF(JSMSG_TOO_MANY_FUN_SPREADARGS, 360, 0, JSEXN_RANGEERR, "too many function arguments")
 MSG_DEF(JSMSG_DEBUG_NOT_DEBUGGEE,     364, 2, JSEXN_ERR, "{0} is not a debuggee {1}")
 MSG_DEF(JSMSG_TYPEDOBJECT_NOT_TYPED_OBJECT, 365, 0, JSEXN_ERR, "Expected a typed object")
 MSG_DEF(JSMSG_TYPEDOBJECT_NO_SUCH_PROP, 366, 1, JSEXN_TYPEERR, "No such property: {0}")
 MSG_DEF(JSMSG_TYPEDOBJECT_HANDLE_BAD_ARGS, 367, 2, JSEXN_TYPEERR, "argument {0} invalid: expected {1}")
 MSG_DEF(JSMSG_TYPEDOBJECT_HANDLE_UNATTACHED, 368, 0, JSEXN_TYPEERR, "handle unattached")
 MSG_DEF(JSMSG_TYPEDOBJECT_HANDLE_BAD_TYPE, 369, 0, JSEXN_TYPEERR, "handle moved to destination of incorrect type")
--- a/js/src/jsreflect.cpp
+++ b/js/src/jsreflect.cpp
@@ -490,18 +490,16 @@ class NodeBuilder
      */
 
     bool program(NodeVector &elts, TokenPos *pos, MutableHandleValue dst);
 
     bool literal(HandleValue val, TokenPos *pos, MutableHandleValue dst);
 
     bool identifier(HandleValue name, TokenPos *pos, MutableHandleValue dst);
 
-    bool module(TokenPos *pos, HandleValue name, HandleValue body, MutableHandleValue dst);
-
     bool function(ASTType type, TokenPos *pos,
                   HandleValue id, NodeVector &args, NodeVector &defaults,
                   HandleValue body, HandleValue rest, bool isGenerator, bool isExpression,
                   MutableHandleValue dst);
 
     bool variableDeclarator(HandleValue id, HandleValue init, TokenPos *pos,
                             MutableHandleValue dst);
 
@@ -1452,30 +1450,16 @@ NodeBuilder::objectPattern(NodeVector &e
 
 bool
 NodeBuilder::arrayPattern(NodeVector &elts, TokenPos *pos, MutableHandleValue dst)
 {
     return listNode(AST_ARRAY_PATT, "elements", elts, pos, dst);
 }
 
 bool
-NodeBuilder::module(TokenPos *pos, HandleValue name, HandleValue body, MutableHandleValue dst)
-{
-    RootedValue cb(cx, callbacks[AST_MODULE_DECL]);
-    if (!cb.isNull()) {
-        return callback(cb, name, body, pos, dst);
-    }
-
-    return newNode(AST_MODULE_DECL, pos,
-                   "name", name,
-                   "body", body,
-                   dst);
-}
-
-bool
 NodeBuilder::function(ASTType type, TokenPos *pos,
                       HandleValue id, NodeVector &args, NodeVector &defaults,
                       HandleValue body, HandleValue rest,
                       bool isGenerator, bool isExpression,
                       MutableHandleValue dst)
 {
     RootedValue array(cx), defarray(cx);
     if (!newArray(args, &array))
@@ -1581,21 +1565,20 @@ class ASTSerializer
     bool identifier(HandleAtom atom, TokenPos *pos, MutableHandleValue dst);
     bool identifier(ParseNode *pn, MutableHandleValue dst);
     bool literal(ParseNode *pn, MutableHandleValue dst);
 
     bool pattern(ParseNode *pn, VarDeclKind *pkind, MutableHandleValue dst);
     bool arrayPattern(ParseNode *pn, VarDeclKind *pkind, MutableHandleValue dst);
     bool objectPattern(ParseNode *pn, VarDeclKind *pkind, MutableHandleValue dst);
 
-    bool module(ParseNode *pn, MutableHandleValue dst);
     bool function(ParseNode *pn, ASTType type, MutableHandleValue dst);
     bool functionArgsAndBody(ParseNode *pn, NodeVector &args, NodeVector &defaults,
                              MutableHandleValue body, MutableHandleValue rest);
-    bool moduleOrFunctionBody(ParseNode *pn, TokenPos *pos, MutableHandleValue dst);
+    bool functionBody(ParseNode *pn, TokenPos *pos, MutableHandleValue dst);
 
     bool comprehensionBlock(ParseNode *pn, MutableHandleValue dst);
     bool comprehension(ParseNode *pn, MutableHandleValue dst);
     bool generatorExpression(ParseNode *pn, MutableHandleValue dst);
 
   public:
     ASTSerializer(JSContext *c, bool l, char const *src, uint32_t ln)
         : cx(c)
@@ -2040,19 +2023,16 @@ ASTSerializer::forIn(ParseNode *loop, Pa
         builder.forInStatement(var, expr, stmt, isForEach, &loop->pn_pos, dst);
 }
 
 bool
 ASTSerializer::statement(ParseNode *pn, MutableHandleValue dst)
 {
     JS_CHECK_RECURSION(cx, return false);
     switch (pn->getKind()) {
-      case PNK_MODULE:
-        return module(pn, dst);
-
       case PNK_FUNCTION:
       case PNK_VAR:
       case PNK_CONST:
         return declaration(pn, dst);
 
       case PNK_LET:
         return pn->isArity(PN_BINARY)
                ? let(pn, false, dst)
@@ -2832,25 +2812,16 @@ ASTSerializer::identifier(ParseNode *pn,
     LOCAL_ASSERT(pn->isArity(PN_NAME) || pn->isArity(PN_NULLARY));
     LOCAL_ASSERT(pn->pn_atom);
 
     RootedAtom pnAtom(cx, pn->pn_atom);
     return identifier(pnAtom, &pn->pn_pos, dst);
 }
 
 bool
-ASTSerializer::module(ParseNode *pn, MutableHandleValue dst)
-{
-    RootedValue name(cx, StringValue(pn->atom()));
-    RootedValue body(cx);
-    return moduleOrFunctionBody(pn->pn_body->pn_head, &pn->pn_body->pn_pos, &body) &&
-           builder.module(&pn->pn_pos, name, body, dst);
-}
-
-bool
 ASTSerializer::function(ParseNode *pn, ASTType type, MutableHandleValue dst)
 {
     RootedFunction func(cx, pn->pn_funbox->function());
 
     // FIXME: Provide more information (legacy generator vs star generator).
     bool isGenerator = pn->pn_funbox->isGenerator();
 
     bool isExpression =
@@ -2925,17 +2896,17 @@ ASTSerializer::functionArgsAndBody(Parse
 
       case PNK_STATEMENTLIST:     /* statement closure */
       {
         ParseNode *pnstart = (pnbody->pn_xflags & PNX_DESTRUCT)
                                ? pnbody->pn_head->pn_next
                                : pnbody->pn_head;
 
         return functionArgs(pn, pnargs, pndestruct, pnbody, args, defaults, rest) &&
-               moduleOrFunctionBody(pnstart, &pnbody->pn_pos, body);
+               functionBody(pnstart, &pnbody->pn_pos, body);
       }
 
       default:
         LOCAL_NOT_REACHED("unexpected function contents");
     }
 }
 
 bool
@@ -2994,17 +2965,17 @@ ASTSerializer::functionArgs(ParseNode *p
         ++i;
     }
     JS_ASSERT(!rest.isUndefined());
 
     return true;
 }
 
 bool
-ASTSerializer::moduleOrFunctionBody(ParseNode *pn, TokenPos *pos, MutableHandleValue dst)
+ASTSerializer::functionBody(ParseNode *pn, TokenPos *pos, MutableHandleValue dst)
 {
     NodeVector elts(cx);
 
     /* We aren't sure how many elements there are up front, so we'll check each append. */
     for (ParseNode *next = pn; next; next = next->pn_next) {
         RootedValue child(cx);
         if (!sourceElement(next, &child) || !elts.append(child))
             return false;
--- a/js/src/moz.build
+++ b/js/src/moz.build
@@ -91,17 +91,16 @@ EXPORTS.js += [
     '../public/Vector.h',
 ]
 
 SOURCES += [
     'assembler/jit/ExecutableAllocator.cpp',
     'builtin/Eval.cpp',
     'builtin/Intl.cpp',
     'builtin/MapObject.cpp',
-    'builtin/Module.cpp',
     'builtin/Object.cpp',
     'builtin/ParallelArray.cpp',
     'builtin/Profilers.cpp',
     'builtin/RegExp.cpp',
     'builtin/TestingFunctions.cpp',
     'builtin/TypedObject.cpp',
     'builtin/TypeRepresentation.cpp',
     'devtools/sharkctl.cpp',