summaryrefslogtreecommitdiffstats
path: root/Source/JavaScriptCore
diff options
context:
space:
mode:
authorKonstantin Tokarev <annulen@yandex.ru>2019-06-04 22:44:55 +0300
committerKonstantin Tokarev <annulen@yandex.ru>2019-06-04 22:45:21 +0300
commitc49326e942d7cc21f78fe187020dce73befdd935 (patch)
treefaf0927eeeff4c57e998902b2085d976e588ed2b /Source/JavaScriptCore
parent72cfbd7664f21fcc0e62b869a6b01bf73eb5e7da (diff)
Import WebKit commit 5ccca3a720f7c2251c4ac8b28f25bd73524081f0
Change-Id: Idfb37cd43929536d4c67d1fa5d8cb598e9c0ad7e Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/JavaScriptCore')
-rw-r--r--Source/JavaScriptCore/bytecode/Opcode.cpp16
-rw-r--r--Source/JavaScriptCore/bytecode/Opcode.h13
-rw-r--r--Source/JavaScriptCore/parser/Parser.cpp16
-rw-r--r--Source/JavaScriptCore/parser/Parser.h3
-rw-r--r--Source/JavaScriptCore/shell/PlatformQt.cmake2
5 files changed, 26 insertions, 24 deletions
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<int, int> leftPair = *(pair<int, int>*) left;
+ std::pair<int, int> leftPair = *(std::pair<int, int>*) left;
long long leftValue = OpcodeStats::opcodePairCounts[leftPair.first][leftPair.second];
- std::pair<int, int> rightPair = *(pair<int, int>*) right;
+ std::pair<int, int> rightPair = *(std::pair<int, int>*) right;
long long rightValue = OpcodeStats::opcodePairCounts[rightPair.first][rightPair.second];
if (leftValue < rightValue)
diff --git a/Source/JavaScriptCore/bytecode/Opcode.h b/Source/JavaScriptCore/bytecode/Opcode.h
index ee667c84f..21665c5f7 100644
--- a/Source/JavaScriptCore/bytecode/Opcode.h
+++ b/Source/JavaScriptCore/bytecode/Opcode.h
@@ -85,21 +85,8 @@ typedef void* Opcode;
typedef OpcodeID Opcode;
#endif
-#define PADDING_STRING " "
-#define PADDING_STRING_LENGTH static_cast<unsigned>(strlen(PADDING_STRING))
-
extern const char* const opcodeNames[];
-inline const char* padOpcodeName(OpcodeID op, unsigned width)
-{
- unsigned pad = width - strlen(opcodeNames[op]);
- pad = std::min(pad, PADDING_STRING_LENGTH);
- return PADDING_STRING + PADDING_STRING_LENGTH - pad;
-}
-
-#undef PADDING_STRING_LENGTH
-#undef PADDING_STRING
-
#if ENABLE(OPCODE_STATS)
struct OpcodeStats {
diff --git a/Source/JavaScriptCore/parser/Parser.cpp b/Source/JavaScriptCore/parser/Parser.cpp
index c66b74282..f4751616f 100644
--- a/Source/JavaScriptCore/parser/Parser.cpp
+++ b/Source/JavaScriptCore/parser/Parser.cpp
@@ -90,7 +90,7 @@ void Parser<LexerType>::logError(bool)
return;
StringPrintStream stream;
printUnexpectedTokenText(stream);
- setErrorMessage(stream.toString());
+ setErrorMessage(stream.toStringWithLatin1Fallback());
}
template <typename LexerType> template <typename A>
@@ -104,7 +104,7 @@ void Parser<LexerType>::logError(bool shouldPrintToken, const A& value1)
stream.print(". ");
}
stream.print(value1, ".");
- setErrorMessage(stream.toString());
+ setErrorMessage(stream.toStringWithLatin1Fallback());
}
template <typename LexerType> template <typename A, typename B>
@@ -118,7 +118,7 @@ void Parser<LexerType>::logError(bool shouldPrintToken, const A& value1, const B
stream.print(". ");
}
stream.print(value1, value2, ".");
- setErrorMessage(stream.toString());
+ setErrorMessage(stream.toStringWithLatin1Fallback());
}
template <typename LexerType> template <typename A, typename B, typename C>
@@ -132,7 +132,7 @@ void Parser<LexerType>::logError(bool shouldPrintToken, const A& value1, const B
stream.print(". ");
}
stream.print(value1, value2, value3, ".");
- setErrorMessage(stream.toString());
+ setErrorMessage(stream.toStringWithLatin1Fallback());
}
template <typename LexerType> template <typename A, typename B, typename C, typename D>
@@ -146,7 +146,7 @@ void Parser<LexerType>::logError(bool shouldPrintToken, const A& value1, const B
stream.print(". ");
}
stream.print(value1, value2, value3, value4, ".");
- setErrorMessage(stream.toString());
+ setErrorMessage(stream.toStringWithLatin1Fallback());
}
template <typename LexerType> template <typename A, typename B, typename C, typename D, typename E>
@@ -160,7 +160,7 @@ void Parser<LexerType>::logError(bool shouldPrintToken, const A& value1, const B
stream.print(". ");
}
stream.print(value1, value2, value3, value4, value5, ".");
- setErrorMessage(stream.toString());
+ setErrorMessage(stream.toStringWithLatin1Fallback());
}
template <typename LexerType> template <typename A, typename B, typename C, typename D, typename E, typename F>
@@ -174,7 +174,7 @@ void Parser<LexerType>::logError(bool shouldPrintToken, const A& value1, const B
stream.print(". ");
}
stream.print(value1, value2, value3, value4, value5, value6, ".");
- setErrorMessage(stream.toString());
+ setErrorMessage(stream.toStringWithLatin1Fallback());
}
template <typename LexerType> template <typename A, typename B, typename C, typename D, typename E, typename F, typename G>
@@ -188,7 +188,7 @@ void Parser<LexerType>::logError(bool shouldPrintToken, const A& value1, const B
stream.print(". ");
}
stream.print(value1, value2, value3, value4, value5, value6, value7, ".");
- setErrorMessage(stream.toString());
+ setErrorMessage(stream.toStringWithLatin1Fallback());
}
template <typename LexerType>
diff --git a/Source/JavaScriptCore/parser/Parser.h b/Source/JavaScriptCore/parser/Parser.h
index 02a726a56..bce94ba25 100644
--- a/Source/JavaScriptCore/parser/Parser.h
+++ b/Source/JavaScriptCore/parser/Parser.h
@@ -1114,7 +1114,10 @@ private:
void setErrorMessage(const String& message)
{
+ ASSERT_WITH_MESSAGE(!message.isEmpty(), "Attempted to set the empty string as an error message. Likely caused by invalid UTF8 used when creating the message.");
m_errorMessage = message;
+ if (m_errorMessage.isEmpty())
+ m_errorMessage = ASCIILiteral("Unparseable script");
}
NEVER_INLINE void logError(bool);
diff --git a/Source/JavaScriptCore/shell/PlatformQt.cmake b/Source/JavaScriptCore/shell/PlatformQt.cmake
index 55640eb3a..8d4b260c1 100644
--- a/Source/JavaScriptCore/shell/PlatformQt.cmake
+++ b/Source/JavaScriptCore/shell/PlatformQt.cmake
@@ -1,5 +1,5 @@
if (QT_STATIC_BUILD)
list(APPEND JSC_LIBRARIES
- ${DEPEND_STATIC_LIBS}
+ ${STATIC_LIB_DEPENDENCIES}
)
endif ()