Skip to content

Commit

Permalink
Tweaks, seems to be running now
Browse files Browse the repository at this point in the history
  • Loading branch information
DerelictDrone committed Aug 14, 2024
1 parent 692b56d commit 790d51d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
13 changes: 6 additions & 7 deletions lua/wire/zvm/zvm_core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -469,15 +469,14 @@ function ZVM:Precompile_Step()
self:Emit("end")
local expectedPage = self:GetPageByIndex(math.floor(self.PrecompileXEIP/128))
if expectedPage.MappedIndex ~= math.floor(expectedPage.MappedIndex) then
-- Bad address, send out an invalid address interrupt if this gets executed(it probably will)
-- Bad address because MappedIndex is a float, send out an invalid address interrupt if this gets executed(it probably will in a sec)
self:Dyn_EmitInterrupt(15,expectedPage.MappedIndex*128)
end
self:Emit("if (VM.CurrentPage.Remapped) and (VM.CurrentPage.MappedIndex ~= %d) then",expectedPage.MappedIndex)
-- This page wasn't the expected continuation, we should invalidate this address. (force recompile at this point)
self:Emit("VM:InvalidateVirtualPrecompileAddress(VM.XEIP)")
-- self:Emit("print(\"Expected page %d got page \"..VM.CurrentPage.MappedIndex)",expectedPage.MappedIndex)
self:Dyn_EmitBreak(true)
self:Emit("end")
self:Emit("end")
self:Emit("if (VM.CurrentPage.MappedIndex ~= %d) then",expectedPage.MappedIndex)
-- This page wasn't the expected continuation, we should invalidate this address. (force recompile at this point)
self:Emit("VM:InvalidateVirtualPrecompileAddress(VM.XEIP)")
self:Dyn_EmitBreak(true)
self:Emit("end")
self:Emit("VM:SetPreviousPage(%d)",math.floor(self.PrecompileXEIP/128))

Expand Down
7 changes: 1 addition & 6 deletions lua/wire/zvm/zvm_opcodes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1206,12 +1206,7 @@ ZVM.OpcodeTable[131] = function(self) --SMAP
self:Dyn_EmitInterruptCheck()

self:Dyn_Emit("for address=IDX*128,IDX*128+127 do")
self:Dyn_Emit("if VM.IsAddressPrecompiled[address] then")
self:Dyn_Emit("for k,v in ipairs(VM.IsAddressPrecompiled[address]) do")
self:Dyn_Emit("VM.PrecompiledData[v] = nil")
self:Dyn_Emit("VM.IsAddressPrecompiled[address][k] = nil")
self:Dyn_Emit("end")
self:Dyn_Emit("end")
self:Dyn_Emit("VM:InvalidateVirtualPrecompileAddress(address)")
self:Dyn_Emit("end")
self:Dyn_Emit("else")
self:Dyn_EmitInterrupt("11","IDX")
Expand Down

0 comments on commit 790d51d

Please sign in to comment.