mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 08:45:46 +00:00
Bug 798849 - fix uninitialized values in WebGL element array cache... and reenable accidentally disabled canvas mochitests (!!!) - r=jgilbert
This fixes Valgrind errors while running TestWebGLElementArrayCache. This also fixes the way we do content/canvas/test in the Makefiles, which had been broken by my attempt to enable compiled-code tests there (bug 732660). Since I still don't know how to do compiled-code tests there, I've disabled them. At least we have the rest of content/canvas/test back. Let's hope that no regression happened.
This commit is contained in:
parent
96fa8a04e3
commit
8ff3c36285
@ -12,7 +12,7 @@ include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
PARALLEL_DIRS = public src
|
||||
|
||||
TOOLS_DIRS += test
|
||||
TEST_DIRS += test
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
@ -146,7 +146,6 @@ public:
|
||||
, mLastInvalidatedLeaf(0)
|
||||
{
|
||||
ResizeToParentSize();
|
||||
Invalidate(0, mParent.ByteSize() - 1);
|
||||
}
|
||||
|
||||
T GlobalMaximum() const {
|
||||
@ -157,22 +156,22 @@ public:
|
||||
// returns the index of the parent node; if treeIndex=1 (the root node),
|
||||
// the return value is 0.
|
||||
static size_t ParentNode(size_t treeIndex) {
|
||||
MOZ_ASSERT(treeIndex);
|
||||
MOZ_ASSERT(treeIndex > 1);
|
||||
return treeIndex >> 1;
|
||||
}
|
||||
|
||||
static bool IsRightNode(size_t treeIndex) {
|
||||
MOZ_ASSERT(treeIndex);
|
||||
MOZ_ASSERT(treeIndex > 1);
|
||||
return treeIndex & 1;
|
||||
}
|
||||
|
||||
static bool IsLeftNode(size_t treeIndex) {
|
||||
MOZ_ASSERT(treeIndex);
|
||||
MOZ_ASSERT(treeIndex > 1);
|
||||
return !IsRightNode(treeIndex);
|
||||
}
|
||||
|
||||
static size_t SiblingNode(size_t treeIndex) {
|
||||
MOZ_ASSERT(treeIndex);
|
||||
MOZ_ASSERT(treeIndex > 1);
|
||||
return treeIndex ^ 1;
|
||||
}
|
||||
|
||||
@ -187,12 +186,12 @@ public:
|
||||
}
|
||||
|
||||
static size_t LeftNeighborNode(size_t treeIndex, size_t distance = 1) {
|
||||
MOZ_ASSERT(treeIndex);
|
||||
MOZ_ASSERT(treeIndex > 1);
|
||||
return treeIndex - distance;
|
||||
}
|
||||
|
||||
static size_t RightNeighborNode(size_t treeIndex, size_t distance = 1) {
|
||||
MOZ_ASSERT(treeIndex);
|
||||
MOZ_ASSERT(treeIndex > 1);
|
||||
return treeIndex + distance;
|
||||
}
|
||||
|
||||
@ -287,10 +286,18 @@ public:
|
||||
size_t numberOfElements = mParent.ByteSize() / sizeof(T);
|
||||
size_t requiredNumLeaves = (numberOfElements + sElementsPerLeaf - 1) / sElementsPerLeaf;
|
||||
|
||||
size_t oldNumLeaves = mNumLeaves;
|
||||
mNumLeaves = NextPowerOfTwo(requiredNumLeaves);
|
||||
Invalidate(0, mParent.ByteSize() - 1);
|
||||
|
||||
// see class comment for why we the tree storage size is 2 * mNumLeaves
|
||||
return mTreeData.SetLength(2 * mNumLeaves);
|
||||
if (!mTreeData.SetLength(2 * mNumLeaves)) {
|
||||
return false;
|
||||
}
|
||||
if (mNumLeaves != oldNumLeaves) {
|
||||
memset(mTreeData.Elements(), 0, mTreeData.Length() * sizeof(mTreeData[0]));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Invalidate(size_t firstByte, size_t lastByte);
|
||||
@ -380,23 +387,18 @@ void WebGLElementArrayCacheTree<T>::Update()
|
||||
|
||||
// Step #2: propagate the values up the tree. This is simply a matter of walking up
|
||||
// the tree and setting each node to the max of its two children.
|
||||
while (true) {
|
||||
|
||||
// fast-exit case where only one node is invalidated at the current level
|
||||
if (firstTreeIndex == lastTreeIndex) {
|
||||
size_t firstTreeIndexParent = ParentNode(firstTreeIndex);
|
||||
while (firstTreeIndexParent) {
|
||||
mTreeData[firstTreeIndexParent] = NS_MAX(mTreeData[firstTreeIndex], mTreeData[SiblingNode(firstTreeIndex)]);
|
||||
firstTreeIndex = firstTreeIndexParent;
|
||||
firstTreeIndexParent = ParentNode(firstTreeIndex);
|
||||
}
|
||||
break;
|
||||
}
|
||||
while (firstTreeIndex > 1) {
|
||||
|
||||
// move up 1 level
|
||||
firstTreeIndex = ParentNode(firstTreeIndex);
|
||||
lastTreeIndex = ParentNode(lastTreeIndex);
|
||||
|
||||
// fast-exit case where only one node is invalidated at the current level
|
||||
if (firstTreeIndex == lastTreeIndex) {
|
||||
mTreeData[firstTreeIndex] = NS_MAX(mTreeData[LeftChildNode(firstTreeIndex)], mTreeData[RightChildNode(firstTreeIndex)]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// initialize local iteration variables: child and parent.
|
||||
size_t child = LeftChildNode(firstTreeIndex);
|
||||
size_t parent = firstTreeIndex;
|
||||
|
@ -65,7 +65,7 @@ private:
|
||||
void InvalidateTrees(size_t firstByte, size_t lastByte);
|
||||
|
||||
template<typename T>
|
||||
friend class WebGLElementArrayCacheTree;
|
||||
friend struct WebGLElementArrayCacheTree;
|
||||
template<typename T>
|
||||
friend struct TreeForType;
|
||||
|
||||
|
@ -10,7 +10,7 @@ VPATH = @srcdir@
|
||||
relativesrcdir = @relativesrcdir@
|
||||
DIRS += webgl crossorigin
|
||||
|
||||
TOOLS_DIRS += compiled
|
||||
# TEST_DIRS += compiled
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
MOCHITEST_FILES = \
|
||||
|
@ -31,14 +31,11 @@ void VerifyImplFunction(bool condition, const char* file, int line)
|
||||
|
||||
void MakeRandomVector(nsTArray<uint8_t>& a, size_t size) {
|
||||
a.SetLength(size);
|
||||
// only the most-significant bits of rand() are reasonably random
|
||||
// 16 here is arbitrary, may fail on platforms where RAND_MAX is low,
|
||||
// but guarded by an assertion.
|
||||
enum { bitsToIgnore = 16 };
|
||||
MOZ_STATIC_ASSERT((unsigned int)(RAND_MAX) >> (8 + bitsToIgnore),
|
||||
"Didn't expect RAND_MAX to be so low");
|
||||
// only the most-significant bits of rand() are reasonably random.
|
||||
// RAND_MAX can be as low as 0x7fff, and we need 8 bits for the result, so we can only
|
||||
// ignore the 7 least significant bits.
|
||||
for (size_t i = 0; i < size; i++)
|
||||
a[i] = static_cast<uint8_t>((unsigned int)(rand()) >> bitsToIgnore);
|
||||
a[i] = static_cast<uint8_t>((unsigned int)(rand()) >> 7);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
Loading…
Reference in New Issue
Block a user