haikuwebkit/LayoutTests/js/math-clz32-expected.txt

50 lines
1.9 KiB
Plaintext
Raw Permalink Normal View History

[JSC] Implement Math.clz32(), remove Number.clz() https://bugs.webkit.org/show_bug.cgi?id=144205 Reviewed by Michael Saboff. Source/JavaScriptCore: This patch adds the ES6 function Math.clz32(), and remove the non-standard Number.clz(). Number.clz() probably came from an older draft. The new function has a corresponding instrinsic: Clz32Intrinsic, and a corresponding DFG node: ArithClz32, optimized all the way to LLVM. * assembler/MacroAssemblerX86Common.h: (JSC::MacroAssemblerX86Common::countLeadingZeros32): * assembler/X86Assembler.h: (JSC::X86Assembler::bsr_rr): The x86 assembler did not have countLeadingZeros32() because there is no native CLZ instruction on that architecture. I have added the version with bsr + branches for the case of zero. An other popular version uses cmov to handle the case of zero. I kept it simple since the Assembler has no support for cmov. It is unlikely to matter much. If the code is hot enough, LLVM picks something good based on the surrounding code. * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): Constant handling + effect propagation. The node only produces integer (between 0 and 32). * dfg/DFGBackwardsPropagationPhase.cpp: (JSC::DFG::BackwardsPropagationPhase::propagate): Thanks to the definition of toUint32(), we can ignore plenty of details from doubles. * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::handleIntrinsic): * dfg/DFGClobberize.h: (JSC::DFG::clobberize): * dfg/DFGDoesGC.cpp: (JSC::DFG::doesGC): * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupNode): * dfg/DFGNodeType.h: * dfg/DFGPredictionPropagationPhase.cpp: (JSC::DFG::PredictionPropagationPhase::propagate): * dfg/DFGSafeToExecute.h: (JSC::DFG::safeToExecute): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileArithClz32): * dfg/DFGSpeculativeJIT.h: * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::compile): * ftl/FTLCapabilities.cpp: (JSC::FTL::canCompile): * ftl/FTLIntrinsicRepository.h: * ftl/FTLLowerDFGToLLVM.cpp: (JSC::FTL::LowerDFGToLLVM::compileNode): (JSC::FTL::LowerDFGToLLVM::compileArithClz32): * ftl/FTLOutput.h: (JSC::FTL::Output::ctlz32): * jit/ThunkGenerators.cpp: (JSC::clz32ThunkGenerator): * jit/ThunkGenerators.h: * runtime/Intrinsic.h: * runtime/MathCommon.h: (JSC::clz32): Fun fact: InstCombine does not recognize this pattern to eliminate the branch which makes our FTL version better than the C version. * runtime/MathObject.cpp: (JSC::MathObject::finishCreation): (JSC::mathProtoFuncClz32): * runtime/NumberPrototype.cpp: (JSC::clz): Deleted. (JSC::numberProtoFuncClz): Deleted. * runtime/VM.cpp: (JSC::thunkGeneratorForIntrinsic): * tests/stress/math-clz32-basics.js: Added. (mathClz32OnInteger): (testMathClz32OnIntegers): (verifyMathClz32OnIntegerWithOtherTypes): (mathClz32OnDouble): (testMathClz32OnDoubles): (verifyMathClz32OnDoublesWithOtherTypes): (mathClz32NoArguments): (mathClz32TooManyArguments): (testMathClz32OnConstants): (mathClz32StructTransition): (Math.clz32): LayoutTests: Basic conformance tests. * js/Object-getOwnPropertyNames-expected.txt: * js/math-clz32-expected.txt: Added. * js/math-clz32.html: Renamed from LayoutTests/js/number-clz.html. * js/number-clz-expected.txt: Removed. * js/script-tests/Object-getOwnPropertyNames.js: * js/script-tests/math-clz32.js: Added. (objectConvertToString.toString): (objectRecordToStringCall.toString): (objectThrowOnToString.toString): (objectWithValueOf.valueOf): (objectThrowOnValueOf.valueOf): (objectThrowOnValueOf.toString): (objectRecordValueOfCall.valueOf): (objectRecordConversionCalls.toString): (objectRecordConversionCalls.valueOf): * js/script-tests/number-clz.js: Removed. Canonical link: https://commits.webkit.org/162224@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183358 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-04-26 19:55:18 +00:00
Test the basic behaviors of Math.clz32()
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS Math.hasOwnProperty("clz32") is true
PASS typeof Math.clz32 is "function"
PASS Object.getPrototypeOf(Math).clz32 is undefined
PASS Math.clz32.length is 1
PASS Math.clz32.name is "clz32"
PASS Object.getOwnPropertyDescriptor(Math, "clz32").configurable is true
PASS Object.getOwnPropertyDescriptor(Math, "clz32").enumerable is false
PASS Object.getOwnPropertyDescriptor(Math, "clz32").writable is true
PASS Math.clz32(0) is 32
PASS Math.clz32(-0) is 32
PASS Math.clz32(1) is 31
PASS Math.clz32(-1) is 0
PASS Math.clz32(42) is 26
PASS Math.clz32(-2147483648) is 0
PASS Math.clz32(2147483647) is 1
PASS Math.clz32(Number.MAX_VALUE) is 32
PASS Math.clz32(Number.MIN_VALUE) is 32
PASS Math.clz32(Number.MAX_SAFE_INTEGER) is 0
PASS Math.clz32(Number.MIN_SAFE_INTEGER) is 31
PASS Math.clz32(Math.PI) is 30
PASS Math.clz32(Math.E) is 30
PASS Math.clz32(NaN) is 32
PASS Math.clz32(Number.POSITIVE_INFINITY) is 32
PASS Math.clz32(Number.NEGATIVE_INFINITY) is 32
[JSC] Implement Math.clz32(), remove Number.clz() https://bugs.webkit.org/show_bug.cgi?id=144205 Reviewed by Michael Saboff. Source/JavaScriptCore: This patch adds the ES6 function Math.clz32(), and remove the non-standard Number.clz(). Number.clz() probably came from an older draft. The new function has a corresponding instrinsic: Clz32Intrinsic, and a corresponding DFG node: ArithClz32, optimized all the way to LLVM. * assembler/MacroAssemblerX86Common.h: (JSC::MacroAssemblerX86Common::countLeadingZeros32): * assembler/X86Assembler.h: (JSC::X86Assembler::bsr_rr): The x86 assembler did not have countLeadingZeros32() because there is no native CLZ instruction on that architecture. I have added the version with bsr + branches for the case of zero. An other popular version uses cmov to handle the case of zero. I kept it simple since the Assembler has no support for cmov. It is unlikely to matter much. If the code is hot enough, LLVM picks something good based on the surrounding code. * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): Constant handling + effect propagation. The node only produces integer (between 0 and 32). * dfg/DFGBackwardsPropagationPhase.cpp: (JSC::DFG::BackwardsPropagationPhase::propagate): Thanks to the definition of toUint32(), we can ignore plenty of details from doubles. * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::handleIntrinsic): * dfg/DFGClobberize.h: (JSC::DFG::clobberize): * dfg/DFGDoesGC.cpp: (JSC::DFG::doesGC): * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupNode): * dfg/DFGNodeType.h: * dfg/DFGPredictionPropagationPhase.cpp: (JSC::DFG::PredictionPropagationPhase::propagate): * dfg/DFGSafeToExecute.h: (JSC::DFG::safeToExecute): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileArithClz32): * dfg/DFGSpeculativeJIT.h: * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::compile): * ftl/FTLCapabilities.cpp: (JSC::FTL::canCompile): * ftl/FTLIntrinsicRepository.h: * ftl/FTLLowerDFGToLLVM.cpp: (JSC::FTL::LowerDFGToLLVM::compileNode): (JSC::FTL::LowerDFGToLLVM::compileArithClz32): * ftl/FTLOutput.h: (JSC::FTL::Output::ctlz32): * jit/ThunkGenerators.cpp: (JSC::clz32ThunkGenerator): * jit/ThunkGenerators.h: * runtime/Intrinsic.h: * runtime/MathCommon.h: (JSC::clz32): Fun fact: InstCombine does not recognize this pattern to eliminate the branch which makes our FTL version better than the C version. * runtime/MathObject.cpp: (JSC::MathObject::finishCreation): (JSC::mathProtoFuncClz32): * runtime/NumberPrototype.cpp: (JSC::clz): Deleted. (JSC::numberProtoFuncClz): Deleted. * runtime/VM.cpp: (JSC::thunkGeneratorForIntrinsic): * tests/stress/math-clz32-basics.js: Added. (mathClz32OnInteger): (testMathClz32OnIntegers): (verifyMathClz32OnIntegerWithOtherTypes): (mathClz32OnDouble): (testMathClz32OnDoubles): (verifyMathClz32OnDoublesWithOtherTypes): (mathClz32NoArguments): (mathClz32TooManyArguments): (testMathClz32OnConstants): (mathClz32StructTransition): (Math.clz32): LayoutTests: Basic conformance tests. * js/Object-getOwnPropertyNames-expected.txt: * js/math-clz32-expected.txt: Added. * js/math-clz32.html: Renamed from LayoutTests/js/number-clz.html. * js/number-clz-expected.txt: Removed. * js/script-tests/Object-getOwnPropertyNames.js: * js/script-tests/math-clz32.js: Added. (objectConvertToString.toString): (objectRecordToStringCall.toString): (objectThrowOnToString.toString): (objectWithValueOf.valueOf): (objectThrowOnValueOf.valueOf): (objectThrowOnValueOf.toString): (objectRecordValueOfCall.valueOf): (objectRecordConversionCalls.toString): (objectRecordConversionCalls.valueOf): * js/script-tests/number-clz.js: Removed. Canonical link: https://commits.webkit.org/162224@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183358 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-04-26 19:55:18 +00:00
PASS Math.clz32() is 32
PASS Math.clz32(undefined) is 32
PASS Math.clz32(null) is 32
PASS Math.clz32("WebKit") is 32
PASS Math.clz32(Symbol("WebKit")) threw exception TypeError: Cannot convert a symbol to a number.
[JSC] Implement Math.clz32(), remove Number.clz() https://bugs.webkit.org/show_bug.cgi?id=144205 Reviewed by Michael Saboff. Source/JavaScriptCore: This patch adds the ES6 function Math.clz32(), and remove the non-standard Number.clz(). Number.clz() probably came from an older draft. The new function has a corresponding instrinsic: Clz32Intrinsic, and a corresponding DFG node: ArithClz32, optimized all the way to LLVM. * assembler/MacroAssemblerX86Common.h: (JSC::MacroAssemblerX86Common::countLeadingZeros32): * assembler/X86Assembler.h: (JSC::X86Assembler::bsr_rr): The x86 assembler did not have countLeadingZeros32() because there is no native CLZ instruction on that architecture. I have added the version with bsr + branches for the case of zero. An other popular version uses cmov to handle the case of zero. I kept it simple since the Assembler has no support for cmov. It is unlikely to matter much. If the code is hot enough, LLVM picks something good based on the surrounding code. * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): Constant handling + effect propagation. The node only produces integer (between 0 and 32). * dfg/DFGBackwardsPropagationPhase.cpp: (JSC::DFG::BackwardsPropagationPhase::propagate): Thanks to the definition of toUint32(), we can ignore plenty of details from doubles. * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::handleIntrinsic): * dfg/DFGClobberize.h: (JSC::DFG::clobberize): * dfg/DFGDoesGC.cpp: (JSC::DFG::doesGC): * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupNode): * dfg/DFGNodeType.h: * dfg/DFGPredictionPropagationPhase.cpp: (JSC::DFG::PredictionPropagationPhase::propagate): * dfg/DFGSafeToExecute.h: (JSC::DFG::safeToExecute): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileArithClz32): * dfg/DFGSpeculativeJIT.h: * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::compile): * ftl/FTLCapabilities.cpp: (JSC::FTL::canCompile): * ftl/FTLIntrinsicRepository.h: * ftl/FTLLowerDFGToLLVM.cpp: (JSC::FTL::LowerDFGToLLVM::compileNode): (JSC::FTL::LowerDFGToLLVM::compileArithClz32): * ftl/FTLOutput.h: (JSC::FTL::Output::ctlz32): * jit/ThunkGenerators.cpp: (JSC::clz32ThunkGenerator): * jit/ThunkGenerators.h: * runtime/Intrinsic.h: * runtime/MathCommon.h: (JSC::clz32): Fun fact: InstCombine does not recognize this pattern to eliminate the branch which makes our FTL version better than the C version. * runtime/MathObject.cpp: (JSC::MathObject::finishCreation): (JSC::mathProtoFuncClz32): * runtime/NumberPrototype.cpp: (JSC::clz): Deleted. (JSC::numberProtoFuncClz): Deleted. * runtime/VM.cpp: (JSC::thunkGeneratorForIntrinsic): * tests/stress/math-clz32-basics.js: Added. (mathClz32OnInteger): (testMathClz32OnIntegers): (verifyMathClz32OnIntegerWithOtherTypes): (mathClz32OnDouble): (testMathClz32OnDoubles): (verifyMathClz32OnDoublesWithOtherTypes): (mathClz32NoArguments): (mathClz32TooManyArguments): (testMathClz32OnConstants): (mathClz32StructTransition): (Math.clz32): LayoutTests: Basic conformance tests. * js/Object-getOwnPropertyNames-expected.txt: * js/math-clz32-expected.txt: Added. * js/math-clz32.html: Renamed from LayoutTests/js/number-clz.html. * js/number-clz-expected.txt: Removed. * js/script-tests/Object-getOwnPropertyNames.js: * js/script-tests/math-clz32.js: Added. (objectConvertToString.toString): (objectRecordToStringCall.toString): (objectThrowOnToString.toString): (objectWithValueOf.valueOf): (objectThrowOnValueOf.valueOf): (objectThrowOnValueOf.toString): (objectRecordValueOfCall.valueOf): (objectRecordConversionCalls.toString): (objectRecordConversionCalls.valueOf): * js/script-tests/number-clz.js: Removed. Canonical link: https://commits.webkit.org/162224@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183358 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-04-26 19:55:18 +00:00
PASS Math.clz32({ webkit: "awesome" }) is 32
PASS Math.clz32(objectConvertToString) is 25
PASS Math.clz32(objectRecordToStringCall) is 28
PASS objectRecordToStringCall.toStringCallCount is 1
PASS Math.clz32(objectThrowOnToString) threw exception No!.
PASS Math.clz32(objectWithValueOf) is 15
PASS Math.clz32(objectThrowOnValueOf) threw exception Nope!.
PASS Math.clz32(objectRecordValueOfCall) is 23
PASS objectRecordValueOfCall.valueOfCallCount is 1
PASS Math.clz32(objectRecordConversionCalls) is 15
PASS objectRecordConversionCalls.callList.toString() is "valueOf"
PASS successfullyParsed is true
TEST COMPLETE