haikuwebkit/LayoutTests/js/script-tests/dfg-uint8clampedarray.js

141 lines
3.0 KiB
JavaScript
Raw Permalink Normal View History

//@ noNoLLIntRunLayoutTest if $architecture == "arm"
Uint8ClampedArray support https://bugs.webkit.org/show_bug.cgi?id=74455 Reviewed by Filip Pizlo. Source/JavaScriptCore: * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/PredictedType.cpp: (JSC::predictionToString): (JSC::predictionFromClassInfo): * bytecode/PredictedType.h: (JSC::isUint8ClampedArrayPrediction): (JSC::isActionableMutableArrayPrediction): * dfg/DFGAbstractState.cpp: (JSC::DFG::AbstractState::initialize): (JSC::DFG::AbstractState::execute): * dfg/DFGNode.h: (JSC::DFG::Node::shouldSpeculateUint8ClampedArray): * dfg/DFGPropagator.cpp: (JSC::DFG::Propagator::propagateNodePredictions): (JSC::DFG::Propagator::fixupNode): (JSC::DFG::Propagator::performNodeCSE): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::checkArgumentTypes): (JSC::DFG::clampDoubleToByte): (JSC::DFG::compileClampIntegerToByte): (JSC::DFG::SpeculativeJIT::compilePutByValForByteArray): (JSC::DFG::SpeculativeJIT::compilePutByValForIntTypedArray): (JSC::DFG::SpeculativeJIT::compileGetIndexedPropertyStorage): * dfg/DFGSpeculativeJIT.h: * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::compile): * runtime/JSCell.h: * runtime/JSGlobalData.h: * wtf/Forward.h: * wtf/Uint8Array.h: * wtf/Uint8ClampedArray.h: Added. (WTF::Uint8ClampedArray::set): (WTF::Uint8ClampedArray::create): (WTF::Uint8ClampedArray::Uint8ClampedArray): (WTF::Uint8ClampedArray::subarray): Source/WebCore: Test: fast/js/dfg-uint8clampedarray.html * CMakeLists.txt: * DerivedSources.cpp: * DerivedSources.make: * DerivedSources.pri: * ForwardingHeaders/wtf/Uint8ClampedArray.h: Added. * GNUmakefile.list.am: * Target.pri: * UseJSC.cmake: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSBindingsAllInOne.cpp: * bindings/js/JSDOMWindowCustom.cpp: * bindings/js/JSUint8ClampedArrayCustom.cpp: Added. (WebCore::JSUint8ClampedArray::indexSetter): (WebCore::toJS): (WebCore::JSUint8ClampedArray::set): (WebCore::JSUint8ClampedArrayConstructor::constructJSUint8ClampedArray): * bindings/scripts/CodeGeneratorJS.pm: (IsTypedArrayType): (GenerateHeader): * html/canvas/Uint8ClampedArray.idl: Added. * page/DOMWindow.idl: Source/WTF: * WTF.pro: LayoutTests: * fast/canvas/webgl/array-unit-tests-expected.txt: * fast/canvas/webgl/array-unit-tests.html: * fast/dom/Window/script-tests/window-property-descriptors.js: * fast/dom/Window/window-properties.html: * fast/dom/script-tests/constructed-objects-prototypes.js: (constructorPropertiesOnWindow): * fast/dom/script-tests/prototype-inheritance-2.js: (constructorNamesForWindow): * fast/js/dfg-uint8clampedarray-expected.txt: Added. * fast/js/dfg-uint8clampedarray.html: Added. * fast/js/script-tests/dfg-uint8clampedarray.js: Added. (getter1): (setter1): (getter2): (setter2): (getter3): (setter3): (getter4): (setter4): (getters.getter1.a): (.a): (setters.setter1.a): (safeGetter): (safeSetter): * fast/js/script-tests/global-constructors.js: * platform/chromium/fast/canvas/webgl/array-unit-tests-expected.txt: Copied from LayoutTests/fast/canvas/webgl/array-unit-tests-expected.txt. * platform/chromium/test_expectations.txt: Canonical link: https://commits.webkit.org/93304@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@105217 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-01-18 01:11:16 +00:00
description(
"This tests that Uint8ClampedArrays work in the DFG."
);
function getter1(a, b) {
return a[b];
}
function setter1(a, b, c) {
a[b] = c;
}
function getter2(a, b) {
a = a.f;
return a[b];
}
function setter2(a, b, c) {
a = a.f;
a[b] = c;
}
function getter3(a, b) {
a = a.f;
b = b.f;
return a[b];
}
function setter3(a, b, c) {
a = a.f;
b = b.f;
c = c.f;
a[b] = c;
}
function getter4(p, a, b) {
var x = a.f;
var y = b.f;
if (p) {
return x[y];
} else {
return x[y + 1];
}
}
function setter4(p, a, b, c) {
var x = a.f;
var y = b.f;
var z = c.f;
if (p) {
x[y] = z;
} else {
x[y + 1] = z;
}
}
var True = true;
var Empty = "";
var getters = [
getter1,
function(a, b) { a = {f:a}; return eval(Empty + "getter2(a, b)"); },
function(a, b) { a = {f:a}; b = {f:b}; return eval(Empty + "getter3(a, b)"); },
function(a, b) { a = {f:a}; b = {f:b}; return eval(Empty + "getter4(True, a, b)"); }
];
var setters = [
setter1,
function(a, b, c) { a = {f:a}; return eval(Empty + "setter2(a, b, c)"); },
function(a, b, c) { a = {f:a}; b = {f:b}; c = {f:c}; return eval(Empty + "setter3(a, b, c)"); },
function(a, b, c) { a = {f:a}; b = {f:b}; c = {f:c}; return eval(Empty + "setter4(True, a, b, c)"); }
];
function safeGetter(a, b) {
return eval("a[\"\" + " + b + "]");
}
function safeSetter(a, b, c) {
return eval("a[\"\" + " + b + "] = c");
}
for (var si = 0; si < setters.length; ++si) {
var array = new Uint8ClampedArray(101);
var checkArray = new Uint8ClampedArray(101);
var indexOffset = 0;
var valueOffset = 0;
var getter = getters[gi];
var setter = setters[si];
for (var i = 0; i < 1000; ++i) {
if (i == 500) {
array = [];
checkArray = [];
}
if (i == 600)
indexOffset = 0.4;
if (i == 700)
valueOffset = 1000.5;
var a = array;
var checkA = checkArray;
var b = (i % 100) + indexOffset;
var c = i + valueOffset;
if (i % 2)
c = -c;
setter(a, b, c);
safeSetter(checkA, b, c);
shouldBe("safeGetter(a, " + b + ", " + c + ")", "" + safeGetter(checkA, b, c));
Uint8ClampedArray support https://bugs.webkit.org/show_bug.cgi?id=74455 Reviewed by Filip Pizlo. Source/JavaScriptCore: * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/PredictedType.cpp: (JSC::predictionToString): (JSC::predictionFromClassInfo): * bytecode/PredictedType.h: (JSC::isUint8ClampedArrayPrediction): (JSC::isActionableMutableArrayPrediction): * dfg/DFGAbstractState.cpp: (JSC::DFG::AbstractState::initialize): (JSC::DFG::AbstractState::execute): * dfg/DFGNode.h: (JSC::DFG::Node::shouldSpeculateUint8ClampedArray): * dfg/DFGPropagator.cpp: (JSC::DFG::Propagator::propagateNodePredictions): (JSC::DFG::Propagator::fixupNode): (JSC::DFG::Propagator::performNodeCSE): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::checkArgumentTypes): (JSC::DFG::clampDoubleToByte): (JSC::DFG::compileClampIntegerToByte): (JSC::DFG::SpeculativeJIT::compilePutByValForByteArray): (JSC::DFG::SpeculativeJIT::compilePutByValForIntTypedArray): (JSC::DFG::SpeculativeJIT::compileGetIndexedPropertyStorage): * dfg/DFGSpeculativeJIT.h: * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::compile): * runtime/JSCell.h: * runtime/JSGlobalData.h: * wtf/Forward.h: * wtf/Uint8Array.h: * wtf/Uint8ClampedArray.h: Added. (WTF::Uint8ClampedArray::set): (WTF::Uint8ClampedArray::create): (WTF::Uint8ClampedArray::Uint8ClampedArray): (WTF::Uint8ClampedArray::subarray): Source/WebCore: Test: fast/js/dfg-uint8clampedarray.html * CMakeLists.txt: * DerivedSources.cpp: * DerivedSources.make: * DerivedSources.pri: * ForwardingHeaders/wtf/Uint8ClampedArray.h: Added. * GNUmakefile.list.am: * Target.pri: * UseJSC.cmake: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSBindingsAllInOne.cpp: * bindings/js/JSDOMWindowCustom.cpp: * bindings/js/JSUint8ClampedArrayCustom.cpp: Added. (WebCore::JSUint8ClampedArray::indexSetter): (WebCore::toJS): (WebCore::JSUint8ClampedArray::set): (WebCore::JSUint8ClampedArrayConstructor::constructJSUint8ClampedArray): * bindings/scripts/CodeGeneratorJS.pm: (IsTypedArrayType): (GenerateHeader): * html/canvas/Uint8ClampedArray.idl: Added. * page/DOMWindow.idl: Source/WTF: * WTF.pro: LayoutTests: * fast/canvas/webgl/array-unit-tests-expected.txt: * fast/canvas/webgl/array-unit-tests.html: * fast/dom/Window/script-tests/window-property-descriptors.js: * fast/dom/Window/window-properties.html: * fast/dom/script-tests/constructed-objects-prototypes.js: (constructorPropertiesOnWindow): * fast/dom/script-tests/prototype-inheritance-2.js: (constructorNamesForWindow): * fast/js/dfg-uint8clampedarray-expected.txt: Added. * fast/js/dfg-uint8clampedarray.html: Added. * fast/js/script-tests/dfg-uint8clampedarray.js: Added. (getter1): (setter1): (getter2): (setter2): (getter3): (setter3): (getter4): (setter4): (getters.getter1.a): (.a): (setters.setter1.a): (safeGetter): (safeSetter): * fast/js/script-tests/global-constructors.js: * platform/chromium/fast/canvas/webgl/array-unit-tests-expected.txt: Copied from LayoutTests/fast/canvas/webgl/array-unit-tests-expected.txt. * platform/chromium/test_expectations.txt: Canonical link: https://commits.webkit.org/93304@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@105217 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-01-18 01:11:16 +00:00
}
}
for (var gi = 0; gi < getters.length; ++gi) {
var array = new Uint8ClampedArray(101);
var indexOffset = 0;
var valueOffset = 0;
var getter = getters[gi];
var setter = setters[si];
for (var i = 0; i < 1000; ++i) {
if (i == 500)
array = [];
if (i == 600)
indexOffset = 0.4;
if (i == 700)
valueOffset = 1000.5;
var a = array;
var b = (i % 100) + indexOffset;
var c = i + valueOffset;
if (i % 2)
c = -c;
safeSetter(a, b, c);
shouldBe("getter(a, " + b + ", " + c + ")", "" + safeGetter(a, b));
Uint8ClampedArray support https://bugs.webkit.org/show_bug.cgi?id=74455 Reviewed by Filip Pizlo. Source/JavaScriptCore: * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/PredictedType.cpp: (JSC::predictionToString): (JSC::predictionFromClassInfo): * bytecode/PredictedType.h: (JSC::isUint8ClampedArrayPrediction): (JSC::isActionableMutableArrayPrediction): * dfg/DFGAbstractState.cpp: (JSC::DFG::AbstractState::initialize): (JSC::DFG::AbstractState::execute): * dfg/DFGNode.h: (JSC::DFG::Node::shouldSpeculateUint8ClampedArray): * dfg/DFGPropagator.cpp: (JSC::DFG::Propagator::propagateNodePredictions): (JSC::DFG::Propagator::fixupNode): (JSC::DFG::Propagator::performNodeCSE): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::checkArgumentTypes): (JSC::DFG::clampDoubleToByte): (JSC::DFG::compileClampIntegerToByte): (JSC::DFG::SpeculativeJIT::compilePutByValForByteArray): (JSC::DFG::SpeculativeJIT::compilePutByValForIntTypedArray): (JSC::DFG::SpeculativeJIT::compileGetIndexedPropertyStorage): * dfg/DFGSpeculativeJIT.h: * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::compile): * runtime/JSCell.h: * runtime/JSGlobalData.h: * wtf/Forward.h: * wtf/Uint8Array.h: * wtf/Uint8ClampedArray.h: Added. (WTF::Uint8ClampedArray::set): (WTF::Uint8ClampedArray::create): (WTF::Uint8ClampedArray::Uint8ClampedArray): (WTF::Uint8ClampedArray::subarray): Source/WebCore: Test: fast/js/dfg-uint8clampedarray.html * CMakeLists.txt: * DerivedSources.cpp: * DerivedSources.make: * DerivedSources.pri: * ForwardingHeaders/wtf/Uint8ClampedArray.h: Added. * GNUmakefile.list.am: * Target.pri: * UseJSC.cmake: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSBindingsAllInOne.cpp: * bindings/js/JSDOMWindowCustom.cpp: * bindings/js/JSUint8ClampedArrayCustom.cpp: Added. (WebCore::JSUint8ClampedArray::indexSetter): (WebCore::toJS): (WebCore::JSUint8ClampedArray::set): (WebCore::JSUint8ClampedArrayConstructor::constructJSUint8ClampedArray): * bindings/scripts/CodeGeneratorJS.pm: (IsTypedArrayType): (GenerateHeader): * html/canvas/Uint8ClampedArray.idl: Added. * page/DOMWindow.idl: Source/WTF: * WTF.pro: LayoutTests: * fast/canvas/webgl/array-unit-tests-expected.txt: * fast/canvas/webgl/array-unit-tests.html: * fast/dom/Window/script-tests/window-property-descriptors.js: * fast/dom/Window/window-properties.html: * fast/dom/script-tests/constructed-objects-prototypes.js: (constructorPropertiesOnWindow): * fast/dom/script-tests/prototype-inheritance-2.js: (constructorNamesForWindow): * fast/js/dfg-uint8clampedarray-expected.txt: Added. * fast/js/dfg-uint8clampedarray.html: Added. * fast/js/script-tests/dfg-uint8clampedarray.js: Added. (getter1): (setter1): (getter2): (setter2): (getter3): (setter3): (getter4): (setter4): (getters.getter1.a): (.a): (setters.setter1.a): (safeGetter): (safeSetter): * fast/js/script-tests/global-constructors.js: * platform/chromium/fast/canvas/webgl/array-unit-tests-expected.txt: Copied from LayoutTests/fast/canvas/webgl/array-unit-tests-expected.txt. * platform/chromium/test_expectations.txt: Canonical link: https://commits.webkit.org/93304@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@105217 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-01-18 01:11:16 +00:00
}
}