diff options
Diffstat (limited to 'source/slang/slang.cpp')
| -rw-r--r-- | source/slang/slang.cpp | 59 |
1 files changed, 50 insertions, 9 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 2c76f035c..f2f28e3e3 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -745,6 +745,7 @@ SlangResult Session::_readBuiltinModule( linkage, astBuilder, nullptr, // no sink + fileContents, astChunk, sourceLocReader, SourceLoc()); @@ -755,11 +756,6 @@ SlangResult Session::_readBuiltinModule( moduleDecl->module = module; module->setModuleDecl(moduleDecl); - if (isFromCoreModule(moduleDecl)) - { - registerBuiltinDecls(this, moduleDecl); - } - // After the AST module has been read in, we next look // to deserialize the IR module. // @@ -4198,6 +4194,7 @@ void Linkage::loadParsedModule( } RefPtr<Module> Linkage::findOrLoadSerializedModuleForModuleLibrary( + ISlangBlob* blobHoldingSerializedData, ModuleChunk const* moduleChunk, RIFF::ListChunk const* libraryChunk, DiagnosticSink* sink) @@ -4244,6 +4241,7 @@ RefPtr<Module> Linkage::findOrLoadSerializedModuleForModuleLibrary( return loadSerializedModule( moduleName, modulePathInfo, + blobHoldingSerializedData, moduleChunk, libraryChunk, SourceLoc(), @@ -4253,6 +4251,7 @@ RefPtr<Module> Linkage::findOrLoadSerializedModuleForModuleLibrary( RefPtr<Module> Linkage::loadSerializedModule( Name* moduleName, const PathInfo& moduleFilePathInfo, + ISlangBlob* blobHoldingSerializedData, ModuleChunk const* moduleChunk, RIFF::ListChunk const* containerChunk, SourceLoc const& requestingLoc, @@ -4286,6 +4285,7 @@ RefPtr<Module> Linkage::loadSerializedModule( if (SLANG_FAILED(loadSerializedModuleContents( module, moduleFilePathInfo, + blobHoldingSerializedData, moduleChunk, containerChunk, sink))) @@ -4352,6 +4352,7 @@ RefPtr<Module> Linkage::loadBinaryModuleImpl( RefPtr<Module> module = loadSerializedModule( moduleName, moduleFilePathInfo, + moduleFileContents, moduleChunk, rootChunk, requestingLoc, @@ -5269,7 +5270,27 @@ void Module::_processFindDeclsExportSymbolsRec(Decl* decl) } } -NodeBase* Module::findExportFromMangledName(const UnownedStringSlice& slice) +Decl* Module::findExportedDeclByMangledName(const UnownedStringSlice& mangledName) +{ + // If this module is a serialized module that is being + // deserialized on-demand, then we want to use the + // mangled name mapping that was baked into the serialized + // data, rather than attempt to enumerate all of the declarations + // in the module (as would be done if we proceeded to call + // `ensureExportLookupAcceleratorBuilt()`). + // + if (this->m_moduleDecl->isUsingOnDemandDeserializationForExports()) + { + return m_moduleDecl->_findSerializedDeclByMangledExportName(mangledName); + } + + ensureExportLookupAcceleratorBuilt(); + + const Index index = m_mangledExportPool.findIndex(mangledName); + return (index >= 0) ? m_mangledExportSymbols[index] : nullptr; +} + +void Module::ensureExportLookupAcceleratorBuilt() { // Will be non zero if has been previously attempted if (m_mangledExportSymbols.getCount() == 0) @@ -5284,9 +5305,25 @@ NodeBase* Module::findExportFromMangledName(const UnownedStringSlice& slice) m_mangledExportSymbols.add(nullptr); } } +} - const Index index = m_mangledExportPool.findIndex(slice); - return (index >= 0) ? m_mangledExportSymbols[index] : nullptr; +Count Module::getExportedDeclCount() +{ + ensureExportLookupAcceleratorBuilt(); + + return m_mangledExportPool.getSlicesCount(); +} + +Decl* Module::getExportedDecl(Index index) +{ + ensureExportLookupAcceleratorBuilt(); + return m_mangledExportSymbols[index]; +} + +UnownedStringSlice Module::getExportedDeclMangledName(Index index) +{ + ensureExportLookupAcceleratorBuilt(); + return m_mangledExportPool.getSlices()[index]; } // ComponentType @@ -6657,6 +6694,7 @@ void Linkage::setFileSystem(ISlangFileSystem* inFileSystem) SlangResult Linkage::loadSerializedModuleContents( Module* module, const PathInfo& moduleFilePathInfo, + ISlangBlob* blobHoldingSerializedData, ModuleChunk const* moduleChunk, RIFF::ListChunk const* containerChunk, DiagnosticSink* sink) @@ -6753,6 +6791,7 @@ SlangResult Linkage::loadSerializedModuleContents( this, astBuilder, sink, + blobHoldingSerializedData, astChunk, sourceLocReader, serializedModuleLoc); @@ -7399,8 +7438,10 @@ SlangResult EndToEndCompileRequest::addLibraryReference( // We need to deserialize and add the modules ComPtr<IModuleLibrary> library; + auto libBlob = RawBlob::create((const Byte*)libData, libDataSize); + SLANG_RETURN_ON_FAIL( - loadModuleLibrary((const Byte*)libData, libDataSize, basePath, this, library)); + loadModuleLibrary(libBlob, (const Byte*)libData, libDataSize, basePath, this, library)); // Create an artifact without any name (as one is not provided) auto artifact = |
