Diff
Modified: trunk/Source/_javascript_Core/CMakeLists.txt (283902 => 283903)
--- trunk/Source/_javascript_Core/CMakeLists.txt 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/CMakeLists.txt 2021-10-11 16:58:40 UTC (rev 283903)
@@ -664,6 +664,7 @@
bytecode/PutByIdFlags.h
bytecode/SetPrivateBrandStatus.h
bytecode/SetPrivateBrandVariant.h
+ bytecode/SourceID.h
bytecode/SpeculatedType.h
bytecode/StructureSet.h
bytecode/SuperSampler.h
Modified: trunk/Source/_javascript_Core/ChangeLog (283902 => 283903)
--- trunk/Source/_javascript_Core/ChangeLog 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/ChangeLog 2021-10-11 16:58:40 UTC (rev 283903)
@@ -1,3 +1,80 @@
+2021-10-11 Keith Miller <[email protected]>
+
+ SourceID should have a type name and only be 32-bits
+ https://bugs.webkit.org/show_bug.cgi?id=231436
+
+ Reviewed by Filip Pizlo.
+
+ This patch gives SourceID a proper type name and shrinks it to
+ 32-bits on 64-bit systems. Shrinking the size makes room on
+ SourceProvider for metadata in a future patch I'm working on.
+ It's also pretty unlikely that any system has more than ~4 billion
+ script tags, evals, wasm modules so shinking the size is unlikely
+ to cause any debugger/profiling issues.
+
+ * CMakeLists.txt:
+ * _javascript_Core.xcodeproj/project.pbxproj:
+ * bytecode/TypeLocation.h:
+ * debugger/Debugger.cpp:
+ (JSC::Debugger::toggleBreakpoint):
+ (JSC::Debugger::pauseIfNeeded):
+ * debugger/DebuggerLocation.h:
+ (JSC::DebuggerLocation::DebuggerLocation):
+ * debugger/DebuggerPrimitives.h:
+ * inspector/_javascript_CallFrame.h:
+ (Inspector::_javascript_CallFrame::sourceID const):
+ * inspector/ScriptCallStackFactory.cpp:
+ (Inspector::CreateScriptCallStackFunctor::operator() const):
+ (Inspector::createScriptCallStackFromException):
+ * interpreter/StackVisitor.cpp:
+ (JSC::StackVisitor::Frame::sourceID):
+ * interpreter/StackVisitor.h:
+ * parser/Nodes.h:
+ (JSC::ScopeNode::sourceID const):
+ * parser/SourceCode.h:
+ (JSC::SourceCode::SourceCode):
+ (JSC::SourceCode::firstLine const):
+ (JSC::SourceCode::startColumn const):
+ (JSC::SourceCode::providerID const):
+ (JSC::SourceCode::provider const):
+ (JSC::SourceCode::operator== const):
+ (JSC::SourceCode::operator!= const):
+ (JSC::makeSource):
+ (JSC::SourceCode::subExpression const):
+ * parser/SourceProvider.cpp:
+ (JSC::SourceProvider::getID):
+ * parser/SourceProvider.h:
+ (JSC::SourceProvider::asID):
+ * runtime/ControlFlowProfiler.cpp:
+ (JSC::ControlFlowProfiler::getBasicBlockLocation):
+ (JSC::ControlFlowProfiler::getBasicBlocksForSourceID const):
+ (JSC::ControlFlowProfiler::hasBasicBlockAtTextOffsetBeenExecuted):
+ (JSC::ControlFlowProfiler::basicBlockExecutionCountAtTextOffset):
+ * runtime/ControlFlowProfiler.h:
+ * runtime/FunctionHasExecutedCache.cpp:
+ (JSC::FunctionHasExecutedCache::hasExecutedAtOffset):
+ (JSC::FunctionHasExecutedCache::insertUnexecutedRange):
+ (JSC::FunctionHasExecutedCache::removeUnexecutedRange):
+ (JSC::FunctionHasExecutedCache::getFunctionRanges):
+ * runtime/FunctionHasExecutedCache.h:
+ * runtime/SamplingProfiler.cpp:
+ (JSC::SamplingProfiler::StackFrame::sourceID):
+ * runtime/SamplingProfiler.h:
+ * runtime/ScriptExecutable.h:
+ (JSC::ScriptExecutable::sourceID const):
+ * runtime/StackFrame.cpp:
+ (JSC::StackFrame::sourceID const):
+ * runtime/StackFrame.h:
+ * runtime/TypeLocationCache.cpp:
+ (JSC::TypeLocationCache::getTypeLocation):
+ * runtime/TypeLocationCache.h:
+ * runtime/TypeProfiler.cpp:
+ (JSC::TypeProfiler::typeInformationForExpressionAtOffset):
+ (JSC::TypeProfiler::findLocation):
+ * runtime/TypeProfiler.h:
+ (JSC::QueryKey::QueryKey):
+ (JSC::QueryKey::isHashTableDeletedValue const):
+
2021-10-11 Geza Lore <[email protected]>
[JSC][32bit] Fix profiling in baseline
Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (283902 => 283903)
--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2021-10-11 16:58:40 UTC (rev 283903)
@@ -947,6 +947,7 @@
534E03541E53BD2900213F64 /* IntrinsicGetterAccessCase.h in Headers */ = {isa = PBXBuildFile; fileRef = 534E03531E53BD2900213F64 /* IntrinsicGetterAccessCase.h */; };
534E03561E53BEDE00213F64 /* ProxyableAccessCase.h in Headers */ = {isa = PBXBuildFile; fileRef = 534E03551E53BEDE00213F64 /* ProxyableAccessCase.h */; };
534E03581E53BF2F00213F64 /* GetterSetterAccessCase.h in Headers */ = {isa = PBXBuildFile; fileRef = 534E03571E53BF2F00213F64 /* GetterSetterAccessCase.h */; };
+ 5350356527147E5A00EC1A7E /* SourceID.h in Headers */ = {isa = PBXBuildFile; fileRef = 5350356427147E5900EC1A7E /* SourceID.h */; settings = {ATTRIBUTES = (Private, ); }; };
53529A4C1C457B75000B49C6 /* APIUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 53529A4B1C457B75000B49C6 /* APIUtils.h */; };
535557141D9D9EA5006D583B /* WasmMemory.h in Headers */ = {isa = PBXBuildFile; fileRef = 535557131D9D9EA5006D583B /* WasmMemory.h */; settings = {ATTRIBUTES = (Private, ); }; };
535C24611F78928E006EC40E /* create_regex_tables in Headers */ = {isa = PBXBuildFile; fileRef = A718F8211178EB4B002465A7 /* create_regex_tables */; };
@@ -3765,6 +3766,7 @@
534E03531E53BD2900213F64 /* IntrinsicGetterAccessCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntrinsicGetterAccessCase.h; sourceTree = "<group>"; };
534E03551E53BEDE00213F64 /* ProxyableAccessCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProxyableAccessCase.h; sourceTree = "<group>"; };
534E03571E53BF2F00213F64 /* GetterSetterAccessCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GetterSetterAccessCase.h; sourceTree = "<group>"; };
+ 5350356427147E5900EC1A7E /* SourceID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceID.h; sourceTree = "<group>"; };
53529A4B1C457B75000B49C6 /* APIUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIUtils.h; sourceTree = "<group>"; };
535557131D9D9EA5006D583B /* WasmMemory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmMemory.h; sourceTree = "<group>"; };
535557151D9DFA32006D583B /* WasmMemory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmMemory.cpp; sourceTree = "<group>"; };
@@ -8822,6 +8824,7 @@
865DA0C725B8960C00875772 /* SetPrivateBrandStatus.h */,
865DA0C625B8959E00875772 /* SetPrivateBrandVariant.cpp */,
865DA0C425B8957400875772 /* SetPrivateBrandVariant.h */,
+ 5350356427147E5900EC1A7E /* SourceID.h */,
0FD82E84141F3FDA00179C94 /* SpeculatedType.cpp */,
0FD82E4F141DAEA100179C94 /* SpeculatedType.h */,
0FB438A219270B1D00E1FBC9 /* StructureSet.cpp */,
@@ -10729,6 +10732,7 @@
E3F23A7F1ECF13EE00978D99 /* SnippetSlowPathCalls.h in Headers */,
14201D591DECF26A00904BD3 /* SourceCode.h in Headers */,
70B791911C024A13002481E2 /* SourceCodeKey.h in Headers */,
+ 5350356527147E5A00EC1A7E /* SourceID.h in Headers */,
2D342F36F7244096804ADB24 /* SourceOrigin.h in Headers */,
BC18C4630E16F5CD00B34460 /* SourceProvider.h in Headers */,
E49DC16C12EF294E00184A1F /* SourceProviderCache.h in Headers */,
Copied: trunk/Source/_javascript_Core/bytecode/SourceID.h (from rev 283902, trunk/Source/_javascript_Core/debugger/DebuggerPrimitives.h) (0 => 283903)
--- trunk/Source/_javascript_Core/bytecode/SourceID.h (rev 0)
+++ trunk/Source/_javascript_Core/bytecode/SourceID.h 2021-10-11 16:58:40 UTC (rev 283903)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace JSC {
+
+using SourceID = uint32_t;
+
+} // namespace JSC
Modified: trunk/Source/_javascript_Core/bytecode/TypeLocation.h (283902 => 283903)
--- trunk/Source/_javascript_Core/bytecode/TypeLocation.h 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/bytecode/TypeLocation.h 2021-10-11 16:58:40 UTC (rev 283903)
@@ -50,7 +50,7 @@
GlobalVariableID m_globalVariableID;
RefPtr<TypeSet> m_instructionTypeSet;
RefPtr<TypeSet> m_globalTypeSet;
- intptr_t m_sourceID;
+ SourceID m_sourceID;
unsigned m_divotStart;
unsigned m_divotEnd;
unsigned m_divotForFunctionOffsetIfReturnStatement;
Modified: trunk/Source/_javascript_Core/debugger/Debugger.cpp (283902 => 283903)
--- trunk/Source/_javascript_Core/debugger/Debugger.cpp 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/debugger/Debugger.cpp 2021-10-11 16:58:40 UTC (rev 283903)
@@ -350,7 +350,7 @@
ScriptExecutable* executable = codeBlock->ownerExecutable();
- SourceID sourceID = static_cast<SourceID>(executable->sourceID());
+ SourceID sourceID = executable->sourceID();
if (breakpoint.sourceID() != sourceID)
return;
@@ -875,7 +875,7 @@
if (m_suppressAllPauses)
return;
- intptr_t sourceID = DebuggerCallFrame::sourceIDForCallFrame(m_currentCallFrame);
+ SourceID sourceID = DebuggerCallFrame::sourceIDForCallFrame(m_currentCallFrame);
auto blackboxTypeIterator = m_blackboxedScripts.find(sourceID);
if (blackboxTypeIterator != m_blackboxedScripts.end() && blackboxTypeIterator->value == BlackboxType::Ignored)
Modified: trunk/Source/_javascript_Core/debugger/DebuggerLocation.h (283902 => 283903)
--- trunk/Source/_javascript_Core/debugger/DebuggerLocation.h 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/debugger/DebuggerLocation.h 2021-10-11 16:58:40 UTC (rev 283903)
@@ -35,7 +35,7 @@
struct DebuggerLocation {
DebuggerLocation() { }
- DebuggerLocation(intptr_t sourceID, unsigned line, unsigned column)
+ DebuggerLocation(SourceID sourceID, unsigned line, unsigned column)
: sourceID(sourceID)
, line(line)
, column(column)
@@ -43,7 +43,7 @@
DebuggerLocation(ScriptExecutable*);
- intptr_t sourceID { noSourceID };
+ SourceID sourceID { noSourceID };
unsigned line { 0 };
unsigned column { 0 };
};
Modified: trunk/Source/_javascript_Core/debugger/DebuggerPrimitives.h (283902 => 283903)
--- trunk/Source/_javascript_Core/debugger/DebuggerPrimitives.h 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/debugger/DebuggerPrimitives.h 2021-10-11 16:58:40 UTC (rev 283903)
@@ -25,11 +25,11 @@
#pragma once
+#include "SourceID.h"
#include <stddef.h>
namespace JSC {
-using SourceID = size_t;
constexpr SourceID noSourceID = 0;
using BreakpointID = size_t;
Modified: trunk/Source/_javascript_Core/inspector/_javascript_CallFrame.h (283902 => 283903)
--- trunk/Source/_javascript_Core/inspector/_javascript_CallFrame.h 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/inspector/_javascript_CallFrame.h 2021-10-11 16:58:40 UTC (rev 283903)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008, 2013-2014 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008-2021 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -41,7 +41,7 @@
}
_javascript_CallFrame* caller();
- intptr_t sourceID() const { return m_debuggerCallFrame->sourceID(); }
+ JSC::SourceID sourceID() const { return m_debuggerCallFrame->sourceID(); }
const TextPosition position() const { return m_debuggerCallFrame->position(); }
int line() const { return m_debuggerCallFrame->line(); }
int column() const { return m_debuggerCallFrame->column(); }
Modified: trunk/Source/_javascript_Core/inspector/ScriptCallStackFactory.cpp (283902 => 283903)
--- trunk/Source/_javascript_Core/inspector/ScriptCallStackFactory.cpp 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/inspector/ScriptCallStackFactory.cpp 2021-10-11 16:58:40 UTC (rev 283903)
@@ -62,7 +62,7 @@
unsigned line;
unsigned column;
visitor->computeLineAndColumn(line, column);
- m_frames.append(ScriptCallFrame(visitor->functionName(), visitor->sourceURL(), static_cast<SourceID>(visitor->sourceID()), line, column));
+ m_frames.append(ScriptCallFrame(visitor->functionName(), visitor->sourceURL(), visitor->sourceID(), line, column));
m_remainingCapacityForFrameCapture--;
return StackVisitor::Continue;
@@ -160,7 +160,7 @@
unsigned column;
stackTrace[i].computeLineAndColumn(line, column);
String functionName = stackTrace[i].functionName(vm);
- frames.append(ScriptCallFrame(functionName, stackTrace[i].sourceURL(), static_cast<SourceID>(stackTrace[i].sourceID()), line, column));
+ frames.append(ScriptCallFrame(functionName, stackTrace[i].sourceURL(), stackTrace[i].sourceID(), line, column));
}
// Fallback to getting at least the line and sourceURL from the exception object if it has values and the exceptionStack doesn't.
Modified: trunk/Source/_javascript_Core/interpreter/StackVisitor.cpp (283902 => 283903)
--- trunk/Source/_javascript_Core/interpreter/StackVisitor.cpp 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/interpreter/StackVisitor.cpp 2021-10-11 16:58:40 UTC (rev 283903)
@@ -348,7 +348,7 @@
return makeString(functionName, separator, sourceURL, ':', line, ':', column);
}
-intptr_t StackVisitor::Frame::sourceID()
+SourceID StackVisitor::Frame::sourceID()
{
if (CodeBlock* codeBlock = this->codeBlock())
return codeBlock->ownerExecutable()->sourceID();
Modified: trunk/Source/_javascript_Core/interpreter/StackVisitor.h (283902 => 283903)
--- trunk/Source/_javascript_Core/interpreter/StackVisitor.h 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/interpreter/StackVisitor.h 2021-10-11 16:58:40 UTC (rev 283903)
@@ -27,6 +27,7 @@
#include "BytecodeIndex.h"
#include "CalleeBits.h"
+#include "SourceID.h"
#include "WasmIndexOrName.h"
#include <wtf/Function.h>
#include <wtf/Indenter.h>
@@ -87,7 +88,7 @@
JS_EXPORT_PRIVATE String sourceURL() const;
JS_EXPORT_PRIVATE String toString() const;
- JS_EXPORT_PRIVATE intptr_t sourceID();
+ JS_EXPORT_PRIVATE SourceID sourceID();
CodeType codeType() const;
bool hasLineAndColumnInfo() const;
Modified: trunk/Source/_javascript_Core/parser/Nodes.h (283902 => 283903)
--- trunk/Source/_javascript_Core/parser/Nodes.h 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/parser/Nodes.h 2021-10-11 16:58:40 UTC (rev 283903)
@@ -1898,7 +1898,7 @@
ScopeNode(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, const SourceCode&, SourceElements*, VariableEnvironment&&, FunctionStack&&, VariableEnvironment&&, UniquedStringImplPtrSet&&, CodeFeatures, LexicalScopeFeatures, InnerArrowFunctionCodeFeatures, int numConstants);
const SourceCode& source() const { return m_source; }
- intptr_t sourceID() const { return m_source.providerID(); }
+ SourceID sourceID() const { return m_source.providerID(); }
int startLine() const { return m_startLineNumber; }
int startStartOffset() const { return m_startStartOffset; }
Modified: trunk/Source/_javascript_Core/parser/SourceCode.h (283902 => 283903)
--- trunk/Source/_javascript_Core/parser/SourceCode.h 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/parser/SourceCode.h 2021-10-11 16:58:40 UTC (rev 283903)
@@ -32,79 +32,79 @@
namespace JSC {
- class SourceCode : public UnlinkedSourceCode {
- friend class CachedSourceCode;
- friend class CachedSourceCodeWithoutProvider;
+class SourceCode : public UnlinkedSourceCode {
+ friend class CachedSourceCode;
+ friend class CachedSourceCodeWithoutProvider;
- public:
- SourceCode()
- : UnlinkedSourceCode()
- , m_firstLine(OrdinalNumber::beforeFirst())
- , m_startColumn(OrdinalNumber::beforeFirst())
- {
- }
+public:
+ SourceCode()
+ : UnlinkedSourceCode()
+ , m_firstLine(OrdinalNumber::beforeFirst())
+ , m_startColumn(OrdinalNumber::beforeFirst())
+ {
+ }
- SourceCode(Ref<SourceProvider>&& provider)
- : UnlinkedSourceCode(WTFMove(provider))
- {
- }
+ SourceCode(Ref<SourceProvider>&& provider)
+ : UnlinkedSourceCode(WTFMove(provider))
+ {
+ }
- SourceCode(Ref<SourceProvider>&& provider, int firstLine, int startColumn)
- : UnlinkedSourceCode(WTFMove(provider))
- , m_firstLine(OrdinalNumber::fromOneBasedInt(std::max(firstLine, 1)))
- , m_startColumn(OrdinalNumber::fromOneBasedInt(std::max(startColumn, 1)))
- {
- }
+ SourceCode(Ref<SourceProvider>&& provider, int firstLine, int startColumn)
+ : UnlinkedSourceCode(WTFMove(provider))
+ , m_firstLine(OrdinalNumber::fromOneBasedInt(std::max(firstLine, 1)))
+ , m_startColumn(OrdinalNumber::fromOneBasedInt(std::max(startColumn, 1)))
+ {
+ }
- SourceCode(RefPtr<SourceProvider>&& provider, int startOffset, int endOffset, int firstLine, int startColumn)
- : UnlinkedSourceCode(WTFMove(provider), startOffset, endOffset)
- , m_firstLine(OrdinalNumber::fromOneBasedInt(std::max(firstLine, 1)))
- , m_startColumn(OrdinalNumber::fromOneBasedInt(std::max(startColumn, 1)))
- {
- }
+ SourceCode(RefPtr<SourceProvider>&& provider, int startOffset, int endOffset, int firstLine, int startColumn)
+ : UnlinkedSourceCode(WTFMove(provider), startOffset, endOffset)
+ , m_firstLine(OrdinalNumber::fromOneBasedInt(std::max(firstLine, 1)))
+ , m_startColumn(OrdinalNumber::fromOneBasedInt(std::max(startColumn, 1)))
+ {
+ }
- OrdinalNumber firstLine() const { return m_firstLine; }
- OrdinalNumber startColumn() const { return m_startColumn; }
+ OrdinalNumber firstLine() const { return m_firstLine; }
+ OrdinalNumber startColumn() const { return m_startColumn; }
- intptr_t providerID() const
- {
- if (!m_provider)
- return SourceProvider::nullID;
- return m_provider->asID();
- }
+ SourceID providerID() const
+ {
+ if (!m_provider)
+ return SourceProvider::nullID;
+ return m_provider->asID();
+ }
- SourceProvider* provider() const { return m_provider.get(); }
+ SourceProvider* provider() const { return m_provider.get(); }
- SourceCode subExpression(unsigned openBrace, unsigned closeBrace, int firstLine, int startColumn) const;
+ SourceCode subExpression(unsigned openBrace, unsigned closeBrace, int firstLine, int startColumn) const;
- bool operator==(const SourceCode& other) const
- {
- return m_firstLine == other.m_firstLine
- && m_startColumn == other.m_startColumn
- && m_provider == other.m_provider
- && m_startOffset == other.m_startOffset
- && m_endOffset == other.m_endOffset;
- }
-
- bool operator!=(const SourceCode& other) const
- {
- return !(*this == other);
- }
-
- private:
- OrdinalNumber m_firstLine;
- OrdinalNumber m_startColumn;
- };
-
- inline SourceCode makeSource(const String& source, const SourceOrigin& sourceOrigin, String filename = String(), const TextPosition& startPosition = TextPosition(), SourceProviderSourceType sourceType = SourceProviderSourceType::Program)
+ bool operator==(const SourceCode& other) const
{
- return SourceCode(StringSourceProvider::create(source, sourceOrigin, WTFMove(filename), startPosition, sourceType), startPosition.m_line.oneBasedInt(), startPosition.m_column.oneBasedInt());
+ return m_firstLine == other.m_firstLine
+ && m_startColumn == other.m_startColumn
+ && m_provider == other.m_provider
+ && m_startOffset == other.m_startOffset
+ && m_endOffset == other.m_endOffset;
}
-
- inline SourceCode SourceCode::subExpression(unsigned openBrace, unsigned closeBrace, int firstLine, int startColumn) const
+
+ bool operator!=(const SourceCode& other) const
{
- startColumn += 1; // Convert to base 1.
- return SourceCode(RefPtr<SourceProvider> { provider() }, openBrace, closeBrace + 1, firstLine, startColumn);
+ return !(*this == other);
}
+private:
+ OrdinalNumber m_firstLine;
+ OrdinalNumber m_startColumn;
+};
+
+inline SourceCode makeSource(const String& source, const SourceOrigin& sourceOrigin, String filename = String(), const TextPosition& startPosition = TextPosition(), SourceProviderSourceType sourceType = SourceProviderSourceType::Program)
+{
+ return SourceCode(StringSourceProvider::create(source, sourceOrigin, WTFMove(filename), startPosition, sourceType), startPosition.m_line.oneBasedInt(), startPosition.m_column.oneBasedInt());
+}
+
+inline SourceCode SourceCode::subExpression(unsigned openBrace, unsigned closeBrace, int firstLine, int startColumn) const
+{
+ startColumn += 1; // Convert to base 1.
+ return SourceCode(RefPtr<SourceProvider> { provider() }, openBrace, closeBrace + 1, firstLine, startColumn);
+}
+
} // namespace JSC
Modified: trunk/Source/_javascript_Core/parser/SourceProvider.cpp (283902 => 283903)
--- trunk/Source/_javascript_Core/parser/SourceProvider.cpp 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/parser/SourceProvider.cpp 2021-10-11 16:58:40 UTC (rev 283903)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2013-2021 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,8 +26,6 @@
#include "config.h"
#include "SourceProvider.h"
-#include <wtf/Lock.h>
-
namespace JSC {
DEFINE_ALLOCATOR_WITH_HEAP_IDENTIFIER(StringSourceProvider);
@@ -44,13 +42,10 @@
{
}
-static Lock providerIdLock;
-
void SourceProvider::getID()
{
- Locker locker { providerIdLock };
if (!m_id) {
- static intptr_t nextProviderID = 0;
+ static std::atomic<SourceID> nextProviderID = nullID;
m_id = ++nextProviderID;
RELEASE_ASSERT(m_id);
}
Modified: trunk/Source/_javascript_Core/parser/SourceProvider.h (283902 => 283903)
--- trunk/Source/_javascript_Core/parser/SourceProvider.h 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/parser/SourceProvider.h 2021-10-11 16:58:40 UTC (rev 283903)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2008-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -79,7 +79,7 @@
TextPosition startPosition() const { return m_startPosition; }
SourceProviderSourceType sourceType() const { return m_sourceType; }
- intptr_t asID()
+ SourceID asID()
{
if (!m_id)
getID();
@@ -98,7 +98,7 @@
String m_sourceURLDirective;
String m_sourceMappingURLDirective;
TextPosition m_startPosition;
- uintptr_t m_id { 0 };
+ SourceID m_id { 0 };
};
DECLARE_ALLOCATOR_WITH_HEAP_IDENTIFIER(StringSourceProvider);
Modified: trunk/Source/_javascript_Core/runtime/ControlFlowProfiler.cpp (283902 => 283903)
--- trunk/Source/_javascript_Core/runtime/ControlFlowProfiler.cpp 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/runtime/ControlFlowProfiler.cpp 2021-10-11 16:58:40 UTC (rev 283903)
@@ -44,7 +44,7 @@
}
}
-BasicBlockLocation* ControlFlowProfiler::getBasicBlockLocation(intptr_t sourceID, int startOffset, int endOffset)
+BasicBlockLocation* ControlFlowProfiler::getBasicBlockLocation(SourceID sourceID, int startOffset, int endOffset)
{
auto addResult = m_sourceIDBuckets.add(sourceID, BlockLocationCache());
BlockLocationCache& blockLocationCache = addResult.iterator->value;
@@ -66,7 +66,7 @@
}
}
-Vector<BasicBlockRange> ControlFlowProfiler::getBasicBlocksForSourceID(intptr_t sourceID, VM& vm) const
+Vector<BasicBlockRange> ControlFlowProfiler::getBasicBlocksForSourceID(SourceID sourceID, VM& vm) const
{
Vector<BasicBlockRange> result(0);
auto bucketFindResult = m_sourceIDBuckets.find(sourceID);
@@ -120,7 +120,7 @@
return bestRange;
}
-bool ControlFlowProfiler::hasBasicBlockAtTextOffsetBeenExecuted(int offset, intptr_t sourceID, VM& vm)
+bool ControlFlowProfiler::hasBasicBlockAtTextOffsetBeenExecuted(int offset, SourceID sourceID, VM& vm)
{
const Vector<BasicBlockRange>& blocks = getBasicBlocksForSourceID(sourceID, vm);
BasicBlockRange range = findBasicBlockAtTextOffset(offset, blocks);
@@ -127,7 +127,7 @@
return range.m_hasExecuted;
}
-size_t ControlFlowProfiler::basicBlockExecutionCountAtTextOffset(int offset, intptr_t sourceID, VM& vm)
+size_t ControlFlowProfiler::basicBlockExecutionCountAtTextOffset(int offset, SourceID sourceID, VM& vm)
{
const Vector<BasicBlockRange>& blocks = getBasicBlocksForSourceID(sourceID, vm);
BasicBlockRange range = findBasicBlockAtTextOffset(offset, blocks);
Modified: trunk/Source/_javascript_Core/runtime/ControlFlowProfiler.h (283902 => 283903)
--- trunk/Source/_javascript_Core/runtime/ControlFlowProfiler.h 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/runtime/ControlFlowProfiler.h 2021-10-11 16:58:40 UTC (rev 283903)
@@ -91,16 +91,16 @@
public:
ControlFlowProfiler();
~ControlFlowProfiler();
- BasicBlockLocation* getBasicBlockLocation(intptr_t sourceID, int startOffset, int endOffset);
+ BasicBlockLocation* getBasicBlockLocation(SourceID, int startOffset, int endOffset);
JS_EXPORT_PRIVATE void dumpData() const;
- Vector<BasicBlockRange> getBasicBlocksForSourceID(intptr_t sourceID, VM&) const;
+ Vector<BasicBlockRange> getBasicBlocksForSourceID(SourceID, VM&) const;
BasicBlockLocation* dummyBasicBlock() { return &m_dummyBasicBlock; }
- JS_EXPORT_PRIVATE bool hasBasicBlockAtTextOffsetBeenExecuted(int, intptr_t, VM&); // This function exists for testing.
- JS_EXPORT_PRIVATE size_t basicBlockExecutionCountAtTextOffset(int, intptr_t, VM&); // This function exists for testing.
+ JS_EXPORT_PRIVATE bool hasBasicBlockAtTextOffsetBeenExecuted(int, SourceID, VM&); // This function exists for testing.
+ JS_EXPORT_PRIVATE size_t basicBlockExecutionCountAtTextOffset(int, SourceID, VM&); // This function exists for testing.
private:
typedef HashMap<BasicBlockKey, BasicBlockLocation*> BlockLocationCache;
- typedef HashMap<intptr_t, BlockLocationCache> SourceIDBuckets;
+ typedef HashMap<SourceID, BlockLocationCache> SourceIDBuckets;
SourceIDBuckets m_sourceIDBuckets;
BasicBlockLocation m_dummyBasicBlock;
Modified: trunk/Source/_javascript_Core/runtime/FunctionHasExecutedCache.cpp (283902 => 283903)
--- trunk/Source/_javascript_Core/runtime/FunctionHasExecutedCache.cpp 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/runtime/FunctionHasExecutedCache.cpp 2021-10-11 16:58:40 UTC (rev 283903)
@@ -30,7 +30,7 @@
namespace JSC {
-bool FunctionHasExecutedCache::hasExecutedAtOffset(intptr_t id, unsigned offset)
+bool FunctionHasExecutedCache::hasExecutedAtOffset(SourceID id, unsigned offset)
{
if (m_rangeMap.find(id) == m_rangeMap.end())
return false;
@@ -49,7 +49,7 @@
return hasExecuted;
}
-void FunctionHasExecutedCache::insertUnexecutedRange(intptr_t id, unsigned start, unsigned end)
+void FunctionHasExecutedCache::insertUnexecutedRange(SourceID id, unsigned start, unsigned end)
{
if (m_rangeMap.find(id) == m_rangeMap.end()) {
RangeMap map;
@@ -66,7 +66,7 @@
map[range] = false;
}
-void FunctionHasExecutedCache::removeUnexecutedRange(intptr_t id, unsigned start, unsigned end)
+void FunctionHasExecutedCache::removeUnexecutedRange(SourceID id, unsigned start, unsigned end)
{
// FIXME: We should never have an instance where we return here, but currently do in some situations. Find out why.
if (m_rangeMap.find(id) == m_rangeMap.end())
@@ -80,7 +80,7 @@
map[range] = true;
}
-Vector<std::tuple<bool, unsigned, unsigned>> FunctionHasExecutedCache::getFunctionRanges(intptr_t id)
+Vector<std::tuple<bool, unsigned, unsigned>> FunctionHasExecutedCache::getFunctionRanges(SourceID id)
{
Vector<std::tuple<bool, unsigned, unsigned>> ranges(0);
auto findResult = m_rangeMap.find(id);
Modified: trunk/Source/_javascript_Core/runtime/FunctionHasExecutedCache.h (283902 => 283903)
--- trunk/Source/_javascript_Core/runtime/FunctionHasExecutedCache.h 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/runtime/FunctionHasExecutedCache.h 2021-10-11 16:58:40 UTC (rev 283903)
@@ -25,6 +25,7 @@
#pragma once
+#include "SourceID.h"
#include <wtf/HashMethod.h>
#include <wtf/StdUnorderedMap.h>
#include <wtf/Vector.h>
@@ -48,10 +49,10 @@
unsigned m_end;
};
- bool hasExecutedAtOffset(intptr_t id, unsigned offset);
- void insertUnexecutedRange(intptr_t id, unsigned start, unsigned end);
- void removeUnexecutedRange(intptr_t id, unsigned start, unsigned end);
- Vector<std::tuple<bool, unsigned, unsigned>> getFunctionRanges(intptr_t id);
+ bool hasExecutedAtOffset(SourceID, unsigned offset);
+ void insertUnexecutedRange(SourceID, unsigned start, unsigned end);
+ void removeUnexecutedRange(SourceID, unsigned start, unsigned end);
+ Vector<std::tuple<bool, unsigned, unsigned>> getFunctionRanges(SourceID);
private:
using RangeMap = StdUnorderedMap<FunctionRange, bool, HashMethod<FunctionRange>>;
Modified: trunk/Source/_javascript_Core/runtime/SamplingProfiler.cpp (283902 => 283903)
--- trunk/Source/_javascript_Core/runtime/SamplingProfiler.cpp 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/runtime/SamplingProfiler.cpp 2021-10-11 16:58:40 UTC (rev 283903)
@@ -918,7 +918,7 @@
return std::numeric_limits<unsigned>::max();
}
-intptr_t SamplingProfiler::StackFrame::sourceID()
+SourceID SamplingProfiler::StackFrame::sourceID()
{
switch (frameType) {
case FrameType::Unknown:
Modified: trunk/Source/_javascript_Core/runtime/SamplingProfiler.h (283902 => 283903)
--- trunk/Source/_javascript_Core/runtime/SamplingProfiler.h 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/runtime/SamplingProfiler.h 2021-10-11 16:58:40 UTC (rev 283903)
@@ -148,7 +148,7 @@
String displayNameForJSONTests(VM&); // Used for JSC stress tests because they want the "(anonymous function)" string for anonymous functions and they want "(eval)" for eval'd code.
int functionStartLine();
unsigned functionStartColumn();
- intptr_t sourceID();
+ SourceID sourceID();
String url();
};
Modified: trunk/Source/_javascript_Core/runtime/ScriptExecutable.h (283902 => 283903)
--- trunk/Source/_javascript_Core/runtime/ScriptExecutable.h 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/runtime/ScriptExecutable.h 2021-10-11 16:58:40 UTC (rev 283903)
@@ -45,7 +45,7 @@
CodeBlockHash hashFor(CodeSpecializationKind) const;
const SourceCode& source() const { return m_source; }
- intptr_t sourceID() const { return m_source.providerID(); }
+ SourceID sourceID() const { return m_source.providerID(); }
const SourceOrigin& sourceOrigin() const { return m_source.provider()->sourceOrigin(); }
// This is NOT the path that should be used for computing relative paths from a script. Use SourceOrigin's URL for that, the values may or may not be the same... This should only be used for `error.sourceURL` and stack traces.
const String& sourceURL() const { return m_source.provider()->sourceURL(); }
Modified: trunk/Source/_javascript_Core/runtime/StackFrame.cpp (283902 => 283903)
--- trunk/Source/_javascript_Core/runtime/StackFrame.cpp 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/runtime/StackFrame.cpp 2021-10-11 16:58:40 UTC (rev 283903)
@@ -51,7 +51,7 @@
{
}
-intptr_t StackFrame::sourceID() const
+SourceID StackFrame::sourceID() const
{
if (!m_codeBlock)
return noSourceID;
Modified: trunk/Source/_javascript_Core/runtime/StackFrame.h (283902 => 283903)
--- trunk/Source/_javascript_Core/runtime/StackFrame.h 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/runtime/StackFrame.h 2021-10-11 16:58:40 UTC (rev 283903)
@@ -47,7 +47,7 @@
void computeLineAndColumn(unsigned& line, unsigned& column) const;
String functionName(VM&) const;
- intptr_t sourceID() const;
+ SourceID sourceID() const;
String sourceURL() const;
String toString(VM&) const;
Modified: trunk/Source/_javascript_Core/runtime/TypeLocationCache.cpp (283902 => 283903)
--- trunk/Source/_javascript_Core/runtime/TypeLocationCache.cpp 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/runtime/TypeLocationCache.cpp 2021-10-11 16:58:40 UTC (rev 283903)
@@ -33,7 +33,7 @@
namespace JSC {
-std::pair<TypeLocation*, bool> TypeLocationCache::getTypeLocation(GlobalVariableID globalVariableID, intptr_t sourceID, unsigned start, unsigned end, RefPtr<TypeSet>&& globalTypeSet, VM* vm)
+std::pair<TypeLocation*, bool> TypeLocationCache::getTypeLocation(GlobalVariableID globalVariableID, SourceID sourceID, unsigned start, unsigned end, RefPtr<TypeSet>&& globalTypeSet, VM* vm)
{
LocationKey key;
key.m_globalVariableID = globalVariableID;
Modified: trunk/Source/_javascript_Core/runtime/TypeLocationCache.h (283902 => 283903)
--- trunk/Source/_javascript_Core/runtime/TypeLocationCache.h 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/runtime/TypeLocationCache.h 2021-10-11 16:58:40 UTC (rev 283903)
@@ -25,6 +25,7 @@
#pragma once
+#include "SourceID.h"
#include "TypeLocation.h"
#include <wtf/FastMalloc.h>
#include <wtf/HashMethod.h>
@@ -52,12 +53,12 @@
}
GlobalVariableID m_globalVariableID;
- intptr_t m_sourceID;
+ SourceID m_sourceID;
unsigned m_start;
unsigned m_end;
};
- std::pair<TypeLocation*, bool> getTypeLocation(GlobalVariableID, intptr_t, unsigned start, unsigned end, RefPtr<TypeSet>&&, VM*);
+ std::pair<TypeLocation*, bool> getTypeLocation(GlobalVariableID, SourceID, unsigned start, unsigned end, RefPtr<TypeSet>&&, VM*);
private:
using LocationMap = StdUnorderedMap<LocationKey, TypeLocation*, HashMethod<LocationKey>>;
LocationMap m_locationMap;
Modified: trunk/Source/_javascript_Core/runtime/TypeProfiler.cpp (283902 => 283903)
--- trunk/Source/_javascript_Core/runtime/TypeProfiler.cpp 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/runtime/TypeProfiler.cpp 2021-10-11 16:58:40 UTC (rev 283903)
@@ -72,7 +72,7 @@
bucket.append(location);
}
-String TypeProfiler::typeInformationForExpressionAtOffset(TypeProfilerSearchDescriptor descriptor, unsigned offset, intptr_t sourceID, VM& vm)
+String TypeProfiler::typeInformationForExpressionAtOffset(TypeProfilerSearchDescriptor descriptor, unsigned offset, SourceID sourceID, VM& vm)
{
// This returns a JSON string representing an Object with the following properties:
// globalTypeSet: 'JSON<TypeSet> | null'
@@ -102,7 +102,7 @@
return json.toString();
}
-TypeLocation* TypeProfiler::findLocation(unsigned divot, intptr_t sourceID, TypeProfilerSearchDescriptor descriptor, VM& vm)
+TypeLocation* TypeProfiler::findLocation(unsigned divot, SourceID sourceID, TypeProfilerSearchDescriptor descriptor, VM& vm)
{
QueryKey queryKey(sourceID, divot, descriptor);
auto iter = m_queryCache.find(queryKey);
Modified: trunk/Source/_javascript_Core/runtime/TypeProfiler.h (283902 => 283903)
--- trunk/Source/_javascript_Core/runtime/TypeProfiler.h 2021-10-11 16:54:18 UTC (rev 283902)
+++ trunk/Source/_javascript_Core/runtime/TypeProfiler.h 2021-10-11 16:58:40 UTC (rev 283903)
@@ -25,6 +25,7 @@
#pragma once
+#include "SourceID.h"
#include "TypeLocation.h"
#include "TypeLocationCache.h"
#include <wtf/Bag.h>
@@ -50,7 +51,7 @@
, m_searchDescriptor(TypeProfilerSearchDescriptorFunctionReturn)
{ }
- QueryKey(intptr_t sourceID, unsigned divot, TypeProfilerSearchDescriptor searchDescriptor)
+ QueryKey(SourceID sourceID, unsigned divot, TypeProfilerSearchDescriptor searchDescriptor)
: m_sourceID(sourceID)
, m_divot(divot)
, m_searchDescriptor(searchDescriptor)
@@ -57,7 +58,7 @@
{ }
QueryKey(WTF::HashTableDeletedValueType)
- : m_sourceID(INTPTR_MAX)
+ : m_sourceID(UINT_MAX)
, m_divot(UINT_MAX)
, m_searchDescriptor(TypeProfilerSearchDescriptorFunctionReturn)
{ }
@@ -64,7 +65,7 @@
bool isHashTableDeletedValue() const
{
- return m_sourceID == INTPTR_MAX
+ return m_sourceID == UINT_MAX
&& m_divot == UINT_MAX
&& m_searchDescriptor == TypeProfilerSearchDescriptorFunctionReturn;
}
@@ -82,7 +83,7 @@
return hash;
}
- intptr_t m_sourceID;
+ SourceID m_sourceID;
unsigned m_divot;
TypeProfilerSearchDescriptor m_searchDescriptor;
};
@@ -116,10 +117,10 @@
public:
TypeProfiler();
void logTypesForTypeLocation(TypeLocation*, VM&);
- JS_EXPORT_PRIVATE String typeInformationForExpressionAtOffset(TypeProfilerSearchDescriptor, unsigned offset, intptr_t sourceID, VM&);
+ JS_EXPORT_PRIVATE String typeInformationForExpressionAtOffset(TypeProfilerSearchDescriptor, unsigned offset, SourceID, VM&);
void insertNewLocation(TypeLocation*);
TypeLocationCache* typeLocationCache() { return &m_typeLocationCache; }
- TypeLocation* findLocation(unsigned divot, intptr_t sourceID, TypeProfilerSearchDescriptor, VM&);
+ TypeLocation* findLocation(unsigned divot, SourceID, TypeProfilerSearchDescriptor, VM&);
GlobalVariableID getNextUniqueVariableID() { return m_nextUniqueVariableID++; }
TypeLocation* nextTypeLocation();
void invalidateTypeSetCache(VM&);
@@ -126,7 +127,7 @@
void dumpTypeProfilerData(VM&);
private:
- typedef HashMap<intptr_t, Vector<TypeLocation*>> SourceIDToLocationBucketMap;
+ typedef HashMap<SourceID, Vector<TypeLocation*>> SourceIDToLocationBucketMap;
SourceIDToLocationBucketMap m_bucketMap;
TypeLocationCache m_typeLocationCache;
typedef HashMap<QueryKey, TypeLocation*> TypeLocationQueryCache;