Add result validation to JSAir
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Jun 2016 17:21:52 +0000 (17:21 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Jun 2016 17:21:52 +0000 (17:21 +0000)
commit00fb34a964a2a0a4bdc0b1aaf2f171b564421dc8
tree6449c47da9ed2632b1e109640e049f5f11c3f51d
parentbda8f360610657b2fa29044e6865e2306f6c73fb
Add result validation to JSAir
https://bugs.webkit.org/show_bug.cgi?id=158493

Reviewed by Saam Barati.

PerformanceTests:

This adds the ability to hash a Code in a way that matches the C++ code's hashing of Code.
This allows us to check if the Code that JSAir sees is the code that C++ saw. We use this to
check the Code before and after allocateStack, and compare against hashes we got from C++.

Doing this uncovered bugs. roundUpToMultipleOf wasn't doing anything. allocateStack was not
allocating things correctly because I was concatting a Set to an Array, which doesn't really
work. Now these bugs are fixed.

The checking step adds to the running time so I reduced the number of iterations. The
benchmark spends a decent amount of its time computing Code hashes; I think it's around 1/3
total. This is probably OK. It's better to verify the results even if the running time is
not all in the "core" of the algorithm.

Also add a run-jsc-stress-tests yaml file to allow this to run as a test.

* JSAir/allocate_stack.js:
* JSAir/arg.js:
(Arg.createImm):
(Arg.createBigImm):
(Arg.createBitImm):
(Arg.createBitImm64):
(Arg.createWidth):
(Arg.createSpecial):
(Arg.prototype.get kind):
(Arg.prototype.get isTmp):
(Arg.prototype.get isImm):
(Arg.prototype.get isSomeImm):
(Arg.prototype.get isSomeBigImm):
(Arg.prototype.get isCondition):
(Arg.prototype.get isWidth):
(Arg.prototype.get isSpecial):
(Arg.prototype.get isAlive):
(Arg.prototype.get tmp):
(Arg.prototype.get value):
(Arg.prototype.get lowValue):
(Arg.prototype.get highValue):
(Arg.prototype.get base):
(Arg.prototype.get isGP):
(Arg.prototype.get isFP):
(Arg.prototype.isValidForm):
(Arg.prototype.get isInvertible):
(Arg.kindCode):
(Arg.prototype.hash):
(Arg.prototype.toString):
(Arg):
* JSAir/basic_block.js:
(BasicBlock.get successorBlocks):
* JSAir/benchmark.js:
(benchmark):
* JSAir/code.js:
(Code.prototype.setFrameSize):
(Code.prototype.hash):
(Code.prototype.toString):
(Code):
* JSAir/inst.js:
(Inst.prototype.get hasNonArgEffects):
(Inst.prototype.hash):
(Inst.prototype.toString):
(Inst):
* JSAir/jsair-tests.yaml: Added.
* JSAir/opcode.js:
(Inst_forEachArg):
(Inst_hasNonArgEffects):
(opcodeCode):
* JSAir/payload-gbemu-executeIteration.js:
(createPayloadGbemuExecuteIteration):
* JSAir/payload-imaging-gaussian-blur-gaussianBlur.js:
(createPayloadImagingGaussianBlurGaussianBlur):
* JSAir/payload-jsair-ACLj8C.js:
(createPayloadJSAirACLj8C):
* JSAir/payload-typescript-scanIdentifier.js:
(createPayloadTypescriptScanIdentifier):
* JSAir/reg.js:
(Reg.prototype.get isReg):
(Reg.prototype.hash):
(Reg.prototype.toString):
* JSAir/stack_slot.js:
(StackSlot.prototype.setOffsetFromFP):
(StackSlot.prototype.hash):
(StackSlot.prototype.toString):
* JSAir/symbols.js:
(relCondCode):
(resCondCode):
(doubleCondCode):
* JSAir/test.html:
* JSAir/tmp.js:
(Tmp.prototype.get isReg):
(Tmp.prototype.hash):
(Tmp.prototype.toString):
* JSAir/util.js:
(roundUpToMultipleOf):
(symbolName):

Source/JavaScriptCore:

Add a ::jsHash() method to some things, to compute a hash code that is suitable for
comparing a C++ Code to a JSAir Code. This is different from existing hashing functionality
because it errs on the side of easy reproducibility from JS rather than speed.

* b3/air/AirArg.cpp:
(JSC::B3::Air::Arg::isCompatibleType):
(JSC::B3::Air::Arg::jsHash):
(JSC::B3::Air::Arg::dump):
* b3/air/AirArg.h:
(JSC::B3::Air::Arg::asDoubleCondition):
(JSC::B3::Air::Arg::isInvertible):
(JSC::B3::Air::Arg::isUnsignedCond):
(JSC::B3::Air::Arg::Arg):
* b3/air/AirCode.cpp:
(JSC::B3::Air::Code::addFastTmp):
(JSC::B3::Air::Code::jsHash):
* b3/air/AirCode.h:
(JSC::B3::Air::Code::lastPhaseName):
* b3/air/AirDumpAsJS.cpp:
(JSC::B3::Air::dumpAsJS):
* b3/air/AirGenerate.cpp:
(JSC::B3::Air::prepareForGeneration):
* b3/air/AirInst.cpp:
(JSC::B3::Air::Inst::hasArgEffects):
(JSC::B3::Air::Inst::jsHash):
(JSC::B3::Air::Inst::dump):
* b3/air/AirInst.h:
* b3/air/AirStackSlot.cpp:
(JSC::B3::Air::StackSlot::setOffsetFromFP):
(JSC::B3::Air::StackSlot::jsHash):
(JSC::B3::Air::StackSlot::dump):
* b3/air/AirStackSlot.h:
* b3/air/opcode_generator.rb:

Tools:

Run JSAir.

* Scripts/run-javascriptcore-tests:
(runJSCStressTests):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201807 268f45cc-cd09-0410-ab3c-d52691b4dbfc
33 files changed:
PerformanceTests/ChangeLog
PerformanceTests/JSAir/allocate_stack.js
PerformanceTests/JSAir/arg.js
PerformanceTests/JSAir/basic_block.js
PerformanceTests/JSAir/benchmark.js
PerformanceTests/JSAir/code.js
PerformanceTests/JSAir/inst.js
PerformanceTests/JSAir/jsair-tests.yaml [new file with mode: 0644]
PerformanceTests/JSAir/opcode.js
PerformanceTests/JSAir/payload-gbemu-executeIteration.js
PerformanceTests/JSAir/payload-imaging-gaussian-blur-gaussianBlur.js
PerformanceTests/JSAir/payload-jsair-ACLj8C.js
PerformanceTests/JSAir/payload-typescript-scanIdentifier.js
PerformanceTests/JSAir/reg.js
PerformanceTests/JSAir/stack_slot.js
PerformanceTests/JSAir/strip-hash.rb [new file with mode: 0644]
PerformanceTests/JSAir/symbols.js
PerformanceTests/JSAir/tmp.js
PerformanceTests/JSAir/util.js
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/b3/air/AirArg.cpp
Source/JavaScriptCore/b3/air/AirArg.h
Source/JavaScriptCore/b3/air/AirCode.cpp
Source/JavaScriptCore/b3/air/AirCode.h
Source/JavaScriptCore/b3/air/AirDumpAsJS.cpp
Source/JavaScriptCore/b3/air/AirGenerate.cpp
Source/JavaScriptCore/b3/air/AirInst.cpp
Source/JavaScriptCore/b3/air/AirInst.h
Source/JavaScriptCore/b3/air/AirStackSlot.cpp
Source/JavaScriptCore/b3/air/AirStackSlot.h
Source/JavaScriptCore/b3/air/opcode_generator.rb
Tools/ChangeLog
Tools/Scripts/run-javascriptcore-tests