Changeset 247339 in webkit
- Timestamp:
- Jul 10, 2019 6:18:14 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r247337 r247339 1 2019-07-10 Robin Morisset <rmorisset@apple.com> 2 3 [WHLSL] The recursion checker should not have quadratic complexity 4 https://bugs.webkit.org/show_bug.cgi?id=199688 5 6 Reviewed by Saam Barati. 7 8 I fix it by using two different hash sets, tracking which functions we have started visiting, and which we have finished visiting. 9 The difference are those that are currently "on the stack", and calling any of those is an error. 10 As a bonus, I also overrode visit(Program&), so that we only bother visiting function definitions. 11 12 On whlsl-compute.html ran 5 times, this patch reduces the time spent in the recursion checker from 26ms to 12ms. 13 It is likely to be a much bigger win on larger programs (since it took the complexity from quadratic to linear). 14 15 No new tests as there is no intended functional change. 16 17 * Modules/webgpu/WHLSL/WHLSLRecursionChecker.cpp: 18 1 19 2019-07-10 Sihui Liu <sihui_liu@apple.com> 2 20 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLRecursionChecker.cpp
r247254 r247339 41 41 class RecursionChecker : public Visitor { 42 42 private: 43 void visit(Program& program) override 44 { 45 for (auto& functionDefinition : program.functionDefinitions()) 46 checkErrorAndVisit(functionDefinition); 47 } 48 43 49 void visit(AST::FunctionDefinition& functionDefinition) override 44 50 { 45 auto addResult = m_visitingSet.add(&functionDefinition); 51 if (m_finishedVisiting.contains(&functionDefinition)) 52 return; 53 54 auto addResult = m_startedVisiting.add(&functionDefinition); 46 55 if (!addResult.isNewEntry) { 47 56 setError(); … … 50 59 51 60 Visitor::visit(functionDefinition); 52 if (error())53 return;54 61 55 auto success = m_visitingSet.remove(&functionDefinition); 56 ASSERT_UNUSED(success, success); 62 { 63 auto addResult = m_finishedVisiting.add(&functionDefinition); 64 ASSERT_UNUSED(addResult, addResult.isNewEntry); 65 } 57 66 } 58 67 … … 64 73 } 65 74 66 HashSet<AST::FunctionDefinition*> m_visitingSet; 75 HashSet<AST::FunctionDefinition*> m_startedVisiting; 76 HashSet<AST::FunctionDefinition*> m_finishedVisiting; 67 77 }; 68 78
Note: See TracChangeset
for help on using the changeset viewer.