From c49326e942d7cc21f78fe187020dce73befdd935 Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Tue, 4 Jun 2019 22:44:55 +0300 Subject: Import WebKit commit 5ccca3a720f7c2251c4ac8b28f25bd73524081f0 Change-Id: Idfb37cd43929536d4c67d1fa5d8cb598e9c0ad7e Reviewed-by: Konstantin Tokarev --- Source/JavaScriptCore/bytecode/Opcode.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'Source/JavaScriptCore/bytecode/Opcode.cpp') diff --git a/Source/JavaScriptCore/bytecode/Opcode.cpp b/Source/JavaScriptCore/bytecode/Opcode.cpp index 0d16dfc2f..25e857d76 100644 --- a/Source/JavaScriptCore/bytecode/Opcode.cpp +++ b/Source/JavaScriptCore/bytecode/Opcode.cpp @@ -49,6 +49,18 @@ const char* const opcodeNames[] = { #if ENABLE(OPCODE_STATS) +inline const char* padOpcodeName(OpcodeID op, unsigned width) +{ + auto padding = " "; + auto paddingLength = strlen(padding); + auto opcodeNameLength = strlen(opcodeNames[op]); + if (opcodeNameLength >= width) + return ""; + if (paddingLength + opcodeNameLength < width) + return padding; + return &padding[paddingLength + opcodeNameLength - width]; +} + long long OpcodeStats::opcodeCounts[numOpcodeIDs]; long long OpcodeStats::opcodePairCounts[numOpcodeIDs][numOpcodeIDs]; int OpcodeStats::lastOpcode = -1; @@ -80,9 +92,9 @@ static int compareOpcodeIndices(const void* left, const void* right) static int compareOpcodePairIndices(const void* left, const void* right) { - std::pair leftPair = *(pair*) left; + std::pair leftPair = *(std::pair*) left; long long leftValue = OpcodeStats::opcodePairCounts[leftPair.first][leftPair.second]; - std::pair rightPair = *(pair*) right; + std::pair rightPair = *(std::pair*) right; long long rightValue = OpcodeStats::opcodePairCounts[rightPair.first][rightPair.second]; if (leftValue < rightValue) -- cgit v1.2.1