mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-26 04:22:30 -10:00
The bulk of this commit was generated with a script, executed at the top
level of a typical source code checkout. The only non-machine-generated
part was modifying MFBT's moz.build to reflect the new naming.
CLOSED TREE makes big refactorings like this a piece of cake.
# The main substitution.
find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \
xargs perl -p -i -e '
s/nsRefPtr\.h/RefPtr\.h/g; # handle includes
s/nsRefPtr ?</RefPtr</g; # handle declarations and variables
'
# Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h.
perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h
# Handle nsRefPtr.h itself, a couple places that define constructors
# from nsRefPtr, and code generators specially. We do this here, rather
# than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename
# things like nsRefPtrHashtable.
perl -p -i -e 's/nsRefPtr/RefPtr/g' \
mfbt/nsRefPtr.h \
xpcom/glue/nsCOMPtr.h \
xpcom/base/OwningNonNull.h \
ipc/ipdl/ipdl/lower.py \
ipc/ipdl/ipdl/builtin.py \
dom/bindings/Codegen.py \
python/lldbutils/lldbutils/utils.py
# In our indiscriminate substitution above, we renamed
# nsRefPtrGetterAddRefs, the class behind getter_AddRefs. Fix that up.
find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \
xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g'
if [ -d .git ]; then
git mv mfbt/nsRefPtr.h mfbt/RefPtr.h
else
hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h
fi
76 lines
2.6 KiB
C++
76 lines
2.6 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
#include "ProfileEntry.h"
|
|
#include "ThreadProfile.h"
|
|
|
|
// Make sure we can initialize our ThreadProfile
|
|
TEST(ThreadProfile, Initialization) {
|
|
PseudoStack* stack = PseudoStack::create();
|
|
Thread::tid_t tid = 1000;
|
|
ThreadInfo info("testThread", tid, true, stack, nullptr);
|
|
RefPtr<ProfileBuffer> pb = new ProfileBuffer(10);
|
|
ThreadProfile tp(&info, pb);
|
|
}
|
|
|
|
// Make sure we can record one tag and read it
|
|
TEST(ThreadProfile, InsertOneTag) {
|
|
PseudoStack* stack = PseudoStack::create();
|
|
Thread::tid_t tid = 1000;
|
|
ThreadInfo info("testThread", tid, true, stack, nullptr);
|
|
RefPtr<ProfileBuffer> pb = new ProfileBuffer(10);
|
|
pb->addTag(ProfileEntry('t', 123.1));
|
|
ASSERT_TRUE(pb->mEntries != nullptr);
|
|
ASSERT_TRUE(pb->mEntries[pb->mReadPos].mTagName == 't');
|
|
ASSERT_TRUE(pb->mEntries[pb->mReadPos].mTagDouble == 123.1);
|
|
}
|
|
|
|
// See if we can insert some tags
|
|
TEST(ThreadProfile, InsertTagsNoWrap) {
|
|
PseudoStack* stack = PseudoStack::create();
|
|
Thread::tid_t tid = 1000;
|
|
ThreadInfo info("testThread", tid, true, stack, nullptr);
|
|
RefPtr<ProfileBuffer> pb = new ProfileBuffer(100);
|
|
int test_size = 50;
|
|
for (int i = 0; i < test_size; i++) {
|
|
pb->addTag(ProfileEntry('t', i));
|
|
}
|
|
ASSERT_TRUE(pb->mEntries != nullptr);
|
|
int readPos = pb->mReadPos;
|
|
while (readPos != pb->mWritePos) {
|
|
ASSERT_TRUE(pb->mEntries[readPos].mTagName == 't');
|
|
ASSERT_TRUE(pb->mEntries[readPos].mTagInt == readPos);
|
|
readPos = (readPos + 1) % pb->mEntrySize;
|
|
}
|
|
}
|
|
|
|
// See if wrapping works as it should in the basic case
|
|
TEST(ThreadProfile, InsertTagsWrap) {
|
|
PseudoStack* stack = PseudoStack::create();
|
|
Thread::tid_t tid = 1000;
|
|
// we can fit only 24 tags in this buffer because of the empty slot
|
|
int tags = 24;
|
|
int buffer_size = tags + 1;
|
|
ThreadInfo info("testThread", tid, true, stack, nullptr);
|
|
RefPtr<ProfileBuffer> pb = new ProfileBuffer(buffer_size);
|
|
int test_size = 43;
|
|
for (int i = 0; i < test_size; i++) {
|
|
pb->addTag(ProfileEntry('t', i));
|
|
}
|
|
ASSERT_TRUE(pb->mEntries != nullptr);
|
|
int readPos = pb->mReadPos;
|
|
int ctr = 0;
|
|
while (readPos != pb->mWritePos) {
|
|
ASSERT_TRUE(pb->mEntries[readPos].mTagName == 't');
|
|
// the first few tags were discarded when we wrapped
|
|
ASSERT_TRUE(pb->mEntries[readPos].mTagInt == ctr + (test_size - tags));
|
|
ctr++;
|
|
readPos = (readPos + 1) % pb->mEntrySize;
|
|
}
|
|
}
|
|
|