diff options
-rw-r--r-- | script/vm/compiler.lua | 10 | ||||
-rw-r--r-- | script/vm/runner.lua | 175 | ||||
-rw-r--r-- | test/tclient/init.lua | 2 |
3 files changed, 2 insertions, 185 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua index 168ad536..10bd5221 100644 --- a/script/vm/compiler.lua +++ b/script/vm/compiler.lua @@ -1226,8 +1226,6 @@ local compilerSwitch = util.switch() matchCall(src) end end) - - vm.waitResolveRunner(source) end) : case 'setlocal' : call(function (source) @@ -1240,7 +1238,6 @@ local compilerSwitch = util.switch() return end vm.compileNode(source.node) - vm.waitResolveRunner(source) end) : case 'setfield' : case 'setmethod' @@ -1921,13 +1918,6 @@ function vm.compileNode(source) end end - if source.type == 'getlocal' then - ---@cast source parser.object - vm.storeWaitingRunner(source) - ---@diagnostic disable-next-line: await-in-sync - vm.waitResolveRunner(source) - end - local cache = vm.getNode(source) if cache ~= nil then return cache diff --git a/script/vm/runner.lua b/script/vm/runner.lua index 8e264521..75bb3a7f 100644 --- a/script/vm/runner.lua +++ b/script/vm/runner.lua @@ -347,66 +347,6 @@ end ---@alias runner.info { target?: parser.object, loc: parser.object } ----@type thread? -local masterRunner = nil ----@type table<thread, runner.info> -local runnerInfo = setmetatable({}, { - __mode = 'k', - __index = function (self, k) - self[k] = {} - return self[k] - end -}) ----@type linked-table? -local runnerList = nil - ----@async ----@param info runner.info -local function waitResolve(info) - while true do - if not info.target then - break - end - if info.target.node == info.loc then - break - end - local node = vm.getNode(info.target) - if node and node.resolved then - break - end - coroutine.yield() - end - info.target = nil -end - -local function resolveDeadLock() - if not runnerList then - return - end - - ---@type runner.info[] - local infos = {} - for runner in runnerList:pairs() do - local info = runnerInfo[runner] - infos[#infos+1] = info - end - - table.sort(infos, function (a, b) - local uriA = guide.getUri(a.loc) - local uriB = guide.getUri(b.loc) - if uriA ~= uriB then - return uriA < uriB - end - return a.loc.start < b.loc.start - end) - - local firstTarget = infos[1].target - ---@cast firstTarget -? - local firstNode = vm.setNode(firstTarget, vm.getNode(firstTarget):copy(), true) - firstNode.resolved = true - firstNode:setData('resolvedByDeadLock', true) -end - ---@async ---@param loc parser.object ---@param start fun() @@ -418,57 +358,6 @@ function vm.launchRunner(loc, start, finish, callback) return end - local function resumeMaster() - for i = 1, 10010 do - if not runnerList or runnerList:getSize() == 0 then - return - end - local deadLock = true - for runner in runnerList:pairs() do - local info = runnerInfo[runner] - local waitingSource = info.target - if coroutine.status(runner) == 'suspended' then - local suc, err = coroutine.resume(runner) - if not suc then - log.error(debug.traceback(runner, err)) - end - else - runnerList:pop(runner) - deadLock = false - end - if not waitingSource or waitingSource ~= info.target then - deadLock = false - end - end - if runnerList:getSize() == 0 then - return - end - if deadLock then - resolveDeadLock() - end - if i == 10000 then - local lines = {} - lines[#lines+1] = 'Dead lock:' - for runner in runnerList:pairs() do - local info = runnerInfo[runner] - lines[#lines+1] = '===============' - lines[#lines+1] = string.format('Runner `%s` at %d(%s)' - , info.loc[1] - , info.loc.start - , guide.getUri(info.loc) - ) - lines[#lines+1] = string.format('Waiting `%s` at %d(%s)' - , info.target[1] - , info.target.start - , guide.getUri(info.target) - ) - end - local msg = table.concat(lines, '\n') - log.error(msg) - end - end - end - local function launch() start() if not loc.ref then @@ -499,67 +388,5 @@ function vm.launchRunner(loc, start, finish, callback) finish() end - local co = coroutine.create(launch) - locNode:setData('runner', co) - local info = runnerInfo[co] - info.loc = loc - - if not runnerList then - runnerList = linked() - end - runnerList:pushTail(co) - - if not masterRunner then - masterRunner = coroutine.running() - resumeMaster() - masterRunner = nil - return - end -end - ----@async ----@param source parser.object -function vm.waitResolveRunner(source) - local myNode = vm.getNode(source) - if myNode and myNode.resolved then - return - end - - local running = coroutine.running() - if not masterRunner or running == masterRunner then - return - end - - local info = runnerInfo[running] - - local targetLoc - if source.type == 'getlocal' then - targetLoc = source.node - elseif source.type == 'local' - or source.type == 'self' then - targetLoc = source - info.target = info.target or source - else - error('Unknown source type: ' .. source.type) - end - - local targetNode = vm.getNode(targetLoc) - if not targetNode then - -- Wait for compiling local by `compiler` - return - end - - waitResolve(info) -end - ----@param source parser.object -function vm.storeWaitingRunner(source) - local sourceNode = vm.getNode(source) - if sourceNode and sourceNode.resolved then - return - end - - local running = coroutine.running() - local info = runnerInfo[running] - info.target = source + launch() end diff --git a/test/tclient/init.lua b/test/tclient/init.lua index f945d570..5c03ddba 100644 --- a/test/tclient/init.lua +++ b/test/tclient/init.lua @@ -11,7 +11,7 @@ require 'tclient.tests.jump-source' require 'tclient.tests.load-relative-library' require 'tclient.tests.hover-set-local' require 'tclient.tests.same-prefix' -require 'tclient.tests.recursive-runner' +--require 'tclient.tests.recursive-runner' require 'tclient.tests.modify-luarc' require 'tclient.tests.performance-jass-common' |