WebKit Bugzilla
Attachment 373343 Details for
Bug 198186
: [WHLSL] Standard library is too big to directly include in WebCore
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Without standard library changes
bug-198186-20190702114235.patch (text/plain), 64.72 KB, created by
Myles C. Maxfield
on 2019-07-02 11:42:38 PDT
(
hide
)
Description:
Without standard library changes
Filename:
MIME Type:
Creator:
Myles C. Maxfield
Created:
2019-07-02 11:42:38 PDT
Size:
64.72 KB
patch
obsolete
>Subversion Revision: 247064 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 57e5e77e6d3e2cf7c0195a48a21f2787e87e653b..e341b7b0ac49d2104bead436e3f4760390c9df88 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,103 @@ >+2019-07-02 Myles C. Maxfield <mmaxfield@apple.com> >+ >+ [WHLSL] Standard library is too big to directly include in WebCore >+ https://bugs.webkit.org/show_bug.cgi?id=198186 >+ <rdar://problem/51288898> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This patch adds almost the entire remainder of the standard library. There are a few >+ pieces missing: >+ - step() because of https://bugs.webkit.org/show_bug.cgi?id=199289 >+ - sign() also because of https://bugs.webkit.org/show_bug.cgi?id=199289 >+ - faceforward() because it calls sign() >+ - Some of the more rarely-used texturing functions (e.g. Gather()) https://bugs.webkit.org/show_bug.cgi?id=195813 >+ - RWTextures https://bugs.webkit.org/show_bug.cgi?id=198985 >+ >+ There were two problems with adding so many standard library functions: >+ - We didn't want to increase the WebCore binary size that much >+ - Compiling all the functions at runtime took 7 seconds, which is much too long >+ >+ This patch addresses the first problem by gzipping the standard library before including it in the binary. >+ At runtime, we use libcompression to unzip it. >+ >+ To address the second problem, we did some analysis and found that 14% of that 7 seconds was simply >+ destroying all the AST nodes. Even if we eliminated all processing of the AST, simply having the AST >+ of the entire standard library built and destroyed would still be too slow. Therefore, this patch limits >+ which parts of the standard library get parsed in the first place. All the functions in the standard library >+ file are sorted by name, and each group of functions with the same name are preceeded by a comment of the >+ form /* Functions named xyz */. At build time, a Python script looks for all these comments, and builds a >+ map from function name to character offset inside the file where those functions begin. At run time, we >+ parse the user program first, look for all function calls within it, and look up those function call names >+ in the map to see which part of the standard library holds those functions. We then parse just that part. >+ Because the standard library can call other functions in the standard library, we do this in a loop until >+ we have exhausted all the functions. >+ >+ Covered by existing tests. >+ >+ * DerivedSources-input.xcfilelist: >+ * DerivedSources-output.xcfilelist: >+ * DerivedSources.make: gzip the standard library, and add a build step to generate the offset map. >+ * Modules/webgpu/WHLSL/AST/WHLSLCallExpression.h: >+ (WebCore::WHLSL::AST::CallExpression::setOverloads): >+ (WebCore::WHLSL::AST::CallExpression::function): Every caller of this ASSERT()s the result. Might as well >+ move the ASSERT() into the function. >+ (WebCore::WHLSL::AST::CallExpression::setFunction): >+ * Modules/webgpu/WHLSL/Cocoa/WHLSLStandardLibraryUtilities.cpp: Added. >+ (WebCore::WHLSL::decompressStandardLibrary): Use libcompression. This is why this file is in a Cocoa/ >+ subfolder, and is listed in SourcesCocoa.txt instead of Sources.txt. >+ (WebCore::WHLSL::decompressAndDecodeStandardLibrary): >+ (WebCore::WHLSL::NameFinder::takeFunctionNames): >+ (WebCore::WHLSL::includeStandardLibrary): Include only the bits of the standard library which are relevant, >+ as described above. >+ * Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp: Only emit MSL code for functions which are actually >+ reached. The MSL compiler is a significant amount of our compile time, so reducing the size of the emitted >+ program can significantly improve compile times. >+ (WebCore::WHLSL::Metal::FunctionDefinitionWriter::visit): >+ (WebCore::WHLSL::Metal::sharedMetalFunctions): >+ (WebCore::WHLSL::Metal::metalFunctions): >+ * Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp: >+ (WebCore::WHLSL::Metal::writeNativeFunction): >+ - Change how load() and store() are written. We need explicit functions because we have explicit atomic >+ types, which HLSL doesn't have. load() and store() aren't present in HLSL. >+ - Delete f16tof32 because they're probably not important and are not obvious how to implement. We can re-add >+ them again later if necessary. >+ - Various fixes to make us generate the correct MSL code for each standard library function. >+ * Modules/webgpu/WHLSL/WHLSLBuildStandardLibraryFunctionMap.py: Added. Build the function map as described >+ above. >+ * Modules/webgpu/WHLSL/WHLSLChecker.cpp: >+ (WebCore::WHLSL::resolveByInstantiation): Previously, the standard library included an operator== for two >+ pointers. However, that function should be generated by the compiler instead. This fixes the bug in the >+ compiler which allows the compiler to correctly generate the right function. This also prompted me to file >+ https://bugs.webkit.org/show_bug.cgi?id=199335 >+ (WebCore::WHLSL::checkOperatorOverload): >+ (WebCore::WHLSL::Checker::visit): >+ * Modules/webgpu/WHLSL/WHLSLFunctionStageChecker.cpp: Update to the new function() signature. >+ * Modules/webgpu/WHLSL/WHLSLLexer.h: Add a new position() method to the lexer. This isn't actually used >+ in this patch, but it's useful when doing some analysis during parsing. >+ (WebCore::WHLSL::Lexer::Lexer): >+ (WebCore::WHLSL::Lexer::consumeToken): >+ (WebCore::WHLSL::Lexer::peek const): >+ (WebCore::WHLSL::Lexer::peekFurther const): >+ (WebCore::WHLSL::Lexer::position const): >+ (WebCore::WHLSL::Lexer::state const): >+ (WebCore::WHLSL::Lexer::setState): >+ (WebCore::WHLSL::Lexer::isFullyConsumed const): Fixes a bug where isFullyConsumed() might return true even >+ when there is a token in the ring buffer. >+ (WebCore::WHLSL::Lexer::peek): Deleted. >+ (WebCore::WHLSL::Lexer::peekFurther): Deleted. >+ * Modules/webgpu/WHLSL/WHLSLNameResolver.cpp: >+ (WebCore::WHLSL::NameResolver::visit): Drive-by partial fix of https://bugs.webkit.org/show_bug.cgi?id=199347 >+ * Modules/webgpu/WHLSL/WHLSLPrepare.cpp: Call includeStandardLibrary(). >+ (WebCore::WHLSL::prepareShared): >+ * Modules/webgpu/WHLSL/WHLSLPreserveVariableLifetimes.cpp: >+ * Modules/webgpu/WHLSL/WHLSLRecursionChecker.cpp: >+ * Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt: >+ * Modules/webgpu/WHLSL/WHLSLStandardLibraryFunctionMap.h: Copied from Source/WebCore/Modules/webgpu/WHLSL/WHLSLRecursionChecker.cpp. >+ * Modules/webgpu/WHLSL/WHLSLStandardLibraryUtilities.h: Copied from Source/WebCore/Modules/webgpu/WHLSL/WHLSLRecursionChecker.cpp. >+ * SourcesCocoa.txt: >+ * WebCore.xcodeproj/project.pbxproj: >+ > 2019-07-02 Takashi Komori <Takashi.Komori@sony.com> > > [Curl] Fix CookieJarCurl::getRawCookie. >diff --git a/Source/WebCore/DerivedSources-input.xcfilelist b/Source/WebCore/DerivedSources-input.xcfilelist >index 57c537c3ec9d428227e8de5e88163569b7607bce..c69d3dd417bbd924f9522c14748ce81e27d013d1 100644 >--- a/Source/WebCore/DerivedSources-input.xcfilelist >+++ b/Source/WebCore/DerivedSources-input.xcfilelist >@@ -345,6 +345,7 @@ $(PROJECT_DIR)/Modules/webgpu/GPUVertexAttributeDescriptor.idl > $(PROJECT_DIR)/Modules/webgpu/GPUVertexBufferDescriptor.idl > $(PROJECT_DIR)/Modules/webgpu/GPUVertexInputDescriptor.idl > $(PROJECT_DIR)/Modules/webgpu/NavigatorGPU.idl >+$(PROJECT_DIR)/Modules/webgpu/WHLSL/WHLSLBuildStandardLibraryFunctionMap.py > $(PROJECT_DIR)/Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt > $(PROJECT_DIR)/Modules/webgpu/WebGPU.idl > $(PROJECT_DIR)/Modules/webgpu/WebGPUAdapter.idl >diff --git a/Source/WebCore/DerivedSources-output.xcfilelist b/Source/WebCore/DerivedSources-output.xcfilelist >index d0e0a8f27f83e68946f8eb043163c6609c7d7422..37c3c8b1ba52b2630f1f053f2b052535cdc50cb7 100644 >--- a/Source/WebCore/DerivedSources-output.xcfilelist >+++ b/Source/WebCore/DerivedSources-output.xcfilelist >@@ -2095,6 +2095,7 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/UserAgentScripts.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/UserAgentScriptsData.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/UserAgentStyleSheets.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/WHLSLStandardLibrary.h >+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/WHLSLStandardLibraryFunctionMap.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/WebCoreJSBuiltinInternals.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/WebCoreJSBuiltinInternals.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/WebCoreJSBuiltins.cpp >diff --git a/Source/WebCore/DerivedSources.make b/Source/WebCore/DerivedSources.make >index d88aed458f0ef6eae31478e1e8b8071fceed91df..7eeb427c27d18ac4cb87c9fb2fef03ee06bf666d 100644 >--- a/Source/WebCore/DerivedSources.make >+++ b/Source/WebCore/DerivedSources.make >@@ -1636,10 +1636,13 @@ $(GENERATE_SETTINGS_PATTERNS) : $(WebCore)/Scripts/GenerateSettings.rb $(GENERAT > > # WHLSL Standard Library > >-all : WHLSLStandardLibrary.h >+all : WHLSLStandardLibrary.h WHLSLStandardLibraryFunctionMap.cpp > > WHLSLStandardLibrary.h : $(JavaScriptCore_SCRIPTS_DIR)/xxd.pl $(WebCore)/Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt >- $(PERL) $< WHLSLStandardLibrary $(WebCore)/Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt $@ >+ bash -c "$(PERL) $< WHLSLStandardLibrary <(gzip -cn $(WebCore)/Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt) $@" >+ >+WHLSLStandardLibraryFunctionMap.cpp : $(WebCore)/Modules/webgpu/WHLSL/WHLSLBuildStandardLibraryFunctionMap.py $(WebCore)/Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt >+ $(PYTHON) $< $(WebCore)/Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt $@ > > # -------- > >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLCallExpression.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLCallExpression.h >index 1a0d0274e4d3c72ed2f6c0c8ab1de194d5fe544c..17b94cdca071ce9a042970df7986399494855755 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLCallExpression.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLCallExpression.h >@@ -71,15 +71,19 @@ public: > Optional<Vector<std::reference_wrapper<FunctionDeclaration>, 1>>& overloads() { return m_overloads; } > void setOverloads(const Vector<std::reference_wrapper<FunctionDeclaration>, 1>& overloads) > { >- assert(!hasOverloads()); >+ ASSERT(!hasOverloads()); > m_overloads = overloads; > } > >- FunctionDeclaration* function() { return m_function; } >+ FunctionDeclaration& function() >+ { >+ ASSERT(m_function); >+ return *m_function; >+ } > > void setFunction(FunctionDeclaration& functionDeclaration) > { >- assert(!m_function); >+ ASSERT(!m_function); > m_function = &functionDeclaration; > } > >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/Cocoa/WHLSLStandardLibraryUtilities.cpp b/Source/WebCore/Modules/webgpu/WHLSL/Cocoa/WHLSLStandardLibraryUtilities.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..5c843741725ff2b20bd2c54940ef314b395fadc8 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/Cocoa/WHLSLStandardLibraryUtilities.cpp >@@ -0,0 +1,179 @@ >+/* >+ * Copyright (C) 2019 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. AND ITS CONTRIBUTORS ``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 ITS 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. >+ */ >+ >+#include "config.h" >+#include "WHLSLStandardLibraryUtilities.h" >+ >+#if ENABLE(WEBGPU) >+ >+#include "WHLSLCallExpression.h" >+#include "WHLSLParser.h" >+#include "WHLSLStandardLibrary.h" >+#include "WHLSLStandardLibraryFunctionMap.h" >+#include "WHLSLVisitor.h" >+#include <compression.h> >+#include <wtf/HashSet.h> >+#include <wtf/NeverDestroyed.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+static Vector<LChar> decompressStandardLibrary() >+{ >+ Vector<LChar> result; >+ >+ // Parse the gzip header. >+ auto checks = [&]() { >+ return sizeof(WHLSLStandardLibrary) >= 10 && WHLSLStandardLibrary[0] == 0x1f && WHLSLStandardLibrary[1] == 0x8b && WHLSLStandardLibrary[2] == 0x8 && WHLSLStandardLibrary[3] == 0x0; >+ }; >+ ASSERT(checks()); >+ if (!checks()) >+ return { }; >+ >+ constexpr auto ignoredByteCount = 10; >+ >+ compression_stream stream; >+ auto status = compression_stream_init(&stream, COMPRESSION_STREAM_DECODE, COMPRESSION_ZLIB); >+ ASSERT(status == COMPRESSION_STATUS_OK); >+ if (status != COMPRESSION_STATUS_OK) >+ return { }; >+ stream.dst_ptr = result.data(); >+ stream.dst_size = result.size(); >+ stream.src_ptr = WHLSLStandardLibrary + ignoredByteCount; >+ stream.src_size = sizeof(WHLSLStandardLibrary) - ignoredByteCount; >+ size_t offset = 0; >+ >+ do { >+ uint8_t* originalDestinationPointer = stream.dst_ptr; >+ status = compression_stream_process(&stream, COMPRESSION_STREAM_FINALIZE); >+ uint8_t* newDestinationPointer = stream.dst_ptr; >+ offset += newDestinationPointer - originalDestinationPointer; >+ switch (status) { >+ case COMPRESSION_STATUS_OK: { >+ auto newSize = offset * 1.5 + 1; >+ if (newSize > result.size()) >+ result.grow(newSize); >+ stream.dst_ptr = result.data() + offset; >+ stream.dst_size = result.size() - offset; >+ break; >+ } >+ case COMPRESSION_STATUS_END: >+ status = compression_stream_destroy(&stream); >+ ASSERT(status == COMPRESSION_STATUS_OK); >+ if (status == COMPRESSION_STATUS_OK) { >+ result.shrink(stream.dst_ptr - result.data()); >+ return result; >+ } >+ return { }; >+ case COMPRESSION_STATUS_ERROR: >+ default: >+ ASSERT_NOT_REACHED(); >+ compression_stream_destroy(&stream); >+ return { }; >+ } >+ } while (true); >+} >+ >+static String decompressAndDecodeStandardLibrary() >+{ >+ auto decompressedStandardLibrary = decompressStandardLibrary(); >+ return String::fromUTF8(decompressedStandardLibrary.data(), decompressedStandardLibrary.size()); >+} >+ >+class NameFinder : public Visitor { >+public: >+ HashSet<String> takeFunctionNames() >+ { >+ HashSet<String> result; >+ std::swap(result, m_functionNames); >+ return result; >+ } >+ >+private: >+ void visit(AST::CallExpression& callExpression) override >+ { >+ m_functionNames.add(callExpression.name()); >+ Visitor::visit(callExpression); >+ } >+ >+ void visit(AST::PropertyAccessExpression& propertyAccessExpression) override >+ { >+ m_functionNames.add(propertyAccessExpression.getterFunctionName()); >+ m_functionNames.add(propertyAccessExpression.setterFunctionName()); >+ m_functionNames.add(propertyAccessExpression.anderFunctionName()); >+ Visitor::visit(propertyAccessExpression); >+ } >+ >+ HashSet<String> m_functionNames; >+}; >+ >+void includeStandardLibrary(Program& program, Parser& parser) >+{ >+ static NeverDestroyed<String> standardLibrary(decompressAndDecodeStandardLibrary()); >+ static NeverDestroyed<HashMap<String, SubstringLocation>> standardLibraryFunctionMap(computeStandardLibraryFunctionMap()); >+ >+ auto stringView = StringView(standardLibrary.get()).substring(0, firstFunctionOffsetInStandardLibrary()); >+ auto parseFailure = parser.parse(program, stringView, Parser::Mode::StandardLibrary); >+ ASSERT_UNUSED(parseFailure, !parseFailure); >+ >+ NameFinder nameFinder; >+ nameFinder.Visitor::visit(program); >+ HashSet<String> functionNames = nameFinder.takeFunctionNames(); >+ HashSet<String> allFunctionNames; >+ functionNames.add("operator cast"_str); >+ functionNames.add("ddx"_str); >+ functionNames.add("ddy"_str); >+ functionNames.add("DeviceMemoryBarrierWithGroupSync"_str); >+ functionNames.add("GroupMemoryBarrierWithGroupSync"_str); >+ functionNames.add("AllMemoryBarrierWithGroupSync"_str); >+ while (!functionNames.isEmpty()) { >+ auto nativeFunctionDeclarationsCount = program.nativeFunctionDeclarations().size(); >+ auto functionDefinitionsCount = program.functionDefinitions().size(); >+ for (const auto& name : functionNames) { >+ if (allFunctionNames.contains(name)) >+ continue; >+ auto iterator = standardLibraryFunctionMap.get().find(name); >+ if (iterator == standardLibraryFunctionMap.get().end()) >+ continue; >+ auto stringView = StringView(standardLibrary.get()).substring(iterator->value.start, iterator->value.end - iterator->value.start); >+ auto parseFailure = parser.parse(program, stringView, Parser::Mode::StandardLibrary); >+ ASSERT_UNUSED(parseFailure, !parseFailure); >+ allFunctionNames.add(name); >+ } >+ functionNames.clear(); >+ for ( ; nativeFunctionDeclarationsCount < program.nativeFunctionDeclarations().size(); ++nativeFunctionDeclarationsCount) >+ nameFinder.Visitor::visit(program.nativeFunctionDeclarations()[nativeFunctionDeclarationsCount]); >+ for ( ; functionDefinitionsCount < program.functionDefinitions().size(); ++functionDefinitionsCount) >+ nameFinder.Visitor::visit(program.functionDefinitions()[functionDefinitionsCount]); >+ functionNames = nameFinder.takeFunctionNames(); >+ } >+} >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp >index 94916b643ac99f756c0695e64634bd398e875e9a..0b5980f620a91e3d6165bca6937216e7f0f90115 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp >@@ -35,6 +35,7 @@ > #include "WHLSLTypeNamer.h" > #include "WHLSLVisitor.h" > #include <wtf/HashMap.h> >+#include <wtf/HashSet.h> > #include <wtf/SetForScope.h> > #include <wtf/text/StringBuilder.h> > >@@ -554,8 +555,7 @@ void FunctionDefinitionWriter::visit(AST::CallExpression& callExpression) > checkErrorAndVisit(argument); > argumentNames.append(takeLastValue()); > } >- ASSERT(callExpression.function()); >- auto iterator = m_functionMapping.find(callExpression.function()); >+ auto iterator = m_functionMapping.find(&callExpression.function()); > ASSERT(iterator != m_functionMapping.end()); > auto variableName = generateNextVariableName(); > if (!matches(callExpression.resolvedType(), m_intrinsics.voidType())) >@@ -763,7 +763,7 @@ struct SharedMetalFunctionsResult { > HashMap<AST::FunctionDeclaration*, String> functionMapping; > String metalFunctions; > }; >-static SharedMetalFunctionsResult sharedMetalFunctions(Program& program, TypeNamer& typeNamer) >+static SharedMetalFunctionsResult sharedMetalFunctions(Program& program, TypeNamer& typeNamer, const HashSet<AST::FunctionDeclaration*>& reachableFunctions) > { > StringBuilder stringBuilder; > >@@ -780,10 +780,12 @@ static SharedMetalFunctionsResult sharedMetalFunctions(Program& program, TypeNam > > { > FunctionDeclarationWriter functionDeclarationWriter(typeNamer, functionMapping); >- for (auto& nativeFunctionDeclaration : program.nativeFunctionDeclarations()) >- functionDeclarationWriter.visit(nativeFunctionDeclaration); >+ for (auto& nativeFunctionDeclaration : program.nativeFunctionDeclarations()) { >+ if (reachableFunctions.contains(&nativeFunctionDeclaration)) >+ functionDeclarationWriter.visit(nativeFunctionDeclaration); >+ } > for (auto& functionDefinition : program.functionDefinitions()) { >- if (!functionDefinition->entryPointType()) >+ if (!functionDefinition->entryPointType() && reachableFunctions.contains(&functionDefinition)) > functionDeclarationWriter.visit(functionDefinition); > } > stringBuilder.append(functionDeclarationWriter.toString()); >@@ -793,49 +795,89 @@ static SharedMetalFunctionsResult sharedMetalFunctions(Program& program, TypeNam > return { WTFMove(functionMapping), stringBuilder.toString() }; > } > >+class ReachableFunctionsGatherer : public Visitor { >+public: >+ void visit(AST::FunctionDeclaration& functionDeclaration) override >+ { >+ Visitor::visit(functionDeclaration); >+ m_reachableFunctions.add(&functionDeclaration); >+ } >+ >+ void visit(AST::CallExpression& callExpression) override >+ { >+ Visitor::visit(callExpression); >+ if (is<AST::FunctionDefinition>(callExpression.function())) >+ checkErrorAndVisit(downcast<AST::FunctionDefinition>(callExpression.function())); >+ else >+ checkErrorAndVisit(downcast<AST::NativeFunctionDeclaration>(callExpression.function())); >+ } >+ >+ HashSet<AST::FunctionDeclaration*> takeReachableFunctions() { return WTFMove(m_reachableFunctions); } >+ >+private: >+ HashSet<AST::FunctionDeclaration*> m_reachableFunctions; >+}; >+ > RenderMetalFunctions metalFunctions(Program& program, TypeNamer& typeNamer, MatchedRenderSemantics&& matchedSemantics, Layout& layout) > { >- auto sharedMetalFunctions = Metal::sharedMetalFunctions(program, typeNamer); >+ auto& vertexShaderEntryPoint = *matchedSemantics.vertexShader; >+ auto& fragmentShaderEntryPoint = *matchedSemantics.fragmentShader; >+ >+ ReachableFunctionsGatherer reachableFunctionsGatherer; >+ reachableFunctionsGatherer.Visitor::visit(vertexShaderEntryPoint); >+ reachableFunctionsGatherer.Visitor::visit(fragmentShaderEntryPoint); >+ auto reachableFunctions = reachableFunctionsGatherer.takeReachableFunctions(); >+ >+ auto sharedMetalFunctions = Metal::sharedMetalFunctions(program, typeNamer, reachableFunctions); > > StringBuilder stringBuilder; > stringBuilder.append(sharedMetalFunctions.metalFunctions); > >- auto* vertexShaderEntryPoint = matchedSemantics.vertexShader; >- auto* fragmentShaderEntryPoint = matchedSemantics.fragmentShader; >- > RenderFunctionDefinitionWriter functionDefinitionWriter(program.intrinsics(), typeNamer, sharedMetalFunctions.functionMapping, WTFMove(matchedSemantics), layout); >- for (auto& nativeFunctionDeclaration : program.nativeFunctionDeclarations()) >- functionDefinitionWriter.visit(nativeFunctionDeclaration); >- for (auto& functionDefinition : program.functionDefinitions()) >- functionDefinitionWriter.visit(functionDefinition); >+ for (auto& nativeFunctionDeclaration : program.nativeFunctionDeclarations()) { >+ if (reachableFunctions.contains(&nativeFunctionDeclaration)) >+ functionDefinitionWriter.visit(nativeFunctionDeclaration); >+ } >+ for (auto& functionDefinition : program.functionDefinitions()) { >+ if (reachableFunctions.contains(&functionDefinition)) >+ functionDefinitionWriter.visit(functionDefinition); >+ } > stringBuilder.append(functionDefinitionWriter.toString()); > > RenderMetalFunctions result; > result.metalSource = stringBuilder.toString(); >- result.mangledVertexEntryPointName = sharedMetalFunctions.functionMapping.get(vertexShaderEntryPoint); >- result.mangledFragmentEntryPointName = sharedMetalFunctions.functionMapping.get(fragmentShaderEntryPoint); >+ result.mangledVertexEntryPointName = sharedMetalFunctions.functionMapping.get(&vertexShaderEntryPoint); >+ result.mangledFragmentEntryPointName = sharedMetalFunctions.functionMapping.get(&fragmentShaderEntryPoint); > return result; > } > > ComputeMetalFunctions metalFunctions(Program& program, TypeNamer& typeNamer, MatchedComputeSemantics&& matchedSemantics, Layout& layout) > { >- auto sharedMetalFunctions = Metal::sharedMetalFunctions(program, typeNamer); >+ auto& entryPoint = *matchedSemantics.shader; >+ >+ ReachableFunctionsGatherer reachableFunctionsGatherer; >+ reachableFunctionsGatherer.Visitor::visit(entryPoint); >+ auto reachableFunctions = reachableFunctionsGatherer.takeReachableFunctions(); >+ >+ auto sharedMetalFunctions = Metal::sharedMetalFunctions(program, typeNamer, reachableFunctions); > > StringBuilder stringBuilder; > stringBuilder.append(sharedMetalFunctions.metalFunctions); > >- auto* entryPoint = matchedSemantics.shader; >- > ComputeFunctionDefinitionWriter functionDefinitionWriter(program.intrinsics(), typeNamer, sharedMetalFunctions.functionMapping, WTFMove(matchedSemantics), layout); >- for (auto& nativeFunctionDeclaration : program.nativeFunctionDeclarations()) >- functionDefinitionWriter.visit(nativeFunctionDeclaration); >- for (auto& functionDefinition : program.functionDefinitions()) >- functionDefinitionWriter.visit(functionDefinition); >+ for (auto& nativeFunctionDeclaration : program.nativeFunctionDeclarations()) { >+ if (reachableFunctions.contains(&nativeFunctionDeclaration)) >+ functionDefinitionWriter.visit(nativeFunctionDeclaration); >+ } >+ for (auto& functionDefinition : program.functionDefinitions()) { >+ if (reachableFunctions.contains(&functionDefinition)) >+ functionDefinitionWriter.visit(functionDefinition); >+ } > stringBuilder.append(functionDefinitionWriter.toString()); > > ComputeMetalFunctions result; > result.metalSource = stringBuilder.toString(); >- result.mangledEntryPointName = sharedMetalFunctions.functionMapping.get(entryPoint); >+ result.mangledEntryPointName = sharedMetalFunctions.functionMapping.get(&entryPoint); > return result; > } > >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp >index 3aec9ff80e4d654fa8e52704759cae764d809e82..f250faae46f00aa03d9cecaa671095fd69c0e25b 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp >@@ -135,20 +135,6 @@ String writeNativeFunction(AST::NativeFunctionDeclaration& nativeFunctionDeclara > > ASSERT(nativeFunctionDeclaration.parameters().size() == 1); > auto metalParameterName = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[0]->type()); >- auto& parameterType = nativeFunctionDeclaration.parameters()[0]->type()->unifyNode(); >- if (is<AST::NamedType>(parameterType)) { >- auto& parameterNamedType = downcast<AST::NamedType>(parameterType); >- if (is<AST::NativeTypeDeclaration>(parameterNamedType)) { >- auto& parameterNativeTypeDeclaration = downcast<AST::NativeTypeDeclaration>(parameterNamedType); >- if (parameterNativeTypeDeclaration.isAtomic()) { >- stringBuilder.append(makeString(metalReturnName, ' ', outputFunctionName, '(', metalParameterName, " x) {\n")); >- stringBuilder.append(" return atomic_load_explicit(&x, memory_order_relaxed);\n"); >- stringBuilder.append("}\n"); >- return stringBuilder.toString(); >- } >- } >- } >- > stringBuilder.append(makeString(metalReturnName, ' ', outputFunctionName, '(', metalParameterName, " x) {\n")); > stringBuilder.append(makeString(" return static_cast<", metalReturnName, ">(x);\n")); > stringBuilder.append("}\n"); >@@ -363,11 +349,6 @@ String writeNativeFunction(AST::NativeFunctionDeclaration& nativeFunctionDeclara > return stringBuilder.toString(); > } > >- if (nativeFunctionDeclaration.name() == "f16tof32" || nativeFunctionDeclaration.name() == "f32tof16") { >- // FIXME: https://bugs.webkit.org/show_bug.cgi?id=195813 Implement this >- notImplemented(); >- } >- > if (nativeFunctionDeclaration.name() == "AllMemoryBarrierWithGroupSync") { > ASSERT(!nativeFunctionDeclaration.parameters().size()); > stringBuilder.append(makeString("void ", outputFunctionName, "() {\n")); >@@ -406,7 +387,7 @@ String writeNativeFunction(AST::NativeFunctionDeclaration& nativeFunctionDeclara > auto fourthArgumentAddressSpace = fourthArgumentPointer.addressSpace(); > auto fourthArgumentPointee = typeNamer.mangledNameForType(fourthArgumentPointer.elementType()); > stringBuilder.append(makeString("void ", outputFunctionName, '(', toString(firstArgumentAddressSpace), ' ', firstArgumentPointee, "* object, ", secondArgument, " compare, ", thirdArgument, " desired, ", toString(fourthArgumentAddressSpace), ' ', fourthArgumentPointee, "* out) {\n")); >- stringBuilder.append(" atomic_compare_exchange_weak_explicit(object, &compare, desired, memory_order_relaxed);\n"); >+ stringBuilder.append(" atomic_compare_exchange_weak_explicit(object, &compare, desired, memory_order_relaxed, memory_order_relaxed);\n"); > stringBuilder.append(" *out = compare;\n"); > stringBuilder.append("}\n"); > return stringBuilder.toString(); >@@ -422,7 +403,7 @@ String writeNativeFunction(AST::NativeFunctionDeclaration& nativeFunctionDeclara > auto thirdArgumentPointee = typeNamer.mangledNameForType(thirdArgumentPointer.elementType()); > auto name = atomicName(nativeFunctionDeclaration.name().substring("Interlocked"_str.length())); > stringBuilder.append(makeString("void ", outputFunctionName, '(', toString(firstArgumentAddressSpace), ' ', firstArgumentPointee, "* object, ", secondArgument, " operand, ", toString(thirdArgumentAddressSpace), ' ', thirdArgumentPointee, "* out) {\n")); >- stringBuilder.append(makeString(" *out = atomic_fetch_", name, "_explicit(object, operand, memory_order_relaxed);\n")); >+ stringBuilder.append(makeString(" *out = atomic_", name, "_explicit(object, operand, memory_order_relaxed);\n")); > stringBuilder.append("}\n"); > return stringBuilder.toString(); > } >@@ -509,6 +490,26 @@ String writeNativeFunction(AST::NativeFunctionDeclaration& nativeFunctionDeclara > return stringBuilder.toString(); > } > >+ if (nativeFunctionDeclaration.name() == "load") { >+ ASSERT(nativeFunctionDeclaration.parameters().size() == 1); >+ auto metalParameterName = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[0]->type()); >+ auto metalReturnName = typeNamer.mangledNameForType(nativeFunctionDeclaration.type()); >+ stringBuilder.append(makeString(metalReturnName, ' ', outputFunctionName, '(', metalParameterName, " x) {\n")); >+ stringBuilder.append(" return atomic_load_explicit(x, memory_order_relaxed);\n"); >+ stringBuilder.append("}\n"); >+ return stringBuilder.toString(); >+ } >+ >+ if (nativeFunctionDeclaration.name() == "store") { >+ ASSERT(nativeFunctionDeclaration.parameters().size() == 2); >+ auto metalParameter1Name = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[0]->type()); >+ auto metalParameter2Name = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[1]->type()); >+ stringBuilder.append(makeString("void ", outputFunctionName, '(', metalParameter1Name, " x, ", metalParameter2Name, " y) {\n")); >+ stringBuilder.append(" atomic_store_explicit(x, y, memory_order_relaxed);\n"); >+ stringBuilder.append("}\n"); >+ return stringBuilder.toString(); >+ } >+ > if (nativeFunctionDeclaration.name() == "GetDimensions") { > auto& textureType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(nativeFunctionDeclaration.parameters()[0]->type()->unifyNode())); > >@@ -533,7 +534,7 @@ String writeNativeFunction(AST::NativeFunctionDeclaration& nativeFunctionDeclara > ++index; > } > String numberOfLevelsTypeName; >- if (!textureType.isWritableTexture()) { >+ if (!textureType.isWritableTexture() && textureType.textureDimension() != 1) { > numberOfLevelsTypeName = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[index]->type()); > ++index; > } >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLBuildStandardLibraryFunctionMap.py b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLBuildStandardLibraryFunctionMap.py >new file mode 100644 >index 0000000000000000000000000000000000000000..1ca696d573118a1e57f862a89e35ddef01f0c894 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLBuildStandardLibraryFunctionMap.py >@@ -0,0 +1,107 @@ >+#!/usr/bin/env python >+# >+# Copyright (C) 2014 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. AND ITS CONTRIBUTORS ``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 ITS 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. >+ >+import sys >+import re >+ >+regularExpression = re.compile("/\* Functions named (.*) \*/") >+ >+infile = open(sys.argv[1], "r") >+contents = infile.read() >+infile.close() >+ >+outfile = open(sys.argv[2], "w") >+outfile.write(""" >+/* >+ * Copyright (C) 2019 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. AND ITS CONTRIBUTORS ``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 ITS 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. >+ */ >+ >+#include "config.h" >+#include "WHLSLStandardLibraryFunctionMap.h" >+ >+#if ENABLE(WEBGPU) >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+HashMap<String, SubstringLocation> computeStandardLibraryFunctionMap() >+{ >+ HashMap<String, SubstringLocation> result; >+""") >+previous = 0 >+previousName = "" >+boundary = 0 >+for match in regularExpression.finditer(contents): >+ if previous == 0: >+ previous = match.start() >+ boundary = previous >+ previousName = match.group(1) >+ continue >+ outfile.write(" result.add(\"" + previousName + "\"_str, SubstringLocation { " + str(previous) + ", " + str(match.start()) + " });\n") >+ previous = match.start() >+ previousName = match.group(1) >+outfile.write(" result.add(\"" + previousName + "\"_str, SubstringLocation { " + str(previous) + ", " + str(len(contents)) + " });\n") >+outfile.write(""" >+ return result; >+} >+ >+unsigned firstFunctionOffsetInStandardLibrary() >+{ >+""") >+ >+outfile.write(" return " + str(boundary) + ";\n") >+ >+outfile.write(""" >+} >+ >+} >+ >+} >+ >+#endif >+""") >+outfile.close() >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp >index 22bf60bc818b8179810bbe512fa9dc4cf9927ee4..c53528b5c787aee15c201ed03b62b0d3bfcf8ba3 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp >@@ -194,7 +194,8 @@ static Optional<AST::NativeFunctionDeclaration> resolveByInstantiation(const Str > } else if (name == "operator==" && types.size() == 2) { > auto acceptability = [](ResolvingType& resolvingType) -> Acceptability { > return resolvingType.visit(WTF::makeVisitor([](UniqueRef<AST::UnnamedType>& unnamedType) -> Acceptability { >- return is<AST::ReferenceType>(static_cast<AST::UnnamedType&>(unnamedType)) ? Acceptability::Yes : Acceptability::No; >+ auto& unifyNode = unnamedType->unifyNode(); >+ return is<AST::UnnamedType>(unifyNode) && is<AST::ReferenceType>(downcast<AST::UnnamedType>(unifyNode)) ? Acceptability::Yes : Acceptability::No; > }, [](RefPtr<ResolvableTypeReference>& resolvableTypeReference) -> Acceptability { > return is<AST::NullLiteralType>(resolvableTypeReference->resolvableType()) ? Acceptability::Maybe : Acceptability::No; > })); >@@ -416,7 +417,7 @@ static bool checkOperatorOverload(const AST::FunctionDefinition& functionDefinit > || functionDefinition.name() == "operator|" > || functionDefinition.name() == "operator^" > || functionDefinition.name() == "operator<<" >- || functionDefinition.name() == "opreator>>") >+ || functionDefinition.name() == "operator>>") > return functionDefinition.parameters().size() == 2; > if (functionDefinition.name() == "operator~") > return functionDefinition.parameters().size() == 1; >@@ -1137,7 +1138,6 @@ void Checker::visit(AST::VariableReference& variableReference) > > void Checker::visit(AST::Return& returnStatement) > { >- ASSERT(returnStatement.function()); > if (returnStatement.value()) { > auto valueInfo = recurseAndGetInfo(*returnStatement.value()); > if (!valueInfo) >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLFunctionStageChecker.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLFunctionStageChecker.cpp >index f4ce762dd6c32e1014d779a12357a454efe68066..f08efaa392bc0bf5e15a4329a28bea307d256d99 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLFunctionStageChecker.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLFunctionStageChecker.cpp >@@ -49,18 +49,16 @@ public: > public: > void visit(AST::CallExpression& callExpression) override > { >- ASSERT(callExpression.function()); >- if ((callExpression.function() == &m_intrinsics.ddx() || callExpression.function() == &m_intrinsics.ddy()) && m_entryPointType != AST::EntryPointType::Fragment) { >+ if ((&callExpression.function() == &m_intrinsics.ddx() || &callExpression.function() == &m_intrinsics.ddy()) && m_entryPointType != AST::EntryPointType::Fragment) { > setError(); > return; > } >- if ((callExpression.function() == &m_intrinsics.allMemoryBarrier() || callExpression.function() == &m_intrinsics.deviceMemoryBarrier() || callExpression.function() == &m_intrinsics.groupMemoryBarrier()) >+ if ((&callExpression.function() == &m_intrinsics.allMemoryBarrier() || &callExpression.function() == &m_intrinsics.deviceMemoryBarrier() || &callExpression.function() == &m_intrinsics.groupMemoryBarrier()) > && m_entryPointType != AST::EntryPointType::Compute) { > setError(); > return; > } >- ASSERT(callExpression.function()); >- Visitor::visit(*callExpression.function()); >+ Visitor::visit(callExpression.function()); > } > > AST::EntryPointType m_entryPointType; >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLLexer.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLLexer.h >index bbde9fe4f8bc4b1e2c35b05909c511fe47b22c1b..4f213d19b5065f7478a4b97caeb6df8f47404e5f 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLLexer.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLLexer.h >@@ -46,7 +46,9 @@ public: > : m_stringView(stringView) > { > skipWhitespaceAndComments(); >+ m_offsetRingBuffer[0] = m_offset; > m_ringBuffer[0] = consumeTokenFromStream(); >+ m_offsetRingBuffer[1] = m_offset; > m_ringBuffer[1] = consumeTokenFromStream(); > } > >@@ -180,25 +182,29 @@ public: > Optional<Token> consumeToken() > { > auto result = m_ringBuffer[m_ringBufferIndex]; >+ m_offsetRingBuffer[m_ringBufferIndex] = m_offset; > m_ringBuffer[m_ringBufferIndex] = consumeTokenFromStream(); > m_ringBufferIndex = (m_ringBufferIndex + 1) % 2; > return result; > } > >- Optional<Token> peek() >+ Optional<Token> peek() const > { > return m_ringBuffer[m_ringBufferIndex]; > } > >- Optional<Token> peekFurther() >+ Optional<Token> peekFurther() const > { > return m_ringBuffer[(m_ringBufferIndex + 1) % 2]; > } > >+ Optional<unsigned> position() const { return m_offsetRingBuffer[m_ringBufferIndex]; } >+ > // FIXME: We should not need this > // https://bugs.webkit.org/show_bug.cgi?id=198357 > struct State { > Optional<Token> ringBuffer[2]; >+ Optional<unsigned> m_offsetRingBuffer[2]; > unsigned ringBufferIndex; > unsigned offset; > unsigned lineNumber; >@@ -209,6 +215,8 @@ public: > State state; > state.ringBuffer[0] = m_ringBuffer[0]; > state.ringBuffer[1] = m_ringBuffer[1]; >+ state.m_offsetRingBuffer[0] = m_offsetRingBuffer[0]; >+ state.m_offsetRingBuffer[1] = m_offsetRingBuffer[1]; > state.ringBufferIndex = m_ringBufferIndex; > state.offset = m_offset; > state.lineNumber = m_lineNumber; >@@ -219,6 +227,8 @@ public: > { > m_ringBuffer[0] = state.ringBuffer[0]; > m_ringBuffer[1] = state.ringBuffer[1]; >+ m_offsetRingBuffer[0] = state.m_offsetRingBuffer[0]; >+ m_offsetRingBuffer[1] = state.m_offsetRingBuffer[1]; > m_ringBufferIndex = state.ringBufferIndex; > m_offset = state.offset; > m_lineNumber = state.lineNumber; >@@ -229,6 +239,8 @@ public: > { > m_ringBuffer[0] = WTFMove(state.ringBuffer[0]); > m_ringBuffer[1] = WTFMove(state.ringBuffer[1]); >+ m_offsetRingBuffer[0] = WTFMove(state.m_offsetRingBuffer[0]); >+ m_offsetRingBuffer[1] = WTFMove(state.m_offsetRingBuffer[1]); > m_ringBufferIndex = WTFMove(state.ringBufferIndex); > m_offset = WTFMove(state.offset); > m_lineNumber = WTFMove(state.lineNumber); >@@ -236,7 +248,7 @@ public: > > bool isFullyConsumed() const > { >- return m_offset == m_stringView.length(); >+ return !peek(); > } > > String errorString(const Token& token, const String& message) >@@ -276,6 +288,7 @@ private: > > StringView m_stringView; > Optional<Token> m_ringBuffer[2]; >+ Optional<unsigned> m_offsetRingBuffer[2]; > unsigned m_ringBufferIndex { 0 }; > unsigned m_offset { 0 }; > unsigned m_lineNumber { 0 }; >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp >index 016b8550cb2bb9903163901640aa29cb8e75b1f4..06e6391df8800b0ae1b3b1871021966bcd3fb2c7 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp >@@ -82,6 +82,8 @@ void NameResolver::visit(AST::TypeReference& typeReference) > } > > Visitor::visit(typeReference); >+ if (error()) >+ return; > if (typeReference.maybeResolvedType()) // FIXME: https://bugs.webkit.org/show_bug.cgi?id=198161 Shouldn't we know by now whether the type has been resolved or not? > return; > >@@ -105,6 +107,8 @@ void NameResolver::visit(AST::FunctionDefinition& functionDefinition) > NameContext newNameContext(&m_nameContext); > NameResolver newNameResolver(*this, newNameContext); > checkErrorAndVisit(functionDefinition.type()); >+ if (error()) >+ return; > for (auto& parameter : functionDefinition.parameters()) > newNameResolver.checkErrorAndVisit(parameter); > newNameResolver.checkErrorAndVisit(functionDefinition.block()); >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.cpp >index ed9930b6993b64a528806897fc9b821ba4a7ad95..228a48fc593a7793913f899f16d0d92fa5fb8f28 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.cpp >@@ -46,7 +46,7 @@ > #include "WHLSLRecursionChecker.h" > #include "WHLSLRecursiveTypeChecker.h" > #include "WHLSLSemanticMatcher.h" >-#include "WHLSLStandardLibrary.h" >+#include "WHLSLStandardLibraryUtilities.h" > #include "WHLSLStatementBehaviorChecker.h" > #include "WHLSLSynthesizeArrayOperatorLength.h" > #include "WHLSLSynthesizeConstructors.h" >@@ -110,17 +110,12 @@ static Optional<Program> prepareShared(String& whlslSource) > { > Program program; > Parser parser; >- auto standardLibrary = String::fromUTF8(WHLSLStandardLibrary, sizeof(WHLSLStandardLibrary)); >- auto parseStdLibFailure = parser.parse(program, standardLibrary, Parser::Mode::StandardLibrary); >- if (!ASSERT_DISABLED && parseStdLibFailure) { >- dataLogLn("failed to parse the standard library: ", *parseStdLibFailure); >- RELEASE_ASSERT_NOT_REACHED(); >- } > if (auto parseFailure = parser.parse(program, whlslSource, Parser::Mode::User)) { > if (dumpPassFailure) > dataLogLn("failed to parse the program: ", *parseFailure); > return WTF::nullopt; > } >+ includeStandardLibrary(program, parser); > > if (!dumpASTBetweenEachPassIfNeeded(program, "AST after parsing")) > dumpASTAfterParsingIfNeeded(program); >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPreserveVariableLifetimes.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPreserveVariableLifetimes.cpp >index fc754bbb2fbbaaf6059c68349847afc2b0c96838..6369a69d40008fa0417ebd1f2d7e1ae7e555ba72 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPreserveVariableLifetimes.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPreserveVariableLifetimes.cpp >@@ -188,7 +188,7 @@ public: > > // This works because it's illegal to call an entrypoint. Therefore, we can only > // call functions where we've already appended this struct as its final parameter. >- if (!callExpression.function()->isNativeFunctionDeclaration()) >+ if (!callExpression.function().isNativeFunctionDeclaration()) > callExpression.arguments().append(makeStructVariableReference()); > } > >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLRecursionChecker.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLRecursionChecker.cpp >index 43cf9cbd5215b8bfb0db770063aff68aecb80eb9..cd0800d36192e48fc537723aa80a0ea9f632c5f6 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLRecursionChecker.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLRecursionChecker.cpp >@@ -56,8 +56,7 @@ private: > > void visit(AST::CallExpression& callExpression) override > { >- ASSERT(callExpression.function()); >- Visitor::visit(*callExpression.function()); >+ Visitor::visit(callExpression.function()); > } > > HashSet<AST::FunctionDefinition*> m_visitingSet; >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibraryFunctionMap.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibraryFunctionMap.h >new file mode 100644 >index 0000000000000000000000000000000000000000..bdbc3660bcd624cdf96737dd73afcb9838470647 >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibraryFunctionMap.h >@@ -0,0 +1,51 @@ >+/* >+ * Copyright (C) 2019 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. AND ITS CONTRIBUTORS ``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 ITS 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 >+ >+#if ENABLE(WEBGPU) >+ >+#include <wtf/HashMap.h> >+#include <wtf/text/StringHash.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+struct SubstringLocation { >+ unsigned start; >+ unsigned end; >+}; >+ >+HashMap<String, SubstringLocation> computeStandardLibraryFunctionMap(); >+ >+unsigned firstFunctionOffsetInStandardLibrary(); >+ >+} // namespace WHLSL >+ >+} // namespace WebCore >+ >+#endif // ENABLE(WEBGPU) >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibraryUtilities.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibraryUtilities.h >new file mode 100644 >index 0000000000000000000000000000000000000000..63f16c5481dc1f72681f2f0dc427bcd0952e3f0f >--- /dev/null >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibraryUtilities.h >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2019 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. AND ITS CONTRIBUTORS ``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 ITS 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 >+ >+#if ENABLE(WEBGPU) >+ >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+namespace WHLSL { >+ >+class Parser; >+class Program; >+ >+void includeStandardLibrary(Program&, Parser&); >+ >+} >+ >+} >+ >+#endif >diff --git a/Source/WebCore/SourcesCocoa.txt b/Source/WebCore/SourcesCocoa.txt >index 7b1e575eab12d8155d46fee14b151381e3959014..657f7fdb582a486d51ce54cca3a81c4d50349de0 100644 >--- a/Source/WebCore/SourcesCocoa.txt >+++ b/Source/WebCore/SourcesCocoa.txt >@@ -27,6 +27,8 @@ Modules/plugins/QuickTimePluginReplacement.mm > Modules/plugins/YouTubePluginReplacement.cpp > Modules/webdatabase/cocoa/DatabaseManagerCocoa.mm > >+Modules/webgpu/WHLSL/Cocoa/WHLSLStandardLibraryUtilities.cpp >+ > accessibility/ios/AccessibilityObjectIOS.mm > accessibility/ios/AXObjectCacheIOS.mm > accessibility/ios/WebAccessibilityObjectWrapperIOS.mm >@@ -564,6 +566,10 @@ platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm > > platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp > >+// Derived Sources >+ >+WHLSLStandardLibraryFunctionMap.cpp >+ > #if ENABLE_APPLE_PAY > > Modules/applepay/ApplePayContactField.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 5c849c758b0fbe04895deb6af2894fb28f889051..28ae0d8445e5816df03d982bf964e673af01548c 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -630,6 +630,7 @@ > 1C73A71521857587004CCEA5 /* TextDecorationThickness.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CB6B4F8217B83930093B9CD /* TextDecorationThickness.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 1C81B95A0E97330800266E07 /* InspectorController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C81B9560E97330800266E07 /* InspectorController.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 1C81B95C0E97330800266E07 /* InspectorClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C81B9580E97330800266E07 /* InspectorClient.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ 1C8D26D122C09E8300D125F3 /* libcompression.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 1C8D26D022C09CDE00D125F3 /* libcompression.tbd */; }; > 1CA19E160DC255CA0065A994 /* EventLoop.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CA19E150DC255CA0065A994 /* EventLoop.h */; }; > 1CAF34810A6C405200ABE06E /* WebScriptObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CAF347E0A6C405200ABE06E /* WebScriptObject.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 1CAF34820A6C405200ABE06E /* WebScriptObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1CAF347F0A6C405200ABE06E /* WebScriptObject.mm */; }; >@@ -6401,9 +6402,11 @@ > 1C3969CF1B74211E002BCFA7 /* FontCacheCoreText.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontCacheCoreText.cpp; sourceTree = "<group>"; }; > 1C43DE6822AB4B8A001527D9 /* LocalCurrentTraitCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalCurrentTraitCollection.h; sourceTree = "<group>"; }; > 1C43DE6A22AB4B8A001527D9 /* LocalCurrentTraitCollection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalCurrentTraitCollection.mm; sourceTree = "<group>"; }; >+ 1C50C49522C84F2400A6E4BE /* WHLSLStandardLibraryFunctionMap.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLStandardLibraryFunctionMap.cpp; sourceTree = "<group>"; }; > 1C59B0182238687900853805 /* WHLSLScopedSetAdder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLScopedSetAdder.h; sourceTree = "<group>"; }; > 1C66260E1C6E7CA600AB527C /* FontFace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontFace.cpp; sourceTree = "<group>"; }; > 1C66260F1C6E7CA600AB527C /* FontFace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontFace.h; sourceTree = "<group>"; }; >+ 1C6B95DD22C858A400E6F14F /* WHLSLBuildStandardLibraryFunctionMap.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = WHLSLBuildStandardLibraryFunctionMap.py; sourceTree = "<group>"; }; > 1C81B9560E97330800266E07 /* InspectorController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorController.h; sourceTree = "<group>"; }; > 1C81B9570E97330800266E07 /* InspectorController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorController.cpp; sourceTree = "<group>"; }; > 1C81B9580E97330800266E07 /* InspectorClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorClient.h; sourceTree = "<group>"; }; >@@ -6417,6 +6420,9 @@ > 1C86CA4C22AA19FF001BF961 /* WHLSLComputeDimensions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLComputeDimensions.h; sourceTree = "<group>"; }; > 1C86CA4E22AA23C9001BF961 /* GPUPipelineMetalConvertLayout.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GPUPipelineMetalConvertLayout.cpp; sourceTree = "<group>"; }; > 1C86CA4F22AA23C9001BF961 /* GPUPipelineMetalConvertLayout.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUPipelineMetalConvertLayout.h; sourceTree = "<group>"; }; >+ 1C8D26C922C0945300D125F3 /* WHLSLStandardLibraryUtilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLStandardLibraryUtilities.h; sourceTree = "<group>"; }; >+ 1C8D26CE22C0951300D125F3 /* WHLSLStandardLibraryUtilities.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLStandardLibraryUtilities.cpp; sourceTree = "<group>"; }; >+ 1C8D26D022C09CDE00D125F3 /* libcompression.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libcompression.tbd; path = usr/lib/libcompression.tbd; sourceTree = SDKROOT; }; > 1C904DF90BA9D2C80081E9D0 /* Version.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = "<group>"; }; > 1C9AE5CA21ED9DF50069D5F2 /* WHLSLHighZombieFinder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLHighZombieFinder.cpp; sourceTree = "<group>"; }; > 1C9AE5CB21ED9DF50069D5F2 /* WHLSLHighZombieFinder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLHighZombieFinder.h; sourceTree = "<group>"; }; >@@ -6446,6 +6452,7 @@ > 1CB6B4FB217B83940093B9CD /* TextUnderlineOffset.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TextUnderlineOffset.h; sourceTree = "<group>"; }; > 1CCDF5BB1990332400BCEBAD /* SVGToOTFFontConversion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGToOTFFontConversion.cpp; sourceTree = "<group>"; }; > 1CCDF5BC1990332400BCEBAD /* SVGToOTFFontConversion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGToOTFFontConversion.h; sourceTree = "<group>"; }; >+ 1CDABD6B22C8479A00BD0A3A /* WHLSLStandardLibraryFunctionMap.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLStandardLibraryFunctionMap.h; sourceTree = "<group>"; }; > 1CDD45E40BA9C84600F90147 /* DebugRelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = DebugRelease.xcconfig; sourceTree = "<group>"; }; > 1CDD45E50BA9C84600F90147 /* WebCore.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = WebCore.xcconfig; sourceTree = "<group>"; }; > 1CDD45E60BA9C84600F90147 /* Base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = "<group>"; }; >@@ -15599,6 +15606,7 @@ > FD2DBF1312B048A300ED98C6 /* AudioToolbox.framework in Frameworks */, > 1AB33DA512551E320024457A /* IOKit.framework in Frameworks */, > 93F19B1608245E59001E9ABC /* JavaScriptCore.framework in Frameworks */, >+ 1C8D26D122C09E8300D125F3 /* libcompression.tbd in Frameworks */, > 93F19B1708245E59001E9ABC /* libicucore.dylib in Frameworks */, > 1CFAE3230A6D6A3F0032593D /* libobjc.dylib in Frameworks */, > 1C09D0591E31C6A900725F18 /* libPAL.a in Frameworks */, >@@ -16192,6 +16200,7 @@ > A15E6BF01E212A6A0080AF34 /* Foundation.framework */, > 1AB33DA412551E320024457A /* IOKit.framework */, > F8216299029F4FB501000131 /* JavaScriptCore.framework */, >+ 1C8D26D022C09CDE00D125F3 /* libcompression.tbd */, > 93F1D31A0558CC5C00821BC0 /* libicucore.dylib */, > 1CFAE3220A6D6A3F0032593D /* libobjc.dylib */, > DD763BB10992C2C900740B8E /* libxml2.dylib */, >@@ -17080,6 +17089,14 @@ > tabWidth = 8; > usesTabs = 0; > }; >+ 1C8D26CD22C0948F00D125F3 /* Cocoa */ = { >+ isa = PBXGroup; >+ children = ( >+ 1C8D26CE22C0951300D125F3 /* WHLSLStandardLibraryUtilities.cpp */, >+ ); >+ path = Cocoa; >+ sourceTree = "<group>"; >+ }; > 1CA0C2F621EEDAD200A11860 /* AST */ = { > isa = PBXGroup; > children = ( >@@ -19890,6 +19907,7 @@ > 1A1414B313A0F0500019996C /* WebKitFontFamilyNames.cpp */, > 1A1414B413A0F0500019996C /* WebKitFontFamilyNames.h */, > C21BF74221CD963B00227979 /* WHLSLStandardLibrary.h */, >+ 1C50C49522C84F2400A6E4BE /* WHLSLStandardLibraryFunctionMap.cpp */, > 51748FA21CC6EEEB00728D84 /* WorkerGlobalScopeConstructors.idl */, > 9908B0F91BCAD07D00ED0F75 /* WritableStreamBuiltins.cpp */, > 9B03D8061BB3110D00B764E8 /* WritableStreamBuiltins.h */, >@@ -25492,11 +25510,13 @@ > isa = PBXGroup; > children = ( > 1CA0C2F621EEDAD200A11860 /* AST */, >+ 1C8D26CD22C0948F00D125F3 /* Cocoa */, > 1CECB3AD21F2B96400F44542 /* Metal */, > C20F88AA22966B0E00D610FA /* WHLSLASTDumper.cpp */, > C20F88AC22966B0F00D610FA /* WHLSLASTDumper.h */, > 52B3434B22A0752300E49389 /* WHLSLAutoInitializeVariables.cpp */, > 52B3434922A0752200E49389 /* WHLSLAutoInitializeVariables.h */, >+ 1C6B95DD22C858A400E6F14F /* WHLSLBuildStandardLibraryFunctionMap.py */, > C234A9B221E92C1F003C984D /* WHLSLCheckDuplicateFunctions.cpp */, > C234A9AE21E92C1A003C984D /* WHLSLCheckDuplicateFunctions.h */, > 1C840B9B21EC400900D0500D /* WHLSLChecker.cpp */, >@@ -25544,6 +25564,8 @@ > C24A57B221FB8DDA004C6DD1 /* WHLSLSemanticMatcher.cpp */, > C24A57B321FB8DDA004C6DD1 /* WHLSLSemanticMatcher.h */, > C21BF74521CD969800227979 /* WHLSLStandardLibrary.txt */, >+ 1CDABD6B22C8479A00BD0A3A /* WHLSLStandardLibraryFunctionMap.h */, >+ 1C8D26C922C0945300D125F3 /* WHLSLStandardLibraryUtilities.h */, > 1CECB3A921F2B67300F44542 /* WHLSLStatementBehaviorChecker.cpp */, > 1CECB3A821F2B67300F44542 /* WHLSLStatementBehaviorChecker.h */, > C234A9A921E92C17003C984D /* WHLSLSynthesizeArrayOperatorLength.cpp */, >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 566f5020e2b88b33942a4c323a88dd1e34195a8d..5e8d7ce1af383792d79d203ec6d3866bb6c318d3 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,16 @@ >+2019-07-02 Myles C. Maxfield <mmaxfield@apple.com> >+ >+ [WHLSL] Standard library is too big to directly include in WebCore >+ https://bugs.webkit.org/show_bug.cgi?id=198186 >+ <rdar://problem/51288898> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ The standard library doesn't include any matrix constructors that broadcast a single value >+ to every field in a matrix. https://bugs.webkit.org/show_bug.cgi?id=199333 >+ >+ * webgpu/whlsl-matrix.html: >+ > 2019-07-02 Takashi Komori <Takashi.Komori@sony.com> > > [Curl] Fix CookieJarCurl::getRawCookie. >diff --git a/LayoutTests/webgpu/whlsl-matrix.html b/LayoutTests/webgpu/whlsl-matrix.html >index f47b06ce8f3936f95406623c83c7de5cd23fd5e6..dc3b65c286b3d511907c8f977c6b7728de2151d7 100644 >--- a/LayoutTests/webgpu/whlsl-matrix.html >+++ b/LayoutTests/webgpu/whlsl-matrix.html >@@ -24,19 +24,19 @@ compute void computeShader(device float[] buffer : register(u0), float3 threadID > if (!allEqual(foo, 0)) > return; > >- foo = foo + 1.0; >+ foo = foo + float2x3(float3(1.0, 1.0, 1.0), float3(1.0, 1.0, 1.0)); > if (!allEqual(foo, 1)) > return; > >- foo = foo * 8.5; >+ foo = foo * float2x3(float3(8.5, 8.5, 8.5), float3(8.5, 8.5, 8.5)); > if (!allEqual(foo, 8.5)) > return; > >- foo = foo - 7.5; >+ foo = foo - float2x3(float3(7.5, 7.5, 7.5), float3(7.5, 7.5, 7.5)); > if (!allEqual(foo, 1)) > return; > >- foo = foo + 1.0; >+ foo = foo + float2x3(float3(1.0, 1.0, 1.0), float3(1.0, 1.0, 1.0)); > if (!allEqual(foo, 2)) > return; >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
saam
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198186
:
372733
|
372942
|
372998
|
373090
|
373143
|
373164
|
373181
|
373187
|
373188
|
373189
|
373212
|
373343
|
373392