| Differences between
and this patch
- a/Source/JavaScriptCore/ChangeLog +94 lines
Lines 1-3 a/Source/JavaScriptCore/ChangeLog_sec1
1
2016-12-27  Yusuke Suzuki  <utatane.tea@gmail.com>
2
3
        [JSC] Prototype dynamic-import
4
        https://bugs.webkit.org/show_bug.cgi?id=165724
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        In this patch, we implement stage3 dynamic-import proposal[1].
9
        This patch adds a new special operator `import`. And by using it, we can import
10
        the module dynamically from modules and scripts. Before this feature, the module
11
        is always imported statically and before executing the modules, importing the modules
12
        needs to be done. And especially, the module can only be imported from the module.
13
        So the classic script cannot import and use the modules. This dynamic-import relaxes
14
        the above restrictions.
15
16
        The typical dynamic-import form is the following.
17
18
            import("...").then(function (namespace) { ... });
19
20
        You can pass any AssignmentExpression for the import operator. So you can determine
21
        the importing modules dynamically.
22
23
            import(value).then(function (namespace) { ... });
24
25
        And previously the module import declaration is only allowed in the top level statements.
26
        But this import operator is just an expression. So you can use it in the function.
27
        And you can use it conditionally.
28
29
            async function go(cond)
30
            {
31
                if (cond)
32
                    return import("...");
33
                return undefined;
34
            }
35
            await go(true);
36
37
        Currently, this patch just implements this feature only for the JSC shell.
38
        JSC module loader requires a new hook, `importModule`. And the JSC shell implements
39
        this hook. So, for now, this dynamic-import is not available in the browser side.
40
        If you write this `import` call, it always returns the rejected promise.
41
42
        import is implemented like a special operator similar to `super`.
43
        This is because import is context-sensitive. If you call the `import`, the module
44
        key resolution is done based on the caller's running context.
45
46
        For example, if you are running the script which filename is "./ok/hello.js", the module
47
        key for the call`import("./resource/syntax.js")` becomes `"./ok/resource/syntax.js"`.
48
        But if you write the completely same import form in the script "./error/hello.js", the
49
        key becomes "./error/resource/syntax.js". So exposing this feature as the `import`
50
        function is misleading: this function becomes caller's context-sensitive. That's why
51
        dynamic-import is specified as a special operator.
52
53
        To resolve the module key, we need the caller's context information like the filename of
54
        the caller. This is provided by the SourceOrigin implemented in r210149.
55
        In the JSC shell implementation, this SourceOrigin holds the filename of the caller. So
56
        based on this implementation, the module loader resolve the module key.
57
        In the near future, we will extend this SourceOrigin to hold more information needed for
58
        the browser-side import implementation.
59
60
        [1]: https://tc39.github.io/proposal-dynamic-import/
61
62
        * builtins/ModuleLoaderPrototype.js:
63
        (importModule):
64
        * bytecompiler/BytecodeGenerator.cpp:
65
        (JSC::BytecodeGenerator::emitGetTemplateObject):
66
        (JSC::BytecodeGenerator::emitGetGlobalPrivate):
67
        * bytecompiler/BytecodeGenerator.h:
68
        * bytecompiler/NodesCodegen.cpp:
69
        (JSC::ImportNode::emitBytecode):
70
        * jsc.cpp:
71
        (GlobalObject::moduleLoaderImportModule):
72
        * parser/ASTBuilder.h:
73
        (JSC::ASTBuilder::createImportExpr):
74
        * parser/NodeConstructors.h:
75
        (JSC::ImportNode::ImportNode):
76
        * parser/Nodes.h:
77
        (JSC::ExpressionNode::isImportNode):
78
        * parser/Parser.cpp:
79
        (JSC::Parser<LexerType>::parseMemberExpression):
80
        * parser/SyntaxChecker.h:
81
        (JSC::SyntaxChecker::createImportExpr):
82
        * runtime/JSGlobalObject.cpp:
83
        (JSC::JSGlobalObject::init):
84
        * runtime/JSGlobalObject.h:
85
        * runtime/JSGlobalObjectFunctions.cpp:
86
        (JSC::globalFuncImportModule):
87
        * runtime/JSGlobalObjectFunctions.h:
88
        * runtime/JSModuleLoader.cpp:
89
        (JSC::JSModuleLoader::importModule):
90
        (JSC::JSModuleLoader::getModuleNamespaceObject):
91
        * runtime/JSModuleLoader.h:
92
        * runtime/ModuleLoaderPrototype.cpp:
93
        (JSC::moduleLoaderPrototypeGetModuleNamespaceObject):
94
1
2016-12-26  Yusuke Suzuki  <utatane.tea@gmail.com>
95
2016-12-26  Yusuke Suzuki  <utatane.tea@gmail.com>
2
96
3
        Use variadic templates in JSC Parser to clean up
97
        Use variadic templates in JSC Parser to clean up
- a/Source/WebCore/ChangeLog +13 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2016-12-27  Yusuke Suzuki  <utatane.tea@gmail.com>
2
3
        [JSC] Prototype dynamic-import
4
        https://bugs.webkit.org/show_bug.cgi?id=165724
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        We do not set a handler for import for now.
9
        So dynamic import feature is only enabled in the JSC shell right now.
10
11
        * bindings/js/JSDOMWindowBase.cpp:
12
        * bindings/js/JSWorkerGlobalScopeBase.cpp:
13
1
2016-12-26  Zalan Bujtas  <zalan@apple.com>
14
2016-12-26  Zalan Bujtas  <zalan@apple.com>
2
15
3
        ASSERTION FAILED: !rect.isEmpty() in WebCore::GraphicsContext::drawRect
16
        ASSERTION FAILED: !rect.isEmpty() in WebCore::GraphicsContext::drawRect
- a/Source/JavaScriptCore/builtins/ModuleLoaderPrototype.js +16 lines
Lines 470-472 function linkAndEvaluateModule(key, initiator) a/Source/JavaScriptCore/builtins/ModuleLoaderPrototype.js_sec1
470
    this.link(entry, initiator);
470
    this.link(entry, initiator);
471
    return this.moduleEvaluation(entry.module, initiator);
471
    return this.moduleEvaluation(entry.module, initiator);
472
}
472
}
473
474
function importModule(moduleName, referrer, initiator)
475
{
476
    "use strict";
477
478
    // Loader.resolve hook point.
479
    // resolve: moduleName => Promise(moduleKey)
480
    // Take the name and resolve it to the unique identifier for the resource location.
481
    // For example, take the "jquery" and return the URL for the resource.
482
    return this.resolve(moduleName, referrer, initiator).then((key) => {
483
        return this.requestInstantiateAll(key, initiator);
484
    }).then((entry) => {
485
        this.linkAndEvaluateModule(entry.key, initiator);
486
        return this.getModuleNamespaceObject(entry.module);
487
    });
488
}
- a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp -11 / +13 lines
Lines 4261-4282 RegisterID* BytecodeGenerator::emitGetTemplateObject(RegisterID* dst, TaggedTemp a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp_sec1
4261
        cookedStrings.append(templateString->value()->cooked().impl());
4261
        cookedStrings.append(templateString->value()->cooked().impl());
4262
    }
4262
    }
4263
4263
4264
    RefPtr<RegisterID> getTemplateObject = nullptr;
4264
    RefPtr<RegisterID> getTemplateObject = emitGetGlobalPrivate(newTemporary(), propertyNames().builtinNames().getTemplateObjectPrivateName());
4265
    Variable var = variable(propertyNames().builtinNames().getTemplateObjectPrivateName());
4266
    if (RegisterID* local = var.local())
4267
        getTemplateObject = emitMove(newTemporary(), local);
4268
    else {
4269
        getTemplateObject = newTemporary();
4270
        RefPtr<RegisterID> scope = newTemporary();
4271
        moveToDestinationIfNeeded(scope.get(), emitResolveScope(scope.get(), var));
4272
        emitGetFromScope(getTemplateObject.get(), scope.get(), var, ThrowIfNotFound);
4273
    }
4274
4275
    CallArguments arguments(*this, nullptr);
4265
    CallArguments arguments(*this, nullptr);
4276
    emitLoad(arguments.thisRegister(), JSValue(addTemplateRegistryKeyConstant(m_vm->templateRegistryKeyTable().createKey(rawStrings, cookedStrings))));
4266
    emitLoad(arguments.thisRegister(), JSValue(addTemplateRegistryKeyConstant(m_vm->templateRegistryKeyTable().createKey(rawStrings, cookedStrings))));
4277
    return emitCall(dst, getTemplateObject.get(), NoExpectedFunction, arguments, taggedTemplate->divot(), taggedTemplate->divotStart(), taggedTemplate->divotEnd(), DebuggableCall::No);
4267
    return emitCall(dst, getTemplateObject.get(), NoExpectedFunction, arguments, taggedTemplate->divot(), taggedTemplate->divotStart(), taggedTemplate->divotEnd(), DebuggableCall::No);
4278
}
4268
}
4279
4269
4270
RegisterID* BytecodeGenerator::emitGetGlobalPrivate(RegisterID* dst, const Identifier& property)
4271
{
4272
    dst = tempDestination(dst);
4273
    Variable var = variable(property);
4274
    if (RegisterID* local = var.local())
4275
        return emitMove(dst, local);
4276
4277
    RefPtr<RegisterID> scope = newTemporary();
4278
    moveToDestinationIfNeeded(scope.get(), emitResolveScope(scope.get(), var));
4279
    return emitGetFromScope(dst, scope.get(), var, ThrowIfNotFound);
4280
}
4281
4280
RegisterID* BytecodeGenerator::emitGetEnumerableLength(RegisterID* dst, RegisterID* base)
4282
RegisterID* BytecodeGenerator::emitGetEnumerableLength(RegisterID* dst, RegisterID* base)
4281
{
4283
{
4282
    emitOpcode(op_get_enumerable_length);
4284
    emitOpcode(op_get_enumerable_length);
- a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h +1 lines
Lines 678-683 namespace JSC { a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h_sec1
678
        void emitEnumeration(ThrowableExpressionData* enumerationNode, ExpressionNode* subjectNode, const std::function<void(BytecodeGenerator&, RegisterID*)>& callBack, ForOfNode* = nullptr, RegisterID* forLoopSymbolTable = nullptr);
678
        void emitEnumeration(ThrowableExpressionData* enumerationNode, ExpressionNode* subjectNode, const std::function<void(BytecodeGenerator&, RegisterID*)>& callBack, ForOfNode* = nullptr, RegisterID* forLoopSymbolTable = nullptr);
679
679
680
        RegisterID* emitGetTemplateObject(RegisterID* dst, TaggedTemplateNode*);
680
        RegisterID* emitGetTemplateObject(RegisterID* dst, TaggedTemplateNode*);
681
        RegisterID* emitGetGlobalPrivate(RegisterID* dst, const Identifier& property);
681
682
682
        enum class ReturnFrom { Normal, Finally };
683
        enum class ReturnFrom { Normal, Finally };
683
        RegisterID* emitReturn(RegisterID* src, ReturnFrom = ReturnFrom::Normal);
684
        RegisterID* emitReturn(RegisterID* src, ReturnFrom = ReturnFrom::Normal);
- a/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp +11 lines
Lines 190-195 RegisterID* SuperNode::emitBytecode(BytecodeGenerator& generator, RegisterID* ds a/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp_sec1
190
    return generator.moveToDestinationIfNeeded(generator.finalDestination(dst), result);
190
    return generator.moveToDestinationIfNeeded(generator.finalDestination(dst), result);
191
}
191
}
192
192
193
// ------------------------------ ImportNode -------------------------------------
194
195
RegisterID* ImportNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
196
{
197
    RefPtr<RegisterID> importModule = generator.emitGetGlobalPrivate(generator.newTemporary(), generator.propertyNames().builtinNames().importModulePrivateName());
198
    CallArguments arguments(generator, nullptr, 1);
199
    generator.emitLoad(arguments.thisRegister(), jsUndefined());
200
    generator.emitNode(arguments.argumentRegister(0), m_expr);
201
    return generator.emitCall(generator.finalDestination(dst, importModule.get()), importModule.get(), NoExpectedFunction, arguments, divot(), divotStart(), divotEnd(), DebuggableCall::No);
202
}
203
193
// ------------------------------ NewTargetNode ----------------------------------
204
// ------------------------------ NewTargetNode ----------------------------------
194
205
195
RegisterID* NewTargetNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
206
RegisterID* NewTargetNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
- a/Source/JavaScriptCore/jsc.cpp +19 lines
Lines 25-30 a/Source/JavaScriptCore/jsc.cpp_sec1
25
#include "ArrayBuffer.h"
25
#include "ArrayBuffer.h"
26
#include "ArrayPrototype.h"
26
#include "ArrayPrototype.h"
27
#include "BuiltinExecutableCreator.h"
27
#include "BuiltinExecutableCreator.h"
28
#include "BuiltinNames.h"
28
#include "ButterflyInlines.h"
29
#include "ButterflyInlines.h"
29
#include "CodeBlock.h"
30
#include "CodeBlock.h"
30
#include "Completion.h"
31
#include "Completion.h"
Lines 48-53 a/Source/JavaScriptCore/jsc.cpp_sec2
48
#include "JSInternalPromise.h"
49
#include "JSInternalPromise.h"
49
#include "JSInternalPromiseDeferred.h"
50
#include "JSInternalPromiseDeferred.h"
50
#include "JSLock.h"
51
#include "JSLock.h"
52
#include "JSModuleLoader.h"
51
#include "JSNativeStdFunction.h"
53
#include "JSNativeStdFunction.h"
52
#include "JSONObject.h"
54
#include "JSONObject.h"
53
#include "JSProxy.h"
55
#include "JSProxy.h"
Lines 1277-1282 class GlobalObject : public JSGlobalObject { a/Source/JavaScriptCore/jsc.cpp_sec3
1277
        putDirect(vm, identifier, JSFunction::create(vm, this, arguments, identifier.string(), function, NoIntrinsic, function));
1279
        putDirect(vm, identifier, JSFunction::create(vm, this, arguments, identifier.string(), function, NoIntrinsic, function));
1278
    }
1280
    }
1279
1281
1282
    static JSInternalPromise* moduleLoaderImportModule(JSGlobalObject*, ExecState*, JSModuleLoader*, JSString*, const SourceOrigin&);
1280
    static JSInternalPromise* moduleLoaderResolve(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSValue, JSValue);
1283
    static JSInternalPromise* moduleLoaderResolve(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSValue, JSValue);
1281
    static JSInternalPromise* moduleLoaderFetch(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSValue);
1284
    static JSInternalPromise* moduleLoaderFetch(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSValue);
1282
};
1285
};
Lines 1288-1293 const GlobalObjectMethodTable GlobalObject::s_globalObjectMethodTable = { a/Source/JavaScriptCore/jsc.cpp_sec4
1288
    &javaScriptRuntimeFlags,
1291
    &javaScriptRuntimeFlags,
1289
    nullptr,
1292
    nullptr,
1290
    &shouldInterruptScriptBeforeTimeout,
1293
    &shouldInterruptScriptBeforeTimeout,
1294
    &moduleLoaderImportModule,
1291
    &moduleLoaderResolve,
1295
    &moduleLoaderResolve,
1292
    &moduleLoaderFetch,
1296
    &moduleLoaderFetch,
1293
    nullptr,
1297
    nullptr,
Lines 1420-1425 static String resolvePath(const DirectoryName& directoryName, const ModuleName& a/Source/JavaScriptCore/jsc.cpp_sec5
1420
    return builder.toString();
1424
    return builder.toString();
1421
}
1425
}
1422
1426
1427
JSInternalPromise* GlobalObject::moduleLoaderImportModule(JSGlobalObject*, ExecState* exec, JSModuleLoader* moduleLoader, JSString* moduleName, const SourceOrigin& sourceOrigin)
1428
{
1429
    auto* function = jsCast<JSObject*>(moduleLoader->get(exec, exec->propertyNames().builtinNames().importModulePublicName()));
1430
    CallData callData;
1431
    CallType callType = JSC::getCallData(function, callData);
1432
    ASSERT(callType != CallType::None);
1433
1434
    MarkedArgumentBuffer arguments;
1435
    arguments.append(moduleName);
1436
    arguments.append(jsString(exec, sourceOrigin.string()));
1437
    arguments.append(jsUndefined());
1438
1439
    return jsCast<JSInternalPromise*>(call(exec, function, callType, callData, moduleLoader, arguments));
1440
}
1441
1423
JSInternalPromise* GlobalObject::moduleLoaderResolve(JSGlobalObject* globalObject, ExecState* exec, JSModuleLoader*, JSValue keyValue, JSValue referrerValue, JSValue)
1442
JSInternalPromise* GlobalObject::moduleLoaderResolve(JSGlobalObject* globalObject, ExecState* exec, JSModuleLoader*, JSValue keyValue, JSValue referrerValue, JSValue)
1424
{
1443
{
1425
    VM& vm = globalObject->vm();
1444
    VM& vm = globalObject->vm();
- a/Source/JavaScriptCore/parser/ASTBuilder.h +6 lines
Lines 178-183 class ASTBuilder { a/Source/JavaScriptCore/parser/ASTBuilder.h_sec1
178
    {
178
    {
179
        return new (m_parserArena) SuperNode(location);
179
        return new (m_parserArena) SuperNode(location);
180
    }
180
    }
181
    ExpressionNode* createImportExpr(const JSTokenLocation& location, ExpressionNode* expr, const JSTextPosition& start, const JSTextPosition& divot, const JSTextPosition& end)
182
    {
183
        auto* node = new (m_parserArena) ImportNode(location, expr);
184
        setExceptionLocation(node, start, divot, end);
185
        return node;
186
    }
181
    ExpressionNode* createNewTargetExpr(const JSTokenLocation location)
187
    ExpressionNode* createNewTargetExpr(const JSTokenLocation location)
182
    {
188
    {
183
        usesNewTarget();
189
        usesNewTarget();
- a/Source/JavaScriptCore/parser/NodeConstructors.h +6 lines
Lines 167-172 namespace JSC { a/Source/JavaScriptCore/parser/NodeConstructors.h_sec1
167
    {
167
    {
168
    }
168
    }
169
169
170
    inline ImportNode::ImportNode(const JSTokenLocation& location, ExpressionNode* expr)
171
        : ExpressionNode(location)
172
        , m_expr(expr)
173
    {
174
    }
175
170
    inline NewTargetNode::NewTargetNode(const JSTokenLocation& location)
176
    inline NewTargetNode::NewTargetNode(const JSTokenLocation& location)
171
        : ExpressionNode(location)
177
        : ExpressionNode(location)
172
    {
178
    {
- a/Source/JavaScriptCore/parser/Nodes.h +12 lines
Lines 186-191 namespace JSC { a/Source/JavaScriptCore/parser/Nodes.h_sec1
186
        virtual bool isBoolean() const { return false; }
186
        virtual bool isBoolean() const { return false; }
187
        virtual bool isSpreadExpression() const { return false; }
187
        virtual bool isSpreadExpression() const { return false; }
188
        virtual bool isSuperNode() const { return false; }
188
        virtual bool isSuperNode() const { return false; }
189
        virtual bool isImportNode() const { return false; }
189
        virtual bool isNewTarget() const { return false; }
190
        virtual bool isNewTarget() const { return false; }
190
        virtual bool isBytecodeIntrinsicNode() const { return false; }
191
        virtual bool isBytecodeIntrinsicNode() const { return false; }
191
192
Lines 570-575 namespace JSC { a/Source/JavaScriptCore/parser/Nodes.h_sec2
570
        RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override;
571
        RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override;
571
    };
572
    };
572
573
574
    class ImportNode : public ExpressionNode, public ThrowableExpressionData {
575
    public:
576
        ImportNode(const JSTokenLocation&, ExpressionNode*);
577
578
    private:
579
        bool isImportNode() const override { return true; }
580
        RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override;
581
582
        ExpressionNode* m_expr;
583
    };
584
573
    class NewTargetNode final : public ExpressionNode {
585
    class NewTargetNode final : public ExpressionNode {
574
    public:
586
    public:
575
        NewTargetNode(const JSTokenLocation&);
587
        NewTargetNode(const JSTokenLocation&);
- a/Source/JavaScriptCore/parser/Parser.cpp -1 / +9 lines
Lines 4343-4349 template <class TreeBuilder> TreeExpression Parser<LexerType>::parseMemberExpres a/Source/JavaScriptCore/parser/Parser.cpp_sec1
4343
    }
4343
    }
4344
4344
4345
    bool baseIsSuper = match(SUPER);
4345
    bool baseIsSuper = match(SUPER);
4346
    semanticFailIfTrue(baseIsSuper && newCount, "Cannot use new with super");
4346
    bool baseIsImport = match(IMPORT);
4347
    semanticFailIfTrue((baseIsSuper || baseIsImport) && newCount, "Cannot use new with ", getToken());
4347
4348
4348
    bool baseIsNewTarget = false;
4349
    bool baseIsNewTarget = false;
4349
    if (newCount && match(DOT)) {
4350
    if (newCount && match(DOT)) {
Lines 4383-4388 template <class TreeBuilder> TreeExpression Parser<LexerType>::parseMemberExpres a/Source/JavaScriptCore/parser/Parser.cpp_sec2
4383
                semanticFailIfTrue(functionSuperBinding == SuperBinding::NotNeeded, "super is not valid in this context");
4384
                semanticFailIfTrue(functionSuperBinding == SuperBinding::NotNeeded, "super is not valid in this context");
4384
            }
4385
            }
4385
        }
4386
        }
4387
    } else if (baseIsImport) {
4388
        JSTextPosition expressionEnd = lastTokenEndPosition();
4389
        next();
4390
        handleProductionOrFail2(OPENPAREN, "(", "start", "'import' call");
4391
        TreeExpression expr = parseAssignmentExpression(context);
4392
        handleProductionOrFail2(CLOSEPAREN, ")", "end", "'import' call");
4393
        return context.createImportExpr(location, expr, expressionStart, expressionEnd, lastTokenEndPosition());
4386
    } else if (!baseIsNewTarget) {
4394
    } else if (!baseIsNewTarget) {
4387
        const bool isAsync = match(ASYNC);
4395
        const bool isAsync = match(ASYNC);
4388
4396
- a/Source/JavaScriptCore/parser/SyntaxChecker.h -1 / +2 lines
Lines 71-77 class SyntaxChecker { a/Source/JavaScriptCore/parser/SyntaxChecker.h_sec1
71
    enum { NoneExpr = 0,
71
    enum { NoneExpr = 0,
72
        ResolveEvalExpr, ResolveExpr, IntegerExpr, DoubleExpr, StringExpr,
72
        ResolveEvalExpr, ResolveExpr, IntegerExpr, DoubleExpr, StringExpr,
73
        ThisExpr, NullExpr, BoolExpr, RegExpExpr, ObjectLiteralExpr,
73
        ThisExpr, NullExpr, BoolExpr, RegExpExpr, ObjectLiteralExpr,
74
        FunctionExpr, ClassExpr, SuperExpr, BracketExpr, DotExpr, CallExpr,
74
        FunctionExpr, ClassExpr, SuperExpr, ImportExpr, BracketExpr, DotExpr, CallExpr,
75
        NewExpr, PreExpr, PostExpr, UnaryExpr, BinaryExpr,
75
        NewExpr, PreExpr, PostExpr, UnaryExpr, BinaryExpr,
76
        ConditionalExpr, AssignmentExpr, TypeofExpr, NewTargetExpr,
76
        ConditionalExpr, AssignmentExpr, TypeofExpr, NewTargetExpr,
77
        DeleteExpr, ArrayLiteralExpr, BindingDestructuring, RestParameter,
77
        DeleteExpr, ArrayLiteralExpr, BindingDestructuring, RestParameter,
Lines 156-161 class SyntaxChecker { a/Source/JavaScriptCore/parser/SyntaxChecker.h_sec2
156
    ExpressionType createLogicalNot(const JSTokenLocation&, ExpressionType) { return UnaryExpr; }
156
    ExpressionType createLogicalNot(const JSTokenLocation&, ExpressionType) { return UnaryExpr; }
157
    ExpressionType createUnaryPlus(const JSTokenLocation&, ExpressionType) { return UnaryExpr; }
157
    ExpressionType createUnaryPlus(const JSTokenLocation&, ExpressionType) { return UnaryExpr; }
158
    ExpressionType createVoid(const JSTokenLocation&, ExpressionType) { return UnaryExpr; }
158
    ExpressionType createVoid(const JSTokenLocation&, ExpressionType) { return UnaryExpr; }
159
    ExpressionType createImportExpr(const JSTokenLocation&, ExpressionType, int, int, int) { return ImportExpr; }
159
    ExpressionType createThisExpr(const JSTokenLocation&) { return ThisExpr; }
160
    ExpressionType createThisExpr(const JSTokenLocation&) { return ThisExpr; }
160
    ExpressionType createSuperExpr(const JSTokenLocation&) { return SuperExpr; }
161
    ExpressionType createSuperExpr(const JSTokenLocation&) { return SuperExpr; }
161
    ExpressionType createNewTargetExpr(const JSTokenLocation&) { return NewTargetExpr; }
162
    ExpressionType createNewTargetExpr(const JSTokenLocation&) { return NewTargetExpr; }
- a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp +3 lines
Lines 256-261 const GlobalObjectMethodTable JSGlobalObject::s_globalObjectMethodTable = { a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp_sec1
256
    nullptr,
256
    nullptr,
257
    nullptr,
257
    nullptr,
258
    nullptr,
258
    nullptr,
259
    nullptr,
259
    nullptr
260
    nullptr
260
};
261
};
261
262
Lines 732-737 putDirectWithoutTransition(vm, vm.propertyNames-> jsName, lowerName ## Construct a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp_sec2
732
    JSFunction* privateFuncTrunc = JSFunction::create(vm, this, 0, String(), mathProtoFuncTrunc, TruncIntrinsic);
733
    JSFunction* privateFuncTrunc = JSFunction::create(vm, this, 0, String(), mathProtoFuncTrunc, TruncIntrinsic);
733
734
734
    JSFunction* privateFuncGetTemplateObject = JSFunction::create(vm, this, 0, String(), getTemplateObject);
735
    JSFunction* privateFuncGetTemplateObject = JSFunction::create(vm, this, 0, String(), getTemplateObject);
736
    JSFunction* privateFuncImportModule = JSFunction::create(vm, this, 0, String(), globalFuncImportModule);
735
    JSFunction* privateFuncTypedArrayLength = JSFunction::create(vm, this, 0, String(), typedArrayViewPrivateFuncLength);
737
    JSFunction* privateFuncTypedArrayLength = JSFunction::create(vm, this, 0, String(), typedArrayViewPrivateFuncLength);
736
    JSFunction* privateFuncTypedArrayGetOriginalConstructor = JSFunction::create(vm, this, 0, String(), typedArrayViewPrivateFuncGetOriginalConstructor);
738
    JSFunction* privateFuncTypedArrayGetOriginalConstructor = JSFunction::create(vm, this, 0, String(), typedArrayViewPrivateFuncGetOriginalConstructor);
737
    JSFunction* privateFuncTypedArraySort = JSFunction::create(vm, this, 0, String(), typedArrayViewPrivateFuncSort);
739
    JSFunction* privateFuncTypedArraySort = JSFunction::create(vm, this, 0, String(), typedArrayViewPrivateFuncSort);
Lines 785-790 putDirectWithoutTransition(vm, vm.propertyNames-> jsName, lowerName ## Construct a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp_sec3
785
        GlobalPropertyInfo(vm.propertyNames->undefinedKeyword, jsUndefined(), DontEnum | DontDelete | ReadOnly),
787
        GlobalPropertyInfo(vm.propertyNames->undefinedKeyword, jsUndefined(), DontEnum | DontDelete | ReadOnly),
786
        GlobalPropertyInfo(vm.propertyNames->builtinNames().ownEnumerablePropertyKeysPrivateName(), JSFunction::create(vm, this, 0, String(), ownEnumerablePropertyKeys), DontEnum | DontDelete | ReadOnly),
788
        GlobalPropertyInfo(vm.propertyNames->builtinNames().ownEnumerablePropertyKeysPrivateName(), JSFunction::create(vm, this, 0, String(), ownEnumerablePropertyKeys), DontEnum | DontDelete | ReadOnly),
787
        GlobalPropertyInfo(vm.propertyNames->builtinNames().getTemplateObjectPrivateName(), privateFuncGetTemplateObject, DontEnum | DontDelete | ReadOnly),
789
        GlobalPropertyInfo(vm.propertyNames->builtinNames().getTemplateObjectPrivateName(), privateFuncGetTemplateObject, DontEnum | DontDelete | ReadOnly),
790
        GlobalPropertyInfo(vm.propertyNames->builtinNames().importModulePrivateName(), privateFuncImportModule, DontEnum | DontDelete | ReadOnly),
788
        GlobalPropertyInfo(vm.propertyNames->builtinNames().enqueueJobPrivateName(), JSFunction::create(vm, this, 0, String(), enqueueJob), DontEnum | DontDelete | ReadOnly),
791
        GlobalPropertyInfo(vm.propertyNames->builtinNames().enqueueJobPrivateName(), JSFunction::create(vm, this, 0, String(), enqueueJob), DontEnum | DontDelete | ReadOnly),
789
        GlobalPropertyInfo(vm.propertyNames->builtinNames().ErrorPrivateName(), m_errorConstructor.get(), DontEnum | DontDelete | ReadOnly),
792
        GlobalPropertyInfo(vm.propertyNames->builtinNames().ErrorPrivateName(), m_errorConstructor.get(), DontEnum | DontDelete | ReadOnly),
790
        GlobalPropertyInfo(vm.propertyNames->builtinNames().RangeErrorPrivateName(), m_rangeErrorConstructor.get(), DontEnum | DontDelete | ReadOnly),
793
        GlobalPropertyInfo(vm.propertyNames->builtinNames().RangeErrorPrivateName(), m_rangeErrorConstructor.get(), DontEnum | DontDelete | ReadOnly),
- a/Source/JavaScriptCore/runtime/JSGlobalObject.h +3 lines
Lines 184-189 struct GlobalObjectMethodTable { a/Source/JavaScriptCore/runtime/JSGlobalObject.h_sec1
184
    typedef bool (*ShouldInterruptScriptBeforeTimeoutPtr)(const JSGlobalObject*);
184
    typedef bool (*ShouldInterruptScriptBeforeTimeoutPtr)(const JSGlobalObject*);
185
    ShouldInterruptScriptBeforeTimeoutPtr shouldInterruptScriptBeforeTimeout;
185
    ShouldInterruptScriptBeforeTimeoutPtr shouldInterruptScriptBeforeTimeout;
186
186
187
    typedef JSInternalPromise* (*ModuleLoaderImportModulePtr)(JSGlobalObject*, ExecState*, JSModuleLoader*, JSString*, const SourceOrigin&);
188
    ModuleLoaderImportModulePtr moduleLoaderImportModule;
189
187
    typedef JSInternalPromise* (*ModuleLoaderResolvePtr)(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSValue, JSValue);
190
    typedef JSInternalPromise* (*ModuleLoaderResolvePtr)(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSValue, JSValue);
188
    ModuleLoaderResolvePtr moduleLoaderResolve;
191
    ModuleLoaderResolvePtr moduleLoaderResolve;
189
192
- a/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp +38 lines
Lines 27-36 a/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp_sec1
27
27
28
#include "CallFrame.h"
28
#include "CallFrame.h"
29
#include "EvalExecutable.h"
29
#include "EvalExecutable.h"
30
#include "Exception.h"
30
#include "IndirectEvalExecutable.h"
31
#include "IndirectEvalExecutable.h"
31
#include "Interpreter.h"
32
#include "Interpreter.h"
32
#include "JSFunction.h"
33
#include "JSFunction.h"
33
#include "JSGlobalObject.h"
34
#include "JSGlobalObject.h"
35
#include "JSInternalPromise.h"
36
#include "JSModuleLoader.h"
37
#include "JSPromiseDeferred.h"
34
#include "JSString.h"
38
#include "JSString.h"
35
#include "JSStringBuilder.h"
39
#include "JSStringBuilder.h"
36
#include "Lexer.h"
40
#include "Lexer.h"
Lines 925-928 EncodedJSValue JSC_HOST_CALL globalFuncBuiltinLog(ExecState* exec) a/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp_sec2
925
    return JSValue::encode(jsUndefined());
929
    return JSValue::encode(jsUndefined());
926
}
930
}
927
931
932
EncodedJSValue JSC_HOST_CALL globalFuncImportModule(ExecState* exec)
933
{
934
    VM& vm = exec->vm();
935
    auto catchScope = DECLARE_CATCH_SCOPE(vm);
936
937
    auto* globalObject = exec->lexicalGlobalObject();
938
939
    auto* promise = JSPromiseDeferred::create(exec, globalObject);
940
    RETURN_IF_EXCEPTION(catchScope, encodedJSValue());
941
942
    auto sourceOrigin = exec->callerSourceOrigin();
943
    if (sourceOrigin.isNull()) {
944
        promise->reject(exec, createError(exec, ASCIILiteral("Could not resolve the module specifier.")));
945
        return JSValue::encode(promise->promise());
946
    }
947
948
    auto* specifier = exec->argument(0).toString(exec);
949
    if (Exception* exception = catchScope.exception()) {
950
        catchScope.clearException();
951
        promise->reject(exec, exception);
952
        return JSValue::encode(promise->promise());
953
    }
954
955
    auto* internalPromise = globalObject->moduleLoader()->importModule(exec, specifier, sourceOrigin);
956
    if (Exception* exception = catchScope.exception()) {
957
        catchScope.clearException();
958
        promise->reject(exec, exception);
959
        return JSValue::encode(promise->promise());
960
    }
961
    promise->resolve(exec, internalPromise);
962
963
    return JSValue::encode(promise->promise());
964
}
965
928
} // namespace JSC
966
} // namespace JSC
- a/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.h +1 lines
Lines 50-55 EncodedJSValue JSC_HOST_CALL globalFuncThrowTypeErrorArgumentsCalleeAndCaller(Ex a/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.h_sec1
50
EncodedJSValue JSC_HOST_CALL globalFuncProtoGetter(ExecState*);
50
EncodedJSValue JSC_HOST_CALL globalFuncProtoGetter(ExecState*);
51
EncodedJSValue JSC_HOST_CALL globalFuncProtoSetter(ExecState*);
51
EncodedJSValue JSC_HOST_CALL globalFuncProtoSetter(ExecState*);
52
EncodedJSValue JSC_HOST_CALL globalFuncBuiltinLog(ExecState*);
52
EncodedJSValue JSC_HOST_CALL globalFuncBuiltinLog(ExecState*);
53
EncodedJSValue JSC_HOST_CALL globalFuncImportModule(ExecState*);
53
54
54
static const double mantissaOverflowLowerBound = 9007199254740992.0;
55
static const double mantissaOverflowLowerBound = 9007199254740992.0;
55
double parseIntOverflow(const LChar*, unsigned length, int radix);
56
double parseIntOverflow(const LChar*, unsigned length, int radix);
- a/Source/JavaScriptCore/runtime/JSModuleLoader.cpp +39 lines
Lines 134-139 JSValue JSModuleLoader::linkAndEvaluateModule(ExecState* exec, JSValue moduleKey a/Source/JavaScriptCore/runtime/JSModuleLoader.cpp_sec1
134
    return call(exec, function, callType, callData, this, arguments);
134
    return call(exec, function, callType, callData, this, arguments);
135
}
135
}
136
136
137
JSInternalPromise* JSModuleLoader::importModule(ExecState* exec, JSString* moduleName, const SourceOrigin& referrer)
138
{
139
    if (Options::dumpModuleLoadingState())
140
        dataLog("Loader [import] ", printableModuleKey(exec, moduleName), "\n");
141
142
    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
143
    VM& vm = globalObject->vm();
144
    auto scope = DECLARE_CATCH_SCOPE(vm);
145
146
    if (globalObject->globalObjectMethodTable()->moduleLoaderImportModule)
147
        return globalObject->globalObjectMethodTable()->moduleLoaderImportModule(globalObject, exec, this, moduleName, referrer);
148
149
    JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
150
    auto moduleNameString = moduleName->value(exec);
151
    if (UNLIKELY(scope.exception())) {
152
        JSValue exception = scope.exception()->value();
153
        scope.clearException();
154
        deferred->reject(exec, exception);
155
        return deferred->promise();
156
    }
157
    deferred->reject(exec, createError(exec, makeString("Could not import the module '", moduleNameString, "'.")));
158
    return deferred->promise();
159
}
160
137
JSInternalPromise* JSModuleLoader::resolve(ExecState* exec, JSValue name, JSValue referrer, JSValue initiator)
161
JSInternalPromise* JSModuleLoader::resolve(ExecState* exec, JSValue name, JSValue referrer, JSValue initiator)
138
{
162
{
139
    if (Options::dumpModuleLoadingState())
163
    if (Options::dumpModuleLoadingState())
Lines 197-200 JSValue JSModuleLoader::evaluate(ExecState* exec, JSValue key, JSValue moduleRec a/Source/JavaScriptCore/runtime/JSModuleLoader.cpp_sec2
197
    return moduleRecord->evaluate(exec);
221
    return moduleRecord->evaluate(exec);
198
}
222
}
199
223
224
JSModuleNamespaceObject* JSModuleLoader::getModuleNamespaceObject(ExecState* exec, JSValue moduleRecordValue)
225
{
226
    VM& vm = exec->vm();
227
    auto scope = DECLARE_THROW_SCOPE(vm);
228
229
    auto* moduleRecord = jsDynamicCast<AbstractModuleRecord*>(moduleRecordValue);
230
    if (!moduleRecord) {
231
        throwTypeError(exec, scope);
232
        return nullptr;
233
    }
234
235
    scope.release();
236
    return moduleRecord->getModuleNamespace(exec);
237
}
238
200
} // namespace JSC
239
} // namespace JSC
- a/Source/JavaScriptCore/runtime/JSModuleLoader.h +5 lines
Lines 31-36 a/Source/JavaScriptCore/runtime/JSModuleLoader.h_sec1
31
namespace JSC {
31
namespace JSC {
32
32
33
class JSInternalPromise;
33
class JSInternalPromise;
34
class JSModuleNamespaceObject;
34
35
35
class JSModuleLoader : public JSNonFinalObject {
36
class JSModuleLoader : public JSNonFinalObject {
36
private:
37
private:
Lines 67-72 class JSModuleLoader : public JSNonFinalObject { a/Source/JavaScriptCore/runtime/JSModuleLoader.h_sec2
67
    JSValue linkAndEvaluateModule(ExecState*, JSValue moduleKey, JSValue initiator);
68
    JSValue linkAndEvaluateModule(ExecState*, JSValue moduleKey, JSValue initiator);
68
69
69
    // Platform dependent hooked APIs.
70
    // Platform dependent hooked APIs.
71
    JSInternalPromise* importModule(ExecState*, JSString* moduleName, const SourceOrigin& referrer);
70
    JSInternalPromise* resolve(ExecState*, JSValue name, JSValue referrer, JSValue initiator);
72
    JSInternalPromise* resolve(ExecState*, JSValue name, JSValue referrer, JSValue initiator);
71
    JSInternalPromise* fetch(ExecState*, JSValue key, JSValue initiator);
73
    JSInternalPromise* fetch(ExecState*, JSValue key, JSValue initiator);
72
    JSInternalPromise* instantiate(ExecState*, JSValue key, JSValue source, JSValue initiator);
74
    JSInternalPromise* instantiate(ExecState*, JSValue key, JSValue source, JSValue initiator);
Lines 74-79 class JSModuleLoader : public JSNonFinalObject { a/Source/JavaScriptCore/runtime/JSModuleLoader.h_sec3
74
    // Additional platform dependent hooked APIs.
76
    // Additional platform dependent hooked APIs.
75
    JSValue evaluate(ExecState*, JSValue key, JSValue moduleRecord, JSValue initiator);
77
    JSValue evaluate(ExecState*, JSValue key, JSValue moduleRecord, JSValue initiator);
76
78
79
    // Utility functions.
80
    JSModuleNamespaceObject* getModuleNamespaceObject(ExecState*, JSValue moduleRecord);
81
77
protected:
82
protected:
78
    void finishCreation(ExecState*, VM&, JSGlobalObject*);
83
    void finishCreation(ExecState*, VM&, JSGlobalObject*);
79
};
84
};
- a/Source/JavaScriptCore/runtime/ModuleLoaderPrototype.cpp +17 lines
Lines 37-42 a/Source/JavaScriptCore/runtime/ModuleLoaderPrototype.cpp_sec1
37
#include "JSMap.h"
37
#include "JSMap.h"
38
#include "JSModuleEnvironment.h"
38
#include "JSModuleEnvironment.h"
39
#include "JSModuleLoader.h"
39
#include "JSModuleLoader.h"
40
#include "JSModuleNamespaceObject.h"
40
#include "JSModuleRecord.h"
41
#include "JSModuleRecord.h"
41
#include "ModuleAnalyzer.h"
42
#include "ModuleAnalyzer.h"
42
#include "Nodes.h"
43
#include "Nodes.h"
Lines 52-57 static EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeModuleDeclarationInstan a/Source/JavaScriptCore/runtime/ModuleLoaderPrototype.cpp_sec2
52
static EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeResolve(ExecState*);
53
static EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeResolve(ExecState*);
53
static EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeFetch(ExecState*);
54
static EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeFetch(ExecState*);
54
static EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeInstantiate(ExecState*);
55
static EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeInstantiate(ExecState*);
56
static EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeGetModuleNamespaceObject(ExecState*);
55
57
56
}
58
}
57
59
Lines 85-90 const ClassInfo ModuleLoaderPrototype::s_info = { "ModuleLoader", &Base::s_info, a/Source/JavaScriptCore/runtime/ModuleLoaderPrototype.cpp_sec3
85
    loadAndEvaluateModule          JSBuiltin                                           DontEnum|Function 3
87
    loadAndEvaluateModule          JSBuiltin                                           DontEnum|Function 3
86
    loadModule                     JSBuiltin                                           DontEnum|Function 3
88
    loadModule                     JSBuiltin                                           DontEnum|Function 3
87
    linkAndEvaluateModule          JSBuiltin                                           DontEnum|Function 2
89
    linkAndEvaluateModule          JSBuiltin                                           DontEnum|Function 2
90
    importModule                   JSBuiltin                                           DontEnum|Function 3
91
    getModuleNamespaceObject       moduleLoaderPrototypeGetModuleNamespaceObject       DontEnum|Function 1
88
    parseModule                    moduleLoaderPrototypeParseModule                    DontEnum|Function 2
92
    parseModule                    moduleLoaderPrototypeParseModule                    DontEnum|Function 2
89
    requestedModules               moduleLoaderPrototypeRequestedModules               DontEnum|Function 1
93
    requestedModules               moduleLoaderPrototypeRequestedModules               DontEnum|Function 1
90
    resolve                        moduleLoaderPrototypeResolve                        DontEnum|Function 2
94
    resolve                        moduleLoaderPrototypeResolve                        DontEnum|Function 2
Lines 211-216 EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeInstantiate(ExecState* exec) a/Source/JavaScriptCore/runtime/ModuleLoaderPrototype.cpp_sec4
211
    return JSValue::encode(loader->instantiate(exec, exec->argument(0), exec->argument(1), exec->argument(2)));
215
    return JSValue::encode(loader->instantiate(exec, exec->argument(0), exec->argument(1), exec->argument(2)));
212
}
216
}
213
217
218
EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeGetModuleNamespaceObject(ExecState* exec)
219
{
220
    VM& vm = exec->vm();
221
    auto scope = DECLARE_THROW_SCOPE(vm);
222
223
    JSModuleLoader* loader = jsDynamicCast<JSModuleLoader*>(exec->thisValue());
224
    if (!loader)
225
        return JSValue::encode(jsUndefined());
226
    auto* moduleNamespaceObject = loader->getModuleNamespaceObject(exec, exec->argument(0));
227
    RETURN_IF_EXCEPTION(scope, encodedJSValue());
228
    return JSValue::encode(moduleNamespaceObject);
229
}
230
214
// ------------------- Additional Hook Functions ---------------------------
231
// ------------------- Additional Hook Functions ---------------------------
215
232
216
EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeEvaluate(ExecState* exec)
233
EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeEvaluate(ExecState* exec)
- a/Source/WebCore/bindings/js/JSDOMWindowBase.cpp +1 lines
Lines 64-69 const GlobalObjectMethodTable JSDOMWindowBase::s_globalObjectMethodTable = { a/Source/WebCore/bindings/js/JSDOMWindowBase.cpp_sec1
64
    &javaScriptRuntimeFlags,
64
    &javaScriptRuntimeFlags,
65
    &queueTaskToEventLoop,
65
    &queueTaskToEventLoop,
66
    &shouldInterruptScriptBeforeTimeout,
66
    &shouldInterruptScriptBeforeTimeout,
67
    nullptr,
67
    &moduleLoaderResolve,
68
    &moduleLoaderResolve,
68
    &moduleLoaderFetch,
69
    &moduleLoaderFetch,
69
    nullptr,
70
    nullptr,
- a/Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.cpp +1 lines
Lines 57-62 const GlobalObjectMethodTable JSWorkerGlobalScopeBase::s_globalObjectMethodTable a/Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.cpp_sec1
57
    nullptr,
57
    nullptr,
58
    nullptr,
58
    nullptr,
59
    nullptr,
59
    nullptr,
60
    nullptr,
60
    &defaultLanguage
61
    &defaultLanguage
61
};
62
};
62
63
- a/LayoutTests/ChangeLog +9 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2016-12-27  Yusuke Suzuki  <utatane.tea@gmail.com>
2
3
        [JSC] Prototype dynamic-import
4
        https://bugs.webkit.org/show_bug.cgi?id=165724
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * sputnik/Conformance/07_Lexical_Conventions/7.5_Tokens/7.5.3_Future_Reserved_Words/S7.5.3_A1.16-expected.txt:
9
1
2016-12-26  Zalan Bujtas  <zalan@apple.com>
10
2016-12-26  Zalan Bujtas  <zalan@apple.com>
2
11
3
        ASSERTION FAILED: !rect.isEmpty() in WebCore::GraphicsContext::drawRect
12
        ASSERTION FAILED: !rect.isEmpty() in WebCore::GraphicsContext::drawRect
- a/LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.5_Tokens/7.5.3_Future_Reserved_Words/S7.5.3_A1.16-expected.txt -1 / +1 lines
Lines 1-4 a/LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.5_Tokens/7.5.3_Future_Reserved_Words/S7.5.3_A1.16-expected.txt_sec1
1
CONSOLE MESSAGE: line 76: SyntaxError: Unexpected keyword 'import'
1
CONSOLE MESSAGE: line 76: SyntaxError: Unexpected token '='. Expected '(' to start an 'import' call.
2
S7.5.3_A1.16
2
S7.5.3_A1.16
3
3
4
PASS Expected parsing failure
4
PASS Expected parsing failure
- a/JSTests/ChangeLog +26 lines
Lines 1-3 a/JSTests/ChangeLog_sec1
1
2016-12-27  Yusuke Suzuki  <utatane.tea@gmail.com>
2
3
        [JSC] Prototype dynamic-import
4
        https://bugs.webkit.org/show_bug.cgi?id=165724
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * stress/import-basic.js: Added.
9
        (async):
10
        (catch):
11
        * stress/import-from-eval.js: Added.
12
        (async):
13
        (catch):
14
        * stress/import-syntax.js: Added.
15
        (testSyntaxError):
16
        * stress/import-tests/cocoa.js: Added.
17
        (export.Cocoa):
18
        (export.hello):
19
        * stress/import-tests/multiple.js: Added.
20
        (export.result):
21
        * stress/import-tests/multiple2.js: Added.
22
        (export.ok):
23
        * stress/import-tests/should.js: Added.
24
        (export.shouldBe):
25
        (export.shouldThrow):
26
1
2016-12-25  Yusuke Suzuki  <utatane.tea@gmail.com>
27
2016-12-25  Yusuke Suzuki  <utatane.tea@gmail.com>
2
28
3
        Propagate the source origin as much as possible
29
        Propagate the source origin as much as possible
- a/JSTests/stress/import-basic.js +53 lines
Line 0 a/JSTests/stress/import-basic.js_sec1
1
(async function () {
2
    const { shouldBe } = await import('./import-tests/should.js');
3
    {
4
        let a = await import('./import-tests/cocoa.js');
5
        let b = await import('./import-tests/cocoa.js');
6
        shouldBe(a, b);
7
        shouldBe(a.hello(), 42);
8
    }
9
10
    {
11
        let a = await import('./import-tests/multiple.js');
12
        let a2 = await a.result();
13
        shouldBe(a !== a2, true);
14
        shouldBe(a2.ok(), 42);
15
        let a3 = await a.result();
16
        shouldBe(a2, a3);
17
    }
18
19
    {
20
        let error = null;
21
        try {
22
            let a = await import({ toString() { throw new Error('out'); } });
23
        } catch (e) {
24
            error = e;
25
        }
26
        shouldBe(error !== null, true);
27
        shouldBe(String(error), `Error: out`);
28
    }
29
30
    {
31
        async function load(cond) {
32
            if (cond)
33
                return import('./import-tests/cocoa.js');
34
            return undefined;
35
        }
36
37
        let v = await load(false);
38
        shouldBe(v, undefined);
39
        let v2 = await load(true);
40
        let v3 = await import('./import-tests/cocoa.js');
41
        shouldBe(v2, v2);
42
    }
43
44
    {
45
        let value = './import-tests/cocoa.js';
46
        let v = await import(value);
47
        let v2 = await import('./import-tests/cocoa.js');
48
        shouldBe(v, v2);
49
    }
50
}()).catch((error) => {
51
    print(String(error));
52
    abort();
53
});
- a/JSTests/stress/import-from-eval.js +36 lines
Line 0 a/JSTests/stress/import-from-eval.js_sec1
1
(async function () {
2
    const { shouldBe, shouldThrow } = await import("./import-tests/should.js");
3
4
    {
5
        let cocoa = await eval(`import("./import-tests/cocoa.js")`);
6
        shouldBe(cocoa.hello(), 42);
7
    }
8
9
    {
10
        let cocoa = await (0, eval)(`import("./import-tests/cocoa.js")`);
11
        shouldBe(cocoa.hello(), 42);
12
    }
13
14
    {
15
        let cocoa = await eval(`eval('import("./import-tests/cocoa.js")')`);
16
        shouldBe(cocoa.hello(), 42);
17
    }
18
19
    {
20
        let cocoa = await ((new Function(`return eval('import("./import-tests/cocoa.js")')`))());
21
        shouldBe(cocoa.hello(), 42);
22
    }
23
24
    {
25
        let cocoa = await eval(`(new Function('return import("./import-tests/cocoa.js")'))()`);
26
        shouldBe(cocoa.hello(), 42);
27
    }
28
29
    {
30
        let cocoa = await [`import("./import-tests/cocoa.js")`].map(eval)[0];
31
        shouldBe(cocoa.hello(), 42);
32
    }
33
}()).catch((error) => {
34
    print(String(error));
35
    abort();
36
});
- a/JSTests/stress/import-syntax.js +32 lines
Line 0 a/JSTests/stress/import-syntax.js_sec1
1
function testSyntaxError(script, message) {
2
    var error = null;
3
    try {
4
        eval(script);
5
    } catch (e) {
6
        error = e;
7
    }
8
    if (!error)
9
        throw new Error("Expected syntax error not thrown");
10
11
    if (String(error) !== message)
12
        throw new Error(`Bad error: ${String(error)}`);
13
}
14
15
testSyntaxError(`import)`, `SyntaxError: Unexpected token ')'. Expected '(' to start an 'import' call.`);
16
testSyntaxError(`new import(`, `SyntaxError: Cannot use new with import.`);
17
testSyntaxError(`import.hello()`, `SyntaxError: Unexpected token '.'. Expected '(' to start an 'import' call.`);
18
testSyntaxError(`import[`, `SyntaxError: Unexpected token '['. Expected '(' to start an 'import' call.`);
19
testSyntaxError(`import<`, `SyntaxError: Unexpected token '<'. Expected '(' to start an 'import' call.`);
20
21
testSyntaxError(`import()`, `SyntaxError: Unexpected token ')'`);
22
testSyntaxError(`import("Hello";`, `SyntaxError: Unexpected token ';'. Expected ')' to end an 'import' call.`);
23
testSyntaxError(`import("Hello"];`, `SyntaxError: Unexpected token ']'. Expected ')' to end an 'import' call.`);
24
testSyntaxError(`import("Hello",;`, `SyntaxError: Unexpected token ','. Expected ')' to end an 'import' call.`);
25
testSyntaxError(`import("Hello", "Hello2";`, `SyntaxError: Unexpected token ','. Expected ')' to end an 'import' call.`);
26
27
testSyntaxError(`import = 42`, `SyntaxError: Unexpected token '='. Expected '(' to start an 'import' call.`);
28
testSyntaxError(`[import] = 42`, `SyntaxError: Unexpected token ']'. Expected '(' to start an 'import' call.`);
29
testSyntaxError(`{import} = 42`, `SyntaxError: Unexpected token '}'. Expected '(' to start an 'import' call.`);
30
testSyntaxError(`let import = 42`, `SyntaxError: Unexpected keyword 'import'`);
31
testSyntaxError(`var import = 42`, `SyntaxError: Cannot use the keyword 'import' as a variable name.`);
32
testSyntaxError(`const import = 42`, `SyntaxError: Cannot use the keyword 'import' as a lexical variable name.`);
- a/JSTests/stress/import-tests/cocoa.js +7 lines
Line 0 a/JSTests/stress/import-tests/cocoa.js_sec1
1
export class Cocoa {
2
}
3
4
export function hello()
5
{
6
    return 42;
7
}
- a/JSTests/stress/import-tests/multiple.js +4 lines
Line 0 a/JSTests/stress/import-tests/multiple.js_sec1
1
export function result()
2
{
3
    return import('./multiple2.js');
4
}
- a/JSTests/stress/import-tests/multiple2.js +4 lines
Line 0 a/JSTests/stress/import-tests/multiple2.js_sec1
1
export function ok()
2
{
3
    return 42;
4
}
- a/JSTests/stress/import-tests/should.js +19 lines
Line 0 a/JSTests/stress/import-tests/should.js_sec1
1
export function shouldBe(actual, expected) {
2
    if (actual !== expected)
3
        throw new Error(`bad value: ${String(actual)}`);
4
}
5
6
export function shouldThrow(func, errorMessage) {
7
    var errorThrown = false;
8
    var error = null;
9
    try {
10
        func();
11
    } catch (e) {
12
        errorThrown = true;
13
        error = e;
14
    }
15
    if (!errorThrown)
16
        throw new Error('not thrown');
17
    if (String(error) !== errorMessage)
18
        throw new Error(`bad error: ${String(error)}`);
19
}

Return to Bug 165724