GitLab will be upgraded to the 12.10.14-ce.0 on 28 Sept 2020 at 2.00pm (AEDT) to 2.30pm (AEDT). During the update, GitLab and Mattermost services will not be available. If you have any concerns with this, please talk to us at N110 (b) CSIT building.

Commit dbf308e4 authored by Kunshan Wang's avatar Kunshan Wang

Added a test on collecting stack memory.

parent caabc2b9
package uvm.refimpl.itpr
import org.scalatest._
import java.io.FileReader
import uvm._
import uvm.types._
import uvm.ssavariables._
import uvm.refimpl._
import uvm.refimpl.itpr._
import MemoryOrder._
import AtomicRMWOptr._
import uvm.refimpl.mem.TypeSizes.Word
import ch.qos.logback.classic.Level._
import uvm.refimpl.UvmBundleTesterBase
class UvmInterpreterStackGCTests extends UvmBundleTesterBase {
setLogLevels(
ROOT_LOGGER_NAME -> INFO,
"uvm.refimpl.itpr" -> DEBUG,
"uvm.refimpl.mem" -> DEBUG)
preloadBundles("tests/uvm-refimpl-test/gc-tests.uir")
def gc() = microVM.memoryManager.heap.mutatorTriggerAndWaitForGCEnd(false)
/** Disable some logger for allocation-heavy parts. */
def quiet[T](f: => T): T = {
setLogLevels(
"uvm.refimpl.itpr" -> INFO,
"uvm.refimpl.mem.simpleimmix.SimpleImmixMutator$" -> INFO,
"uvm.refimpl.mem.HeaderUtils" -> INFO)
val rv = f
setLogLevels("uvm.refimpl.itpr" -> DEBUG,
"uvm.refimpl.mem.simpleimmix.SimpleImmixMutator$" -> null,
"uvm.refimpl.mem.HeaderUtils" -> null)
rv
}
// Half of the heap (1MB) space is LOS. It can accommodate 16 stacks.
override def makeMicroVM = new MicroVM(heapSize = 2L * 1024L * 1024L, stackSize = 63L * 1024L)
"The memory manager" should "collect unreachable stacks." in {
val ca = microVM.newClientAgent()
val nStacks = ca.putInt("@i64", 13)
val func = ca.putFunction("@stackcollecttest")
testFunc(ca, func, Seq(nStacks)) { (ca, th, st, wp) =>
nameOf(ca.currentInstruction(st, 0)) match {
case "@stackcollecttest_v1.trap" => {
gc()
TrapRebindPassVoid(st)
}
}
}
ca.close()
}
}
\ No newline at end of file
......@@ -369,3 +369,28 @@
%exit:
COMMINST @uvm.thread_exit()
}
.funcdef @emptystack VERSION @emptystack_v1 <@noparamsnoret> () {
%entry:
RETVOID
}
.funcsig @stackcollecttest_sig = @void (@i64)
.funcdef @stackcollecttest VERSION @stackcollecttest_v1 <@stackcollecttest_sig> (%nstacks) {
%entry:
BRANCH %head
%head:
%i = PHI <@i64> { %entry: @I64_0; %body: %i2; }
%lt = SLT <@i64> %i %nstacks
BRANCH2 %lt %body %endloop
%body:
%st = NEWSTACK <@noparamsnoret> @emptystack ()
%i2 = ADD <@i64> %i @I64_1
BRANCH %head
%endloop:
%trap = TRAP <@void>
COMMINST @uvm.thread_exit()
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment