aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRolf Eike Beer <eb@emlix.com>2018-09-07 11:52:55 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2018-09-13 12:47:15 +0000
commit624ced39e92ee98588a2f8bb7aa7111c4f67eb74 (patch)
tree29dfa78d8a0e5e7932d138cc431c4dd8125db4ba
parent321dcd297ca0fcc267977bfc29acdd2b29080181 (diff)
use WTF::roundUpToMultipleOf() instead of open coding it
Change-Id: I3d6bbfcf02748e03c653763175c1904b4c2c8604 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
-rw-r--r--src/qml/compiler/qv4compiler.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp
index d25913da6d..ede0f5cb86 100644
--- a/src/qml/compiler/qv4compiler.cpp
+++ b/src/qml/compiler/qv4compiler.cpp
@@ -380,8 +380,7 @@ void QV4::Compiler::JSUnitGenerator::writeFunction(char *f, QV4::Compiler::Conte
{
QV4::CompiledData::Function *function = (QV4::CompiledData::Function *)f;
- quint32 currentOffset = sizeof(QV4::CompiledData::Function);
- currentOffset = (currentOffset + 7) & ~quint32(0x7);
+ quint32 currentOffset = static_cast<quint32>(WTF::roundUpToMultipleOf(8, sizeof(*function)));
function->nameIndex = getStringId(irFunction->name);
function->flags = 0;
@@ -534,8 +533,7 @@ void QV4::Compiler::JSUnitGenerator::writeBlock(char *b, QV4::Compiler::Context
{
QV4::CompiledData::Block *block = reinterpret_cast<QV4::CompiledData::Block *>(b);
- quint32 currentOffset = sizeof(QV4::CompiledData::Block);
- currentOffset = (currentOffset + 7) & ~quint32(0x7);
+ quint32 currentOffset = static_cast<quint32>(WTF::roundUpToMultipleOf(8, sizeof(*block)));
block->sizeOfLocalTemporalDeadZone = irBlock->sizeOfLocalTemporalDeadZone;
block->nLocals = irBlock->locals.size();
@@ -605,19 +603,19 @@ QV4::CompiledData::Unit QV4::Compiler::JSUnitGenerator::generateHeader(QV4::Comp
*jsClassDataOffset = nextOffset;
nextOffset += jsClassData.size();
- nextOffset = (nextOffset + 7) & ~quint32(0x7);
+ nextOffset = static_cast<quint32>(WTF::roundUpToMultipleOf(8, nextOffset));
unit.translationTableSize = translations.count();
unit.offsetToTranslationTable = nextOffset;
nextOffset += unit.translationTableSize * sizeof(CompiledData::TranslationData);
- nextOffset = (nextOffset + 7) & ~quint32(0x7);
+ nextOffset = static_cast<quint32>(WTF::roundUpToMultipleOf(8, nextOffset));
const auto reserveExportTable = [&nextOffset](int count, quint32_le *tableSizePtr, quint32_le *offsetPtr) {
*tableSizePtr = count;
*offsetPtr = nextOffset;
nextOffset += count * sizeof(CompiledData::ExportEntry);
- nextOffset = (nextOffset + 7) & ~quint32(0x7);
+ nextOffset = static_cast<quint32>(WTF::roundUpToMultipleOf(8, nextOffset));
};
reserveExportTable(module->localExportEntries.count(), &unit.localExportEntryTableSize, &unit.offsetToLocalExportEntryTable);
@@ -627,13 +625,12 @@ QV4::CompiledData::Unit QV4::Compiler::JSUnitGenerator::generateHeader(QV4::Comp
unit.importEntryTableSize = module->importEntries.count();
unit.offsetToImportEntryTable = nextOffset;
nextOffset += unit.importEntryTableSize * sizeof(CompiledData::ImportEntry);
- nextOffset = (nextOffset + 7) & ~quint32(0x7);
-
+ nextOffset = static_cast<quint32>(WTF::roundUpToMultipleOf(8, nextOffset));
unit.moduleRequestTableSize = module->moduleRequests.count();
unit.offsetToModuleRequestTable = nextOffset;
nextOffset += unit.moduleRequestTableSize * sizeof(uint);
- nextOffset = (nextOffset + 7) & ~quint32(0x7);
+ nextOffset = static_cast<quint32>(WTF::roundUpToMultipleOf(8, nextOffset));
quint32 functionSize = 0;
for (int i = 0; i < module->functions.size(); ++i) {