- Revision
- 277240
- Author
- [email protected]
- Date
- 2021-05-08 21:15:21 -0700 (Sat, 08 May 2021)
Log Message
Remove calls to the String::toInt family of functions from _javascript_Core
https://bugs.webkit.org/show_bug.cgi?id=225571
Reviewed by Sam Weinig.
* inspector/agents/InspectorDebuggerAgent.cpp:
(Inspector::parseLocation): Use parseIntegerAllowingTrailingJunk<JSC::SourceID>
instead of String::toIntPtr. There was no reason to parse the source ID as a
signed integer, and it's more elegant to parse the type we intend to store and
process, not a different but similar type.
(Inspector::InspectorDebuggerAgent::searchInContent): Ditto.
(Inspector::InspectorDebuggerAgent::getScriptSource): Ditto.
* inspector/agents/InspectorRuntimeAgent.cpp:
(Inspector::InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets): Use
parseInteger<uintptr_t> instead of String::toIntPtrStrict.
(Inspector::InspectorRuntimeAgent::getBasicBlocks): Use
parseIntegerAllowingTrailingJunk<uintptr_t> instead of String::toIntPtr.
* runtime/FuzzerPredictions.cpp:
(JSC::FuzzerPredictions::FuzzerPredictions): Use parseInteger<uint64_t>
instead of String::toUInt64Strict.
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (277239 => 277240)
--- trunk/Source/_javascript_Core/ChangeLog 2021-05-09 04:09:18 UTC (rev 277239)
+++ trunk/Source/_javascript_Core/ChangeLog 2021-05-09 04:15:21 UTC (rev 277240)
@@ -1,3 +1,28 @@
+2021-05-08 Darin Adler <[email protected]>
+
+ Remove calls to the String::toInt family of functions from _javascript_Core
+ https://bugs.webkit.org/show_bug.cgi?id=225571
+
+ Reviewed by Sam Weinig.
+
+ * inspector/agents/InspectorDebuggerAgent.cpp:
+ (Inspector::parseLocation): Use parseIntegerAllowingTrailingJunk<JSC::SourceID>
+ instead of String::toIntPtr. There was no reason to parse the source ID as a
+ signed integer, and it's more elegant to parse the type we intend to store and
+ process, not a different but similar type.
+ (Inspector::InspectorDebuggerAgent::searchInContent): Ditto.
+ (Inspector::InspectorDebuggerAgent::getScriptSource): Ditto.
+
+ * inspector/agents/InspectorRuntimeAgent.cpp:
+ (Inspector::InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets): Use
+ parseInteger<uintptr_t> instead of String::toIntPtrStrict.
+ (Inspector::InspectorRuntimeAgent::getBasicBlocks): Use
+ parseIntegerAllowingTrailingJunk<uintptr_t> instead of String::toIntPtr.
+
+ * runtime/FuzzerPredictions.cpp:
+ (JSC::FuzzerPredictions::FuzzerPredictions): Use parseInteger<uint64_t>
+ instead of String::toUInt64Strict.
+
2021-05-08 Ross Kirsling <[email protected]>
[JSC] Fix invalid exception checks after recent ErrorInstance changes
Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp (277239 => 277240)
--- trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp 2021-05-09 04:09:18 UTC (rev 277239)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp 2021-05-09 04:15:21 UTC (rev 277240)
@@ -44,6 +44,7 @@
#include <wtf/Function.h>
#include <wtf/JSONValues.h>
#include <wtf/Stopwatch.h>
+#include <wtf/text/StringToIntegerConversion.h>
#include <wtf/text/WTFString.h>
namespace Inspector {
@@ -533,7 +534,7 @@
return false;
}
- sourceID = scriptIDStr.toIntPtr();
+ sourceID = parseIntegerAllowingTrailingJunk<JSC::SourceID>(scriptIDStr).valueOr(0);
columnNumber = location.getInteger(Protocol::Debugger::Location::columnNumberKey).valueOr(0);
return true;
}
@@ -729,7 +730,7 @@
Protocol::ErrorStringOr<Ref<JSON::ArrayOf<Protocol::GenericTypes::SearchMatch>>> InspectorDebuggerAgent::searchInContent(const Protocol::Debugger::ScriptId& scriptId, const String& query, Optional<bool>&& caseSensitive, Optional<bool>&& isRegex)
{
- auto it = m_scripts.find(scriptId.toIntPtr());
+ auto it = m_scripts.find(parseIntegerAllowingTrailingJunk<JSC::SourceID>(scriptId).valueOr(0));
if (it == m_scripts.end())
return makeUnexpected("Missing script for given scriptId"_s);
@@ -738,7 +739,7 @@
Protocol::ErrorStringOr<String> InspectorDebuggerAgent::getScriptSource(const Protocol::Debugger::ScriptId& scriptId)
{
- auto it = m_scripts.find(scriptId.toIntPtr());
+ auto it = m_scripts.find(parseIntegerAllowingTrailingJunk<JSC::SourceID>(scriptId).valueOr(0));
if (it == m_scripts.end())
return makeUnexpected("Missing script for given scriptId");
Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.cpp (277239 => 277240)
--- trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.cpp 2021-05-09 04:09:18 UTC (rev 277239)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.cpp 2021-05-09 04:15:21 UTC (rev 277240)
@@ -44,6 +44,7 @@
#include "TypeProfiler.h"
#include "TypeProfilerLog.h"
#include <wtf/JSONValues.h>
+#include <wtf/text/StringToIntegerConversion.h>
namespace Inspector {
@@ -395,9 +396,7 @@
auto sourceIDString = location->getString(Protocol::Runtime::TypeLocation::sourceIDKey);
auto divot = location->getInteger(Protocol::Runtime::TypeLocation::divotKey).valueOr(0);
- bool okay;
- TypeLocation* typeLocation = m_vm.typeProfiler()->findLocation(divot, sourceIDString.toIntPtrStrict(&okay), static_cast<TypeProfilerSearchDescriptor>(descriptor), m_vm);
- ASSERT(okay);
+ auto typeLocation = m_vm.typeProfiler()->findLocation(divot, parseInteger<uintptr_t>(sourceIDString).value(), static_cast<TypeProfilerSearchDescriptor>(descriptor), m_vm);
RefPtr<TypeSet> typeSet;
if (typeLocation) {
@@ -504,7 +503,7 @@
return makeUnexpected("VM has no control flow information"_s);
auto basicBlocks = JSON::ArrayOf<Protocol::Runtime::BasicBlock>::create();
- for (const auto& block : m_vm.controlFlowProfiler()->getBasicBlocksForSourceID(sourceID.toIntPtr(), m_vm)) {
+ for (const auto& block : m_vm.controlFlowProfiler()->getBasicBlocksForSourceID(parseIntegerAllowingTrailingJunk<uintptr_t>(sourceID).valueOr(0), m_vm)) {
auto location = Protocol::Runtime::BasicBlock::create()
.setStartOffset(block.m_startOffset)
.setEndOffset(block.m_endOffset)
Modified: trunk/Source/_javascript_Core/runtime/FuzzerPredictions.cpp (277239 => 277240)
--- trunk/Source/_javascript_Core/runtime/FuzzerPredictions.cpp 2021-05-09 04:09:18 UTC (rev 277239)
+++ trunk/Source/_javascript_Core/runtime/FuzzerPredictions.cpp 2021-05-09 04:15:21 UTC (rev 277240)
@@ -26,6 +26,8 @@
#include "config.h"
#include "FuzzerPredictions.h"
+#include <wtf/text/StringToIntegerConversion.h>
+
namespace JSC {
static String readFileIntoString(const char* fileName)
@@ -75,11 +77,10 @@
RELEASE_ASSERT_WITH_MESSAGE(lineParts.size() == 2, "Expected line with two parts delimited by a colon. Found line with %zu parts.", lineParts.size());
const String& lookupKey = lineParts[0];
const String& predictionString = lineParts[1];
- bool ok;
- SpeculatedType prediction = predictionString.toUInt64Strict(&ok, 0x10);
- RELEASE_ASSERT_WITH_MESSAGE(ok, "Could not parse prediction from '%s'", predictionString.utf8().data());
- RELEASE_ASSERT(speculationChecked(prediction, SpecFullTop));
- m_predictions.set(lookupKey, prediction);
+ auto prediction = parseInteger<uint64_t>(predictionString, 0x10);
+ RELEASE_ASSERT_WITH_MESSAGE(prediction, "Could not parse prediction from '%s'", predictionString.utf8().data());
+ RELEASE_ASSERT(speculationChecked(*prediction, SpecFullTop));
+ m_predictions.set(lookupKey, *prediction);
}
}