haikuwebkit/Tools/Scripts/test262
Yusuke Suzuki 369f05ed1a Re-enable SharedArrayBuffer for JSC shell and Testers
https://bugs.webkit.org/show_bug.cgi?id=212069

Reviewed by Keith Miller.

JSTests:

Update tests to align to the latest spec.

* stress/SharedArrayBuffer-opt.js:
(shouldSucceed):
(idx.of.string_appeared_here.a.of.arrays.m.of.atomics):
(string_appeared_here.a.of.arrays.m.of.atomics): Deleted.
* stress/SharedArrayBuffer.js:
(shouldSucceed):
(Symbol):
* stress/array-buffer-byte-length.js:
(shouldThrow):
(Symbol):
* stress/atomics-add-uint32.js:
* stress/atomics-known-int-use.js:
* stress/atomics-neg-zero.js:
* stress/atomics-store-return.js:
* stress/lars-sab-workers.js:
(resources):
(notify):
(wake): Deleted.
* stress/regress-170473.js:
* stress/regress-189317.js:
* stress/shared-array-buffer-sort-while-different-thread-is-modifying.js: Added.
(262.agent.waitUntil):
(262.agent.start.262.agent.receiveBroadcast):
* test262/config.yaml:
* test262/expectations.yaml:

LayoutTests/imported/w3c:

* web-platform-tests/html/webappapis/scripting/processing-model-2/integration-with-the-javascript-agent-formalism/requires-failure.https.any-expected.txt:
* web-platform-tests/html/webappapis/scripting/processing-model-2/integration-with-the-javascript-agent-formalism/requires-failure.https.any.serviceworker-expected.txt:
* web-platform-tests/html/webappapis/scripting/processing-model-2/integration-with-the-javascript-agent-formalism/requires-success.any.worker-expected.txt:
* web-platform-tests/wasm/jsapi/memory/constructor.any-expected.txt:
* web-platform-tests/wasm/jsapi/memory/constructor.any.worker-expected.txt:
* web-platform-tests/workers/postMessage_block.https-expected.txt:

Source/JavaScriptCore:

This patch revives SharedArrayBuffer and Atomics and aligning them to the latest spec.

1. SharedArrayBuffer's sort should be done in JS side. C++ sort is not safe for SharedArrayBuffer since the buffer
   can be modified by different threads while sorting.
2. Atomics.wait should be renamed to Atomics.notify.
3. Atomics operation should be VarArgs in DFG because DFGSSALoweringPhase assumes that they are VarArgs and they can
   have another arg for CheckInBounds dependency.
4. For test262, JSC shell should support "--can-block-is-false" flag. If it is true, the main thread's [[CanBlock]] becomes false.
   This means that `Atomics.wait` cannot be used.

* builtins/BuiltinNames.h:
* builtins/TypedArrayPrototype.js:
(sort):
* bytecode/LinkTimeConstant.h:
* dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::handleIntrinsicCall):
* dfg/DFGClobberize.h:
(JSC::DFG::clobberize):
* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* dfg/DFGNode.h:
(JSC::DFG::Node::mustGenerate const):
(JSC::DFG::Node::hasVarArgs const):
(JSC::DFG::Node::mustGenerate): Deleted.
* dfg/DFGNodeType.h:
* dfg/DFGSSALoweringPhase.cpp:
(JSC::DFG::SSALoweringPhase::handleNode):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileAtomicsIsLockFree):
* jsc.cpp:
(printUsageStatement):
(CommandLine::parseArguments):
(runJSC):
* runtime/AtomicsObject.cpp:
(JSC::AtomicsObject::finishCreation):
(JSC::JSC_DEFINE_HOST_FUNCTION):
(JSC::JSC_DEFINE_JIT_OPERATION):
* runtime/CommonIdentifiers.h:
* runtime/Intrinsic.cpp:
(JSC::intrinsicName):
* runtime/Intrinsic.h:
* runtime/JSArrayBufferPrototype.cpp:
(JSC::arrayBufferSlice):
(JSC::arrayBufferByteLength):
(JSC::JSC_DEFINE_HOST_FUNCTION):
(JSC::JSArrayBufferPrototype::finishCreation):
* runtime/JSCJSValue.h:
* runtime/JSCJSValueInlines.h:
(JSC::JSValue::toIntegerOrInfinity const):
* runtime/JSGenericTypedArrayViewPrototypeFunctions.h:
(JSC::genericTypedArrayViewProtoFuncReverse):
(JSC::genericTypedArrayViewPrivateFuncSort):
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
* runtime/JSTypedArrayViewPrototype.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/JSTypedArrayViewPrototype.h:
* runtime/OptionsList.h:
* runtime/SimpleTypedArrayController.cpp:
(JSC::SimpleTypedArrayController::SimpleTypedArrayController):
(JSC::SimpleTypedArrayController::isAtomicsWaitAllowedOnCurrentThread):
* runtime/SimpleTypedArrayController.h:
* runtime/SmallStrings.cpp:
(JSC::SmallStrings::initializeCommonStrings):
(JSC::SmallStrings::visitStrongReferences):
* runtime/SmallStrings.h:
(JSC::SmallStrings::notEqualString const):
(JSC::SmallStrings::timedOutString const):
(JSC::SmallStrings::okString const):

Source/WTF:

* wtf/PlatformEnable.h:

Tools:

* Scripts/test262/Runner.pm:
(getFeatureFlags):
* Scripts/webkitpy/layout_tests/run_webkit_tests.py:
(main):

LayoutTests:

* webaudio/dom-exceptions-expected.txt:

Canonical link: https://commits.webkit.org/231326@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269531 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-11-06 20:23:25 +00:00
..
local
Import.pm [JSC] update test262 (July 2020 edition) 2020-07-20 22:01:37 +00:00
README.md
Runner.pm Re-enable SharedArrayBuffer for JSC shell and Testers 2020-11-06 20:23:25 +00:00
cpanfile
cpanfile.snapshot
expectation.yaml
report.css

README.md

Test262 Tools

Runner script

To execute the Test262 Runner script, just call it through your shell.

./Tools/Scripts/test262-runner

Custom options

If you need to customize the execution, check out runner.pl --help for extra commands.

test262-config.yaml

This yaml file can be used to skip tests. An example file:

---
skip:
  paths:
    - test/built-ins/Atomics
  features:
    - SharedArrayBuffer
    - BigInt
  files:
    - test/built-ins/Array/prototype/reverse/length-exceeding-integer-limit-with-object.js
    - test/built-ins/Array/prototype/unshift/length-near-integer-limit.js

test262-expectation.yaml

This file contains all exected failures. If JSC or Test262 is updated, this file should be updated with the new set of expected tests in order for developers to only see errors they introduce.

To update this file, run:

runner.pl --save-expectations

test262-results.yaml

This file contains results for all tests. It is updated on every run.

Import Script

To execute the Test262 Import script, just call it through your shell. The script will update the JSTests/test262 folder.

./Tools/Scripts/test262-import

Custom options

If you need to customize the execution, check out import.pl --help for extra commands.

Development

The Test262 Runner script requires Perl 5.8.8, to install Perl 5.8.8, use Perlbrew.

Its not necessary to install Perl 5.8.8 to execute the runner script if you have a more recent version of Perl 5.x.x installed.

It's also not necessary to install or configure anything extra to execute the runner script. The script dependencies are also stored locally.

Installing Perlbrew

Mac

\curl -L https://install.perlbrew.pl | bash

Linux (Debian derivative):

sudo apt-get install perlbrew
perlbrew init

Loading Perlbrew

Append the following piece of code to the end of your ~/.bash_profile and start a new shell, perlbrew should be up and fully functional from there:

source ~/perl5/perlbrew/etc/bashrc

Installing Perl 5.8.8 through Perlbrew

Mac

perlbrew install perl-5.8.8

Linux

perlbrew --notest install perl-5.8.8 # Perl 5.8.8 has some known compilation errors

Switching to Perl versions

perlbrew switch perl-5.8.8
perlbrew switch perl-5.27.6
# ...

Install cpanminus and Carton

Install cpanminus and Carton to set and manage dependencies.

perlbrew install-cpanm
cpanm install Carton

Installing dependencies through Carton

From the Tools/Scripts/test262-helpes/ folder, run carton install to install dependencies from the cpanfile.

More documentation on the cpanfile here.

Executing the script using Carton:

carton exec runner.pl

Loading dependencies without Carton

To run the script without Carton, prepend your script file with the following code:

use FindBin;
use Config;
use Encode;

BEGIN {
    $ENV{DBIC_OVERWRITE_HELPER_METHODS_OK} = 1;

    unshift @INC, ".";
    unshift @INC, "$FindBin::Bin/lib";
    unshift @INC, "$FindBin::Bin/local/lib/perl5";
    unshift @INC, "$FindBin::Bin/local/lib/perl5/$Config{archname}";

    $ENV{LOAD_ROUTES} = 1;
}