Title: [227738] trunk

Diff

Modified: trunk/JSTests/ChangeLog (227737 => 227738)


--- trunk/JSTests/ChangeLog	2018-01-29 17:45:17 UTC (rev 227737)
+++ trunk/JSTests/ChangeLog	2018-01-29 17:47:30 UTC (rev 227738)
@@ -1,3 +1,16 @@
+2018-01-29  Matt Lewis  <jlew...@apple.com>
+
+        Unreviewed, rolling out r227725.
+
+        This caused internal failures.
+
+        Reverted changeset:
+
+        "JSC Sampling Profiler: Detect tester and testee when sampling
+        in RegExp JIT"
+        https://bugs.webkit.org/show_bug.cgi?id=152729
+        https://trac.webkit.org/changeset/227725
+
 2018-01-29  Yusuke Suzuki  <utatane....@gmail.com>
 
         JSC Sampling Profiler: Detect tester and testee when sampling in RegExp JIT

Deleted: trunk/JSTests/stress/sampling-profiler-regexp.js (227737 => 227738)


--- trunk/JSTests/stress/sampling-profiler-regexp.js	2018-01-29 17:45:17 UTC (rev 227737)
+++ trunk/JSTests/stress/sampling-profiler-regexp.js	2018-01-29 17:47:30 UTC (rev 227738)
@@ -1,18 +0,0 @@
-if (platformSupportsSamplingProfiler()) {
-    load("./sampling-profiler/samplingProfiler.js");
-
-    function test(regexp, string)
-    {
-        return string.match(regexp);
-    }
-    noInline(test);
-
-    function baz() {
-        var text = `Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.`;
-        var regexp = /.*/gi;
-        for (var i = 0; i < 1e5; ++i)
-            test(regexp, text);
-    }
-
-    runTest(baz, ["/.*/gi", "", "test", "baz"]);
-}

Modified: trunk/Source/_javascript_Core/ChangeLog (227737 => 227738)


--- trunk/Source/_javascript_Core/ChangeLog	2018-01-29 17:45:17 UTC (rev 227737)
+++ trunk/Source/_javascript_Core/ChangeLog	2018-01-29 17:47:30 UTC (rev 227738)
@@ -1,3 +1,16 @@
+2018-01-29  Matt Lewis  <jlew...@apple.com>
+
+        Unreviewed, rolling out r227725.
+
+        This caused internal failures.
+
+        Reverted changeset:
+
+        "JSC Sampling Profiler: Detect tester and testee when sampling
+        in RegExp JIT"
+        https://bugs.webkit.org/show_bug.cgi?id=152729
+        https://trac.webkit.org/changeset/227725
+
 2018-01-29  Yusuke Suzuki  <utatane....@gmail.com>
 
         JSC Sampling Profiler: Detect tester and testee when sampling in RegExp JIT

Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (227737 => 227738)


--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2018-01-29 17:45:17 UTC (rev 227737)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2018-01-29 17:47:30 UTC (rev 227738)
@@ -1706,7 +1706,6 @@
 		E35CA1541DBC3A5C00F83516 /* DOMJITHeapRange.h in Headers */ = {isa = PBXBuildFile; fileRef = E35CA1521DBC3A5600F83516 /* DOMJITHeapRange.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E35CA1561DBC3A5F00F83516 /* DOMJITAbstractHeap.h in Headers */ = {isa = PBXBuildFile; fileRef = E35CA1501DBC3A5600F83516 /* DOMJITAbstractHeap.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E35E03601B7AB43E0073AD2A /* InspectorInstrumentationObject.h in Headers */ = {isa = PBXBuildFile; fileRef = E35E035E1B7AB43E0073AD2A /* InspectorInstrumentationObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		E36CA813201F302900368EFF /* Concurrency.h in Headers */ = {isa = PBXBuildFile; fileRef = E36CA812201F301100368EFF /* Concurrency.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E3794E761B77EB97005543AE /* ModuleAnalyzer.h in Headers */ = {isa = PBXBuildFile; fileRef = E3794E741B77EB97005543AE /* ModuleAnalyzer.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E393ADD81FE702D00022D681 /* WeakMapImplInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = E393ADD71FE702CC0022D681 /* WeakMapImplInlines.h */; };
 		E39D45F51D39005600B3B377 /* InterpreterInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = E39D9D841D39000600667282 /* InterpreterInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -4554,7 +4553,6 @@
 		E35E035D1B7AB43E0073AD2A /* InspectorInstrumentationObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorInstrumentationObject.cpp; sourceTree = "<group>"; };
 		E35E035E1B7AB43E0073AD2A /* InspectorInstrumentationObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorInstrumentationObject.h; sourceTree = "<group>"; };
 		E35E03611B7AB4850073AD2A /* InspectorInstrumentationObject.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = InspectorInstrumentationObject.js; sourceTree = "<group>"; };
-		E36CA812201F301100368EFF /* Concurrency.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Concurrency.h; sourceTree = "<group>"; };
 		E3794E731B77EB97005543AE /* ModuleAnalyzer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ModuleAnalyzer.cpp; sourceTree = "<group>"; };
 		E3794E741B77EB97005543AE /* ModuleAnalyzer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModuleAnalyzer.h; sourceTree = "<group>"; };
 		E380A76B1DCD7195000F89E6 /* MacroAssemblerHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerHelpers.h; sourceTree = "<group>"; };
@@ -6429,7 +6427,6 @@
 				A7E5A3A61797432D00E893C0 /* CompilationResult.h */,
 				969A09220ED1E09C00F1F681 /* Completion.cpp */,
 				F5BB2BC5030F772101FCFE1D /* Completion.h */,
-				E36CA812201F301100368EFF /* Concurrency.h */,
 				0FDB2CE9174896C7007B3C1B /* ConcurrentJSLock.h */,
 				658824B01E5CFDF400FB7359 /* ConfigFile.cpp */,
 				658824AE1E5CFDB000FB7359 /* ConfigFile.h */,
@@ -9364,7 +9361,6 @@
 				0FA2C17C17D7CF84009D015F /* TestRunnerUtils.h in Headers */,
 				FE3422121D6B81C30032BE88 /* ThrowScope.h in Headers */,
 				0F572D4F16879FDD00E57FBD /* ThunkGenerator.h in Headers */,
-				E36CA813201F302900368EFF /* Concurrency.h in Headers */,
 				A7386556118697B400540279 /* ThunkGenerators.h in Headers */,
 				141448CD13A1783700F5BA1A /* TinyBloomFilter.h in Headers */,
 				0F55989817C86C5800A1E543 /* ToNativeFromValue.h in Headers */,

Modified: trunk/Source/_javascript_Core/bytecode/BytecodeDumper.cpp (227737 => 227738)


--- trunk/Source/_javascript_Core/bytecode/BytecodeDumper.cpp	2018-01-29 17:45:17 UTC (rev 227737)
+++ trunk/Source/_javascript_Core/bytecode/BytecodeDumper.cpp	2018-01-29 17:47:30 UTC (rev 227738)
@@ -250,9 +250,29 @@
     return block()->identifier(index);
 }
 
+static CString regexpToSourceString(RegExp* regExp)
+{
+    char postfix[7] = { '/', 0, 0, 0, 0, 0, 0 };
+    int index = 1;
+    if (regExp->global())
+        postfix[index++] = 'g';
+    if (regExp->ignoreCase())
+        postfix[index++] = 'i';
+    if (regExp->multiline())
+        postfix[index] = 'm';
+    if (regExp->dotAll())
+        postfix[index++] = 's';
+    if (regExp->unicode())
+        postfix[index++] = 'u';
+    if (regExp->sticky())
+        postfix[index++] = 'y';
+
+    return toCString("/", regExp->pattern().impl(), postfix);
+}
+
 static CString regexpName(int re, RegExp* regexp)
 {
-    return toCString(regexp->toSourceString(), "(@re", re, ")");
+    return toCString(regexpToSourceString(regexp), "(@re", re, ")");
 }
 
 template<class Instruction>
@@ -1728,7 +1748,7 @@
         out.printf("\nm_regexps:\n");
         size_t i = 0;
         do {
-            out.print("  re", i, " = ", block()->regexp(i)->toSourceString(), "\n");
+            out.printf("  re%u = %s\n", static_cast<unsigned>(i), regexpToSourceString(block()->regexp(i)).data());
             ++i;
         } while (i < count);
     }

Modified: trunk/Source/_javascript_Core/bytecode/ObjectPropertyConditionSet.cpp (227737 => 227738)


--- trunk/Source/_javascript_Core/bytecode/ObjectPropertyConditionSet.cpp	2018-01-29 17:45:17 UTC (rev 227737)
+++ trunk/Source/_javascript_Core/bytecode/ObjectPropertyConditionSet.cpp	2018-01-29 17:47:30 UTC (rev 227738)
@@ -24,7 +24,6 @@
  */
 
 #include "config.h"
-#include "Concurrency.h"
 #include "ObjectPropertyConditionSet.h"
 
 #include "JSCInlines.h"
@@ -243,10 +242,14 @@
     return result;
 }
 
+enum Concurrency {
+    MainThread,
+    Concurrent
+};
 template<typename Functor>
 ObjectPropertyConditionSet generateConditions(
     VM& vm, JSGlobalObject* globalObject, Structure* structure, JSObject* prototype, const Functor& functor,
-    Concurrency concurrency = Concurrency::MainThread)
+    Concurrency concurrency = MainThread)
 {
     Vector<ObjectPropertyCondition> conditions;
     
@@ -286,7 +289,7 @@
         structure = object->structure(vm);
         
         if (structure->isDictionary()) {
-            if (concurrency == Concurrency::MainThread) {
+            if (concurrency == MainThread) {
                 if (structure->hasBeenFlattenedBefore()) {
                     if (ObjectPropertyConditionSetInternal::verbose)
                         dataLog("Dictionary has been flattened before, so invalid.\n");
@@ -383,7 +386,7 @@
                 return false;
             conditions.append(result);
             return true;
-        }, Concurrency::Concurrent);
+        }, Concurrent);
 }
 
 ObjectPropertyConditionSet generateConditionsForPropertyMissConcurrently(
@@ -397,7 +400,7 @@
                 return false;
             conditions.append(result);
             return true;
-        }, Concurrency::Concurrent);
+        }, Concurrent);
 }
 
 ObjectPropertyConditionSet generateConditionsForPropertySetterMissConcurrently(
@@ -412,7 +415,7 @@
                 return false;
             conditions.append(result);
             return true;
-        }, Concurrency::Concurrent);
+        }, Concurrent);
 }
 
 ObjectPropertyCondition generateConditionForSelfEquivalence(

Modified: trunk/Source/_javascript_Core/heap/Heap.cpp (227737 => 227738)


--- trunk/Source/_javascript_Core/heap/Heap.cpp	2018-01-29 17:45:17 UTC (rev 227737)
+++ trunk/Source/_javascript_Core/heap/Heap.cpp	2018-01-29 17:47:30 UTC (rev 227738)
@@ -2650,7 +2650,6 @@
             
             slotVisitor.appendUnbarriered(m_vm->exception());
             slotVisitor.appendUnbarriered(m_vm->lastException());
-            slotVisitor.appendUnbarriered(m_vm->currentlyExecutingRegExp);
         },
         ConstraintVolatility::GreyedByExecution);
     

Deleted: trunk/Source/_javascript_Core/runtime/Concurrency.h (227737 => 227738)


--- trunk/Source/_javascript_Core/runtime/Concurrency.h	2018-01-29 17:45:17 UTC (rev 227737)
+++ trunk/Source/_javascript_Core/runtime/Concurrency.h	2018-01-29 17:47:30 UTC (rev 227738)
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2018 Yusuke Suzuki <utatane....@gmail.com>.
- *
- * 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 {
-
-enum class Concurrency {
-    MainThread,
-    Concurrent,
-};
-
-}

Modified: trunk/Source/_javascript_Core/runtime/RegExp.cpp (227737 => 227738)


--- trunk/Source/_javascript_Core/runtime/RegExp.cpp	2018-01-29 17:45:17 UTC (rev 227737)
+++ trunk/Source/_javascript_Core/runtime/RegExp.cpp	2018-01-29 17:47:30 UTC (rev 227738)
@@ -307,7 +307,7 @@
 
 #if ENABLE(YARR_JIT)
     if (!pattern.m_containsBackreferences && !pattern.containsUnsignedLengthPattern() && VM::canUseRegExpJIT()) {
-        Yarr::jitCompile(pattern, charSize, m_regExpJITCode);
+        Yarr::jitCompile(pattern, charSize, vm, m_regExpJITCode);
         if (!m_regExpJITCode.failureReason()) {
             m_state = JITCode;
             return;
@@ -326,7 +326,7 @@
 
 int RegExp::match(VM& vm, const String& s, unsigned startOffset, Vector<int>& ovector)
 {
-    return matchInline(vm, Concurrency::MainThread, s, startOffset, ovector);
+    return matchInline(vm, s, startOffset, ovector);
 }
 
 bool RegExp::matchConcurrently(
@@ -337,7 +337,7 @@
     if (!hasCodeFor(s.is8Bit() ? Yarr::Char8 : Yarr::Char16))
         return false;
 
-    position = matchInline(vm, Concurrency::Concurrent, s, startOffset, ovector);
+    position = match(vm, s, startOffset, ovector);
     return true;
 }
 
@@ -363,7 +363,7 @@
 
 #if ENABLE(YARR_JIT)
     if (!pattern.m_containsBackreferences && !pattern.containsUnsignedLengthPattern() && VM::canUseRegExpJIT()) {
-        Yarr::jitCompile(pattern, charSize, m_regExpJITCode, Yarr::MatchOnly);
+        Yarr::jitCompile(pattern, charSize, vm, m_regExpJITCode, Yarr::MatchOnly);
         if (!m_regExpJITCode.failureReason()) {
             m_state = JITCode;
             return;
@@ -382,7 +382,7 @@
 
 MatchResult RegExp::match(VM& vm, const String& s, unsigned startOffset)
 {
-    return matchInline(vm, Concurrency::MainThread, s, startOffset);
+    return matchInline(vm, s, startOffset);
 }
 
 bool RegExp::matchConcurrently(VM& vm, const String& s, unsigned startOffset, MatchResult& result)
@@ -392,7 +392,7 @@
     if (!hasMatchOnlyCodeFor(s.is8Bit() ? Yarr::Char8 : Yarr::Char16))
         return false;
 
-    result = matchInline(vm, Concurrency::Concurrent, s, startOffset);
+    result = match(vm, s, startOffset);
     return true;
 }
 
@@ -409,26 +409,6 @@
     m_regExpBytecode = nullptr;
 }
 
-String RegExp::toSourceString() const
-{
-    char postfix[8] = { '/', 0, 0, 0, 0, 0, 0, 0 };
-    int index = 1;
-    if (global())
-        postfix[index++] = 'g';
-    if (ignoreCase())
-        postfix[index++] = 'i';
-    if (multiline())
-        postfix[index++] = 'm';
-    if (dotAll())
-        postfix[index++] = 's';
-    if (unicode())
-        postfix[index++] = 'u';
-    if (sticky())
-        postfix[index++] = 'y';
-
-    return makeString("/", pattern(), postfix);
-}
-
 #if ENABLE(YARR_JIT_DEBUG)
 void RegExp::matchCompareWithInterpreter(const String& s, int startOffset, int* offsetVector, int jitResult)
 {

Modified: trunk/Source/_javascript_Core/runtime/RegExp.h (227737 => 227738)


--- trunk/Source/_javascript_Core/runtime/RegExp.h	2018-01-29 17:45:17 UTC (rev 227737)
+++ trunk/Source/_javascript_Core/runtime/RegExp.h	2018-01-29 17:47:30 UTC (rev 227738)
@@ -21,7 +21,6 @@
 
 #pragma once
 
-#include "Concurrency.h"
 #include "ConcurrentJSLock.h"
 #include "MatchResult.h"
 #include "RegExpKey.h"
@@ -75,8 +74,8 @@
 
     // Call these versions of the match functions if you're desperate for performance.
     template<typename VectorType>
-    int matchInline(VM&, Concurrency, const String&, unsigned startOffset, VectorType& ovector);
-    MatchResult matchInline(VM&, Concurrency, const String&, unsigned startOffset);
+    int matchInline(VM&, const String&, unsigned startOffset, VectorType& ovector);
+    MatchResult matchInline(VM&, const String&, unsigned startOffset);
     
     unsigned numSubpatterns() const { return m_numSubpatterns; }
 
@@ -123,8 +122,6 @@
 
     RegExpKey key() { return RegExpKey(m_flags, m_patternString); }
 
-    String toSourceString() const;
-
 protected:
     void finishCreation(VM&);
 
@@ -153,30 +150,6 @@
     void matchCompareWithInterpreter(const String&, int startOffset, int* offsetVector, int jitResult);
 #endif
 
-#if ENABLE(YARR_JIT)
-    class RegExpJITFrameTracer {
-        WTF_MAKE_NONCOPYABLE(RegExpJITFrameTracer);
-    public:
-        ALWAYS_INLINE RegExpJITFrameTracer(VM& vm, RegExp& regExp, Concurrency concurrency)
-        {
-            if (concurrency == Concurrency::MainThread) {
-                m_vm = &vm;
-                ASSERT(!m_vm->currentlyExecutingRegExp);
-                m_vm->currentlyExecutingRegExp = &regExp;
-            }
-        }
-
-        ALWAYS_INLINE ~RegExpJITFrameTracer()
-        {
-            if (m_vm)
-                m_vm->currentlyExecutingRegExp = nullptr;
-        }
-
-    private:
-        VM* m_vm { nullptr };
-    };
-#endif
-
     RegExpState m_state { NotCompiled };
     String m_patternString;
     RegExpFlags m_flags;

Modified: trunk/Source/_javascript_Core/runtime/RegExpInlines.h (227737 => 227738)


--- trunk/Source/_javascript_Core/runtime/RegExpInlines.h	2018-01-29 17:45:17 UTC (rev 227737)
+++ trunk/Source/_javascript_Core/runtime/RegExpInlines.h	2018-01-29 17:47:30 UTC (rev 227738)
@@ -94,7 +94,7 @@
 }
 
 template<typename VectorType>
-ALWAYS_INLINE int RegExp::matchInline(VM& vm, Concurrency concurrency, const String& s, unsigned startOffset, VectorType& ovector)
+ALWAYS_INLINE int RegExp::matchInline(VM& vm, const String& s, unsigned startOffset, VectorType& ovector)
 {
 #if ENABLE(REGEXP_TRACING)
     m_rtMatchCallCount++;
@@ -118,13 +118,10 @@
 #endif
 
     if (m_state == JITCode) {
-        {
-            RegExpJITFrameTracer tracer { vm, *this, concurrency };
-            if (s.is8Bit())
-                result = m_regExpJITCode.execute(s.characters8(), startOffset, s.length(), offsetVector EXTRA_JIT_PARAMS).start;
-            else
-                result = m_regExpJITCode.execute(s.characters16(), startOffset, s.length(), offsetVector EXTRA_JIT_PARAMS).start;
-        }
+        if (s.is8Bit())
+            result = m_regExpJITCode.execute(s.characters8(), startOffset, s.length(), offsetVector EXTRA_JIT_PARAMS).start;
+        else
+            result = m_regExpJITCode.execute(s.characters16(), startOffset, s.length(), offsetVector EXTRA_JIT_PARAMS).start;
 
         if (result == Yarr::JSRegExpJITCodeFailure) {
             // JIT'ed code couldn't handle _expression_, so punt back to the interpreter.
@@ -205,7 +202,7 @@
     compileMatchOnly(&vm, charSize);
 }
 
-ALWAYS_INLINE MatchResult RegExp::matchInline(VM& vm, Concurrency concurrency, const String& s, unsigned startOffset)
+ALWAYS_INLINE MatchResult RegExp::matchInline(VM& vm, const String& s, unsigned startOffset)
 {
 #if ENABLE(REGEXP_TRACING)
     m_rtMatchOnlyCallCount++;
@@ -226,13 +223,10 @@
     MatchResult result;
 
     if (m_state == JITCode) {
-        {
-            RegExpJITFrameTracer tracer { vm, *this, concurrency };
-            if (s.is8Bit())
-                result = m_regExpJITCode.execute(s.characters8(), startOffset, s.length() EXTRA_JIT_PARAMS);
-            else
-                result = m_regExpJITCode.execute(s.characters16(), startOffset, s.length() EXTRA_JIT_PARAMS);
-        }
+        if (s.is8Bit())
+            result = m_regExpJITCode.execute(s.characters8(), startOffset, s.length() EXTRA_JIT_PARAMS);
+        else
+            result = m_regExpJITCode.execute(s.characters16(), startOffset, s.length() EXTRA_JIT_PARAMS);
 
 #if ENABLE(REGEXP_TRACING)
         if (!result)

Modified: trunk/Source/_javascript_Core/runtime/RegExpMatchesArray.h (227737 => 227738)


--- trunk/Source/_javascript_Core/runtime/RegExpMatchesArray.h	2018-01-29 17:45:17 UTC (rev 227737)
+++ trunk/Source/_javascript_Core/runtime/RegExpMatchesArray.h	2018-01-29 17:47:30 UTC (rev 227738)
@@ -63,7 +63,7 @@
     RegExp* regExp, unsigned startOffset, MatchResult& result)
 {
     Vector<int, 32> subpatternResults;
-    int position = regExp->matchInline(vm, Concurrency::MainThread, inputValue, startOffset, subpatternResults);
+    int position = regExp->matchInline(vm, inputValue, startOffset, subpatternResults);
     if (position == -1) {
         result = MatchResult::failed();
         return nullptr;

Modified: trunk/Source/_javascript_Core/runtime/SamplingProfiler.cpp (227737 => 227738)


--- trunk/Source/_javascript_Core/runtime/SamplingProfiler.cpp	2018-01-29 17:45:17 UTC (rev 227737)
+++ trunk/Source/_javascript_Core/runtime/SamplingProfiler.cpp	2018-01-29 17:47:30 UTC (rev 227738)
@@ -276,8 +276,11 @@
 
 SamplingProfiler::SamplingProfiler(VM& vm, RefPtr<Stopwatch>&& stopwatch)
     : m_vm(vm)
+    , m_weakRandom()
     , m_stopwatch(WTFMove(stopwatch))
     , m_timingInterval(Seconds::fromMicroseconds(Options::sampleInterval()))
+    , m_isPaused(false)
+    , m_isShutDown(false)
 {
     if (sReportStats) {
         sNumTotalWalks = 0;
@@ -287,6 +290,10 @@
     m_currentFrames.grow(256);
 }
 
+SamplingProfiler::~SamplingProfiler()
+{
+}
+
 void SamplingProfiler::createThreadIfNecessary(const AbstractLocker&)
 {
     ASSERT(m_lock.isLocked());
@@ -310,7 +317,7 @@
                 return;
 
             if (!m_isPaused && m_jscExecutionThread)
-                stackTraceProcessingTime = takeSample(locker);
+                takeSample(locker, stackTraceProcessingTime);
 
             m_lastTime = m_stopwatch->elapsedTime();
         }
@@ -325,7 +332,7 @@
     }
 }
 
-Seconds SamplingProfiler::takeSample(const AbstractLocker&)
+void SamplingProfiler::takeSample(const AbstractLocker&, Seconds& stackTraceProcessingTime)
 {
     ASSERT(m_lock.isLocked());
     if (m_vm.entryScope) {
@@ -343,7 +350,6 @@
             ExecState* callFrame;
             void* machinePC;
             bool topFrameIsLLInt = false;
-            RegExp* regExp = nullptr;
             void* llintPC;
             {
                 PlatformRegisters registers;
@@ -356,9 +362,11 @@
             // FIXME: Lets have a way of detecting when we're parsing code.
             // https://bugs.webkit.org/show_bug.cgi?id=152761
             if (ExecutableAllocator::singleton().isValidExecutableMemory(executableAllocatorLocker, machinePC)) {
-                regExp = m_vm.currentlyExecutingRegExp;
-                if (regExp)
+                if (m_vm.isExecutingInRegExpJIT) {
+                    // FIXME: We're executing a regexp. Lets gather more intersting data.
+                    // https://bugs.webkit.org/show_bug.cgi?id=152729
                     callFrame = m_vm.topCallFrame; // We need to do this or else we'd fail our backtrace validation b/c this isn't a JS frame.
+                }
             } else if (LLInt::isLLIntPC(machinePC)) {
                 topFrameIsLLInt = true;
                 // We're okay to take a normal stack trace when the PC
@@ -399,16 +407,16 @@
                     stackTrace.uncheckedAppend(frame);
                 }
 
-                m_unprocessedStackTraces.append(UnprocessedStackTrace { nowTime, machinePC, topFrameIsLLInt, llintPC, regExp, WTFMove(stackTrace) });
+                m_unprocessedStackTraces.append(UnprocessedStackTrace { nowTime, machinePC, topFrameIsLLInt, llintPC, WTFMove(stackTrace) });
 
                 if (didRunOutOfVectorSpace)
                     m_currentFrames.grow(m_currentFrames.size() * 1.25);
             }
 
-            return MonotonicTime::now() - startTime;
+            auto endTime = MonotonicTime::now();
+            stackTraceProcessingTime = endTime - startTime;
         }
     }
-    return 0_s;
 }
 
 static ALWAYS_INLINE unsigned tryGetBytecodeIndex(unsigned llintPC, CodeBlock* codeBlock, bool& isValid)
@@ -563,44 +571,36 @@
         // Prepend the top-most inlined frame if needed and gather
         // location information about where the top frame is executing.
         size_t startIndex = 0;
-        if (!unprocessedStackTrace.frames.isEmpty()) {
-            auto& topFrame = unprocessedStackTrace.frames[0];
-            if (!!topFrame.verifiedCodeBlock) {
-                CodeBlock* topCodeBlock = topFrame.verifiedCodeBlock;
-                if (unprocessedStackTrace.topFrameIsLLInt) {
-                    // We reuse LLInt CodeBlocks for the baseline JIT, so we need to check for both jit types.
-                    // This might also be false for various reasons (known and unknown), even though
-                    // it's super unlikely. One reason that this can be false is when we throw from a DFG frame,
-                    // and we end up having to unwind past an EntryFrame, we will end up executing
-                    // inside the LLInt's handleUncaughtException. So we just protect against this
-                    // by ignoring it.
-                    unsigned bytecodeIndex = 0;
-                    if (topCodeBlock->jitType() == JITCode::InterpreterThunk || topCodeBlock->jitType() == JITCode::BaselineJIT) {
-                        bool isValidPC;
-                        unsigned bits;
+        if (unprocessedStackTrace.frames.size() && !!unprocessedStackTrace.frames[0].verifiedCodeBlock) {
+            CodeBlock* topCodeBlock = unprocessedStackTrace.frames[0].verifiedCodeBlock;
+            if (unprocessedStackTrace.topFrameIsLLInt) {
+                // We reuse LLInt CodeBlocks for the baseline JIT, so we need to check for both jit types.
+                // This might also be false for various reasons (known and unknown), even though
+                // it's super unlikely. One reason that this can be false is when we throw from a DFG frame,
+                // and we end up having to unwind past an EntryFrame, we will end up executing
+                // inside the LLInt's handleUncaughtException. So we just protect against this
+                // by ignoring it.
+                unsigned bytecodeIndex = 0;
+                if (topCodeBlock->jitType() == JITCode::InterpreterThunk || topCodeBlock->jitType() == JITCode::BaselineJIT) {
+                    bool isValidPC;
+                    unsigned bits;
 #if USE(JSVALUE64)
-                        bits = static_cast<unsigned>(bitwise_cast<uintptr_t>(unprocessedStackTrace.llintPC));
+                    bits = static_cast<unsigned>(bitwise_cast<uintptr_t>(unprocessedStackTrace.llintPC));
 #else
-                        bits = bitwise_cast<unsigned>(unprocessedStackTrace.llintPC);
+                    bits = bitwise_cast<unsigned>(unprocessedStackTrace.llintPC);
 #endif
-                        bytecodeIndex = tryGetBytecodeIndex(bits, topCodeBlock, isValidPC);
+                    bytecodeIndex = tryGetBytecodeIndex(bits, topCodeBlock, isValidPC);
 
-                        UNUSED_PARAM(isValidPC); // FIXME: do something with this info for the web inspector: https://bugs.webkit.org/show_bug.cgi?id=153455
+                    UNUSED_PARAM(isValidPC); // FIXME: do something with this info for the web inspector: https://bugs.webkit.org/show_bug.cgi?id=153455
 
-                        appendCodeBlock(topCodeBlock, bytecodeIndex);
-                        storeCalleeIntoLastFrame(topFrame.unverifiedCallee);
-                        startIndex = 1;
-                    }
-                } else if (std::optional<CodeOrigin> codeOrigin = topCodeBlock->findPC(unprocessedStackTrace.topPC)) {
-                    appendCodeOrigin(topCodeBlock, *codeOrigin);
-                    storeCalleeIntoLastFrame(topFrame.unverifiedCallee);
+                    appendCodeBlock(topCodeBlock, bytecodeIndex);
+                    storeCalleeIntoLastFrame(unprocessedStackTrace.frames[0].unverifiedCallee);
                     startIndex = 1;
                 }
-            } else if (unprocessedStackTrace.regExp) {
-                appendEmptyFrame();
-                stackTrace.frames.last().regExp = unprocessedStackTrace.regExp;
-                stackTrace.frames.last().frameType = FrameType::RegExp;
-                m_liveCellPointers.add(unprocessedStackTrace.regExp);
+            } else if (std::optional<CodeOrigin> codeOrigin = topCodeBlock->findPC(unprocessedStackTrace.topPC)) {
+                appendCodeOrigin(topCodeBlock, *codeOrigin);
+                storeCalleeIntoLastFrame(unprocessedStackTrace.frames[0].unverifiedCallee);
+                startIndex = 1;
             }
         }
 
@@ -712,11 +712,8 @@
 
 String SamplingProfiler::StackFrame::nameFromCallee(VM& vm)
 {
-    if (!callee) {
-        if (regExp)
-            return regExp->toSourceString();
+    if (!callee)
         return String();
-    }
 
     auto scope = DECLARE_CATCH_SCOPE(vm);
     ExecState* exec = callee->globalObject()->globalExec();
@@ -750,7 +747,7 @@
             return name;
     }
 
-    if (frameType == FrameType::Unknown || frameType == FrameType::C || frameType == FrameType::RegExp) {
+    if (frameType == FrameType::Unknown || frameType == FrameType::C) {
 #if HAVE(DLADDR)
         if (frameType == FrameType::C) {
             auto demangled = WTF::StackTrace::demangle(cCodePC);
@@ -786,7 +783,7 @@
             return name;
     }
 
-    if (frameType == FrameType::Unknown || frameType == FrameType::C || frameType == FrameType::RegExp)
+    if (frameType == FrameType::Unknown || frameType == FrameType::C)
         return ASCIILiteral("(unknown)");
     if (frameType == FrameType::Host)
         return ASCIILiteral("(host)");
@@ -813,79 +810,48 @@
 
 int SamplingProfiler::StackFrame::functionStartLine()
 {
-    switch (frameType) {
-    case FrameType::Executable:
-        if (executable->isHostFunction())
-            return -1;
-        return static_cast<ScriptExecutable*>(executable)->firstLine();
+    if (frameType == FrameType::Unknown || frameType == FrameType::Host || frameType == FrameType::C)
+        return -1;
 
-    case FrameType::Host:
-    case FrameType::RegExp:
-    case FrameType::C:
-    case FrameType::Unknown:
+    if (executable->isHostFunction())
         return -1;
-    }
-    ASSERT_NOT_REACHED();
-    return -1;
+    return static_cast<ScriptExecutable*>(executable)->firstLine();
 }
 
 unsigned SamplingProfiler::StackFrame::functionStartColumn()
 {
-    switch (frameType) {
-    case FrameType::Executable:
-        if (executable->isHostFunction())
-            return std::numeric_limits<unsigned>::max();
-        return static_cast<ScriptExecutable*>(executable)->startColumn();
+    if (frameType == FrameType::Unknown || frameType == FrameType::Host || frameType == FrameType::C)
+        return std::numeric_limits<unsigned>::max();
 
-    case FrameType::Host:
-    case FrameType::RegExp:
-    case FrameType::C:
-    case FrameType::Unknown:
+    if (executable->isHostFunction())
         return std::numeric_limits<unsigned>::max();
-    }
-    ASSERT_NOT_REACHED();
-    return std::numeric_limits<unsigned>::max();
+
+    return static_cast<ScriptExecutable*>(executable)->startColumn();
 }
 
 intptr_t SamplingProfiler::StackFrame::sourceID()
 {
-    switch (frameType) {
-    case FrameType::Executable:
-        if (executable->isHostFunction())
-            return -1;
-        return static_cast<ScriptExecutable*>(executable)->sourceID();
+    if (frameType == FrameType::Unknown || frameType == FrameType::Host || frameType == FrameType::C)
+        return -1;
 
-    case FrameType::Host:
-    case FrameType::RegExp:
-    case FrameType::C:
-    case FrameType::Unknown:
+    if (executable->isHostFunction())
         return -1;
-    }
-    ASSERT_NOT_REACHED();
-    return -1;
+
+    return static_cast<ScriptExecutable*>(executable)->sourceID();
 }
 
 String SamplingProfiler::StackFrame::url()
 {
-    switch (frameType) {
-    case FrameType::Executable: {
-        if (executable->isHostFunction())
-            return emptyString();
+    if (frameType == FrameType::Unknown || frameType == FrameType::Host || frameType == FrameType::C)
+        return emptyString();
 
-        String url = ""
-        if (url.isEmpty())
-            return static_cast<ScriptExecutable*>(executable)->source().provider()->sourceURL(); // Fall back to sourceURL directive.
-        return url;
-    }
+    if (executable->isHostFunction())
+        return emptyString();
 
-    case FrameType::Host:
-    case FrameType::RegExp:
-    case FrameType::C:
-    case FrameType::Unknown:
-        return emptyString();
-    }
-    ASSERT_NOT_REACHED();
-    return emptyString();
+    String url = ""
+    if (url.isEmpty())
+        return static_cast<ScriptExecutable*>(executable)->source().provider()->sourceURL(); // Fall back to sourceURL directive.
+    return url;
 }
 
 Vector<SamplingProfiler::StackTrace> SamplingProfiler::releaseStackTraces(const AbstractLocker& locker)
@@ -1114,9 +1080,6 @@
     case SamplingProfiler::FrameType::Host:
         out.print("Host");
         break;
-    case SamplingProfiler::FrameType::RegExp:
-        out.print("RegExp");
-        break;
     case SamplingProfiler::FrameType::C:
     case SamplingProfiler::FrameType::Unknown:
         out.print("Unknown");

Modified: trunk/Source/_javascript_Core/runtime/SamplingProfiler.h (227737 => 227738)


--- trunk/Source/_javascript_Core/runtime/SamplingProfiler.h	2018-01-29 17:45:17 UTC (rev 227737)
+++ trunk/Source/_javascript_Core/runtime/SamplingProfiler.h	2018-01-29 17:47:30 UTC (rev 227738)
@@ -39,7 +39,6 @@
 
 namespace JSC {
 
-class RegExp;
 class VM;
 class ExecutableBase;
 
@@ -69,7 +68,6 @@
     enum class FrameType { 
         Executable,
         Host,
-        RegExp,
         C,
         Unknown
     };
@@ -87,7 +85,6 @@
         void* cCodePC { nullptr };
         ExecutableBase* executable { nullptr };
         JSObject* callee { nullptr };
-        RegExp* regExp { nullptr };
 
         struct CodeLocation {
             bool hasCodeBlockHash() const
@@ -144,7 +141,6 @@
         void* topPC;
         bool topFrameIsLLInt;
         void* llintPC;
-        RegExp* regExp;
         Vector<UnprocessedStackFrame> frames;
     };
 
@@ -160,7 +156,7 @@
     };
 
     SamplingProfiler(VM&, RefPtr<Stopwatch>&&);
-    ~SamplingProfiler() = default;
+    ~SamplingProfiler();
     void noticeJSLockAcquisition();
     void noticeVMEntry();
     void shutdown();
@@ -189,7 +185,7 @@
 private:
     void createThreadIfNecessary(const AbstractLocker&);
     void timerLoop();
-    Seconds takeSample(const AbstractLocker&);
+    void takeSample(const AbstractLocker&, Seconds& stackTraceProcessingTime);
 
     VM& m_vm;
     WeakRandom m_weakRandom;
@@ -201,8 +197,8 @@
     Lock m_lock;
     RefPtr<Thread> m_thread;
     RefPtr<Thread> m_jscExecutionThread;
-    bool m_isPaused { false };
-    bool m_isShutDown { false };
+    bool m_isPaused;
+    bool m_isShutDown;
     bool m_needsReportAtExit { false };
     HashSet<JSCell*> m_liveCellPointers;
     Vector<UnprocessedStackFrame> m_currentFrames;

Modified: trunk/Source/_javascript_Core/runtime/VM.h (227737 => 227738)


--- trunk/Source/_javascript_Core/runtime/VM.h	2018-01-29 17:45:17 UTC (rev 227737)
+++ trunk/Source/_javascript_Core/runtime/VM.h	2018-01-29 17:47:30 UTC (rev 227738)
@@ -118,7 +118,6 @@
 class LLIntOffsetsExtractor;
 class NativeExecutable;
 class PromiseDeferredTimer;
-class RegExp;
 class RegExpCache;
 class Register;
 class RegisterAtOffsetList;
@@ -637,7 +636,7 @@
     Instruction* targetInterpreterPCForThrow;
     uint32_t osrExitIndex;
     void* osrExitJumpDestination;
-    RegExp* currentlyExecutingRegExp { nullptr };
+    bool isExecutingInRegExpJIT { false };
 
     // The threading protocol here is as follows:
     // - You can call scratchBufferForSize from any thread.

Modified: trunk/Source/_javascript_Core/yarr/YarrJIT.cpp (227737 => 227738)


--- trunk/Source/_javascript_Core/yarr/YarrJIT.cpp	2018-01-29 17:45:17 UTC (rev 227737)
+++ trunk/Source/_javascript_Core/yarr/YarrJIT.cpp	2018-01-29 17:47:30 UTC (rev 227738)
@@ -29,6 +29,7 @@
 #include <wtf/ASCIICType.h>
 #include "LinkBuffer.h"
 #include "Options.h"
+#include "VM.h"
 #include "Yarr.h"
 #include "YarrCanonicalize.h"
 
@@ -40,7 +41,7 @@
 
 template<YarrJITCompileMode compileMode>
 class YarrGenerator : private MacroAssembler {
-    friend void jitCompile(YarrCodeBlock& jitObject, const String& pattern, unsigned& numSubpatterns, const char*& error, bool ignoreCase, bool multiline);
+    friend void jitCompile(VM*, YarrCodeBlock& jitObject, const String& pattern, unsigned& numSubpatterns, const char*& error, bool ignoreCase, bool multiline);
 
 #if CPU(ARM)
     static const RegisterID input = ARMRegisters::r0;
@@ -3336,10 +3337,14 @@
 #elif CPU(MIPS)
         // Do nothing.
 #endif
+
+        store8(TrustedImm32(1), &m_vm->isExecutingInRegExpJIT);
     }
 
     void generateReturn()
     {
+        store8(TrustedImm32(0), &m_vm->isExecutingInRegExpJIT);
+
 #if CPU(X86_64)
 #if OS(WINDOWS)
         // Store the return value in the allocated space pointed by rcx.
@@ -3386,8 +3391,9 @@
     }
 
 public:
-    YarrGenerator(YarrPattern& pattern, YarrCharSize charSize)
-        : m_pattern(pattern)
+    YarrGenerator(VM* vm, YarrPattern& pattern, YarrCharSize charSize)
+        : m_vm(vm)
+        , m_pattern(pattern)
         , m_charSize(charSize)
         , m_decodeSurrogatePairs(m_charSize == Char16 && m_pattern.unicode())
         , m_unicodeIgnoreCase(m_pattern.unicode() && m_pattern.ignoreCase())
@@ -3489,6 +3495,8 @@
     }
 
 private:
+    VM* m_vm;
+
     YarrPattern& m_pattern;
 
     YarrCharSize m_charSize;
@@ -3552,12 +3560,12 @@
     }
 }
 
-void jitCompile(YarrPattern& pattern, YarrCharSize charSize, YarrCodeBlock& jitObject, YarrJITCompileMode mode)
+void jitCompile(YarrPattern& pattern, YarrCharSize charSize, VM* vm, YarrCodeBlock& jitObject, YarrJITCompileMode mode)
 {
     if (mode == MatchOnly)
-        YarrGenerator<MatchOnly>(pattern, charSize).compile(jitObject);
+        YarrGenerator<MatchOnly>(vm, pattern, charSize).compile(jitObject);
     else
-        YarrGenerator<IncludeSubpatterns>(pattern, charSize).compile(jitObject);
+        YarrGenerator<IncludeSubpatterns>(vm, pattern, charSize).compile(jitObject);
 
     if (auto failureReason = jitObject.failureReason()) {
         if (Options::dumpCompiledRegExpPatterns())

Modified: trunk/Source/_javascript_Core/yarr/YarrJIT.h (227737 => 227738)


--- trunk/Source/_javascript_Core/yarr/YarrJIT.h	2018-01-29 17:45:17 UTC (rev 227737)
+++ trunk/Source/_javascript_Core/yarr/YarrJIT.h	2018-01-29 17:47:30 UTC (rev 227738)
@@ -45,6 +45,7 @@
 
 namespace JSC {
 
+class VM;
 class ExecutablePool;
 
 namespace Yarr {
@@ -204,7 +205,7 @@
     MatchOnly,
     IncludeSubpatterns
 };
-void jitCompile(YarrPattern&, YarrCharSize, YarrCodeBlock& jitObject, YarrJITCompileMode = IncludeSubpatterns);
+void jitCompile(YarrPattern&, YarrCharSize, VM*, YarrCodeBlock& jitObject, YarrJITCompileMode = IncludeSubpatterns);
 
 } } // namespace JSC::Yarr
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to