- Revision
- 238753
- Author
- [email protected]
- Date
- 2018-11-30 13:55:12 -0800 (Fri, 30 Nov 2018)
Log Message
Add first-class support for .mjs files in jsc binary
https://bugs.webkit.org/show_bug.cgi?id=192190
<rdar://problem/46375715>
Reviewed by Keith Miller.
JSTests:
* stress/simple-module.mjs: Added.
* stress/simple-script.js: Added.
Source/_javascript_Core:
Treat files with a .mjs extension as a module, regardless
of whether or not the --module-file argument was given.
* jsc.cpp:
(printUsageStatement): Update usage.
(isMJSFile): Helper to look for .mjs extensions.
(CommandLine::parseArguments): Pick the appropriate script type.
Tools:
Add .mjs files to the regexp looking for all JS files.
* Scripts/run-jsc-stress-tests:
Modified Paths
Added Paths
Diff
Modified: trunk/JSTests/ChangeLog (238752 => 238753)
--- trunk/JSTests/ChangeLog 2018-11-30 21:27:54 UTC (rev 238752)
+++ trunk/JSTests/ChangeLog 2018-11-30 21:55:12 UTC (rev 238753)
@@ -1,3 +1,14 @@
+2018-11-30 Dean Jackson <[email protected]>
+
+ Add first-class support for .mjs files in jsc binary
+ https://bugs.webkit.org/show_bug.cgi?id=192190
+ <rdar://problem/46375715>
+
+ Reviewed by Keith Miller.
+
+ * stress/simple-module.mjs: Added.
+ * stress/simple-script.js: Added.
+
2018-11-30 Caio Lima <[email protected]>
[BigInt] Implement ValueBitXor into DFG
Added: trunk/JSTests/stress/simple-module.mjs (0 => 238753)
--- trunk/JSTests/stress/simple-module.mjs (rev 0)
+++ trunk/JSTests/stress/simple-module.mjs 2018-11-30 21:55:12 UTC (rev 238753)
@@ -0,0 +1,2 @@
+if (this !== undefined)
+ throw new Error("this === undefined in module code");
Added: trunk/JSTests/stress/simple-script.js (0 => 238753)
--- trunk/JSTests/stress/simple-script.js (rev 0)
+++ trunk/JSTests/stress/simple-script.js 2018-11-30 21:55:12 UTC (rev 238753)
@@ -0,0 +1,2 @@
+if (this === undefined)
+ throw new Error("this !== undefined in script code");
Property changes on: trunk/JSTests/stress/simple-script.js
___________________________________________________________________
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:keywords
+Date Revision
\ No newline at end of property
Added: svn:mime-type
+text/plain
\ No newline at end of property
Modified: trunk/Source/_javascript_Core/ChangeLog (238752 => 238753)
--- trunk/Source/_javascript_Core/ChangeLog 2018-11-30 21:27:54 UTC (rev 238752)
+++ trunk/Source/_javascript_Core/ChangeLog 2018-11-30 21:55:12 UTC (rev 238753)
@@ -1,3 +1,19 @@
+2018-11-30 Dean Jackson <[email protected]>
+
+ Add first-class support for .mjs files in jsc binary
+ https://bugs.webkit.org/show_bug.cgi?id=192190
+ <rdar://problem/46375715>
+
+ Reviewed by Keith Miller.
+
+ Treat files with a .mjs extension as a module, regardless
+ of whether or not the --module-file argument was given.
+
+ * jsc.cpp:
+ (printUsageStatement): Update usage.
+ (isMJSFile): Helper to look for .mjs extensions.
+ (CommandLine::parseArguments): Pick the appropriate script type.
+
2018-11-30 Caio Lima <[email protected]>
[BigInt] Implement ValueBitXor into DFG
Modified: trunk/Source/_javascript_Core/jsc.cpp (238752 => 238753)
--- trunk/Source/_javascript_Core/jsc.cpp 2018-11-30 21:27:54 UTC (rev 238752)
+++ trunk/Source/_javascript_Core/jsc.cpp 2018-11-30 21:55:12 UTC (rev 238753)
@@ -2568,10 +2568,22 @@
fprintf(stderr, " --dumpOptions Dumps all non-default JSC VM options before continuing\n");
fprintf(stderr, " --<jsc VM option>=<value> Sets the specified JSC VM option\n");
fprintf(stderr, "\n");
+ fprintf(stderr, "Files with a .mjs extension will always be evaluated as modules.\n");
+ fprintf(stderr, "\n");
jscExit(help ? EXIT_SUCCESS : EXIT_FAILURE);
}
+static bool isMJSFile(char *filename)
+{
+ filename = strrchr(filename, '.');
+
+ if (filename)
+ return !strcasecmp(filename, ".mjs");
+
+ return false;
+}
+
void CommandLine::parseArguments(int argc, char** argv)
{
Options::initialize();
@@ -2722,7 +2734,8 @@
// This arg is not recognized by the VM nor by jsc. Pass it on to the
// script.
- m_scripts.append(Script(Script::StrictMode::Sloppy, Script::CodeSource::File, Script::ScriptType::Script, argv[i]));
+ Script::ScriptType scriptType = isMJSFile(argv[i]) ? Script::ScriptType::Module : Script::ScriptType::Script;
+ m_scripts.append(Script(Script::StrictMode::Sloppy, Script::CodeSource::File, scriptType, argv[i]));
}
if (hasBadJSCOptions && JSC::Options::validateOptions())
Modified: trunk/Tools/ChangeLog (238752 => 238753)
--- trunk/Tools/ChangeLog 2018-11-30 21:27:54 UTC (rev 238752)
+++ trunk/Tools/ChangeLog 2018-11-30 21:55:12 UTC (rev 238753)
@@ -1,3 +1,15 @@
+2018-11-30 Dean Jackson <[email protected]>
+
+ Add first-class support for .mjs files in jsc binary
+ https://bugs.webkit.org/show_bug.cgi?id=192190
+ <rdar://problem/46375715>
+
+ Reviewed by Keith Miller.
+
+ Add .mjs files to the regexp looking for all JS files.
+
+ * Scripts/run-jsc-stress-tests:
+
2018-11-30 Jonathan Bedard <[email protected]>
webkitpy: Use DeviceType instead of str to represent device class
Modified: trunk/Tools/Scripts/run-jsc-stress-tests (238752 => 238753)
--- trunk/Tools/Scripts/run-jsc-stress-tests 2018-11-30 21:27:54 UTC (rev 238752)
+++ trunk/Tools/Scripts/run-jsc-stress-tests 2018-11-30 21:55:12 UTC (rev 238753)
@@ -1429,7 +1429,7 @@
result = []
Dir.foreach(path) {
| filename |
- next unless filename =~ /\.js$/
+ next unless filename =~ /\.m?js$/
next unless (path + filename).file?
result << path + filename
}