From 4d202e4945e6b7679cc8a07d31ba22692753ff3c Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Fri, 22 Jun 2007 15:31:45 -0600 Subject: [PATCH] fix iinc instruction to use set() instead of direct assignment; add Thread::HeapSizeInWords and Thread::StackSizeInWords --- src/heap.cpp | 2 +- src/vm.cpp | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/heap.cpp b/src/heap.cpp index 0b53cabc7c..ff8236728f 100644 --- a/src/heap.cpp +++ b/src/heap.cpp @@ -18,7 +18,7 @@ const unsigned MinimumGen2SizeInBytes = 128 * 1024; const unsigned Top = ~static_cast(0); const bool Verbose = true; -const bool Debug = true; +const bool Debug = false; class Context; diff --git a/src/vm.cpp b/src/vm.cpp index 241bfc586b..23ed2460ea 100644 --- a/src/vm.cpp +++ b/src/vm.cpp @@ -94,6 +94,9 @@ class Thread { static const unsigned HeapSizeInBytes = 64 * 1024; static const unsigned StackSizeInBytes = 64 * 1024; + static const unsigned HeapSizeInWords = HeapSizeInBytes / BytesPerWord; + static const unsigned StackSizeInWords = StackSizeInBytes / BytesPerWord; + Thread(Machine* m); Machine* vm; @@ -107,8 +110,8 @@ class Thread { unsigned ip; unsigned sp; unsigned heapIndex; - object stack[StackSizeInBytes / BytesPerWord]; - object heap[HeapSizeInBytes / BytesPerWord]; + object stack[StackSizeInWords]; + object heap[HeapSizeInWords]; Protector* protector; }; @@ -466,7 +469,7 @@ maybeYieldAndMaybeCollect(Thread* t, unsigned sizeInBytes) } if (t->heapIndex + divide(sizeInBytes, BytesPerWord) - >= (Thread::HeapSizeInBytes / BytesPerWord)) + >= Thread::HeapSizeInWords) { enter(t, Thread::ExclusiveState); collect(t->vm, Heap::MinorCollection); @@ -478,7 +481,7 @@ inline object allocate(Thread* t, unsigned sizeInBytes) { if (UNLIKELY(t->heapIndex + divide(sizeInBytes, BytesPerWord) - >= (Thread::HeapSizeInBytes / BytesPerWord) + >= Thread::HeapSizeInWords or t->vm->exclusive)) { maybeYieldAndMaybeCollect(t, sizeInBytes); @@ -2429,7 +2432,7 @@ run(Thread* t) int8_t c = codeBody(t, code, ip++); int32_t v = intValue(t, frameLocals(t, frame, index)); - frameLocals(t, frame, index) = makeInt(t, v + c); + set(t, frameLocals(t, frame, index), makeInt(t, v + c)); } goto loop; case imul: { @@ -3021,7 +3024,7 @@ run(Thread* t) uint16_t count = (count1 << 8) | count2; int32_t v = intValue(t, frameLocals(t, frame, index)); - frameLocals(t, frame, index) = makeInt(t, v + count); + set(t, frameLocals(t, frame, index), makeInt(t, v + count)); } goto loop; case ret: { @@ -3036,7 +3039,7 @@ run(Thread* t) invoke: if (UNLIKELY(codeMaxStack(t, methodCode(t, code)) + sp - parameterCount - > (Thread::StackSizeInBytes / BytesPerWord))) + > Thread::StackSizeInWords)) { exception = makeStackOverflowError(t); goto throw_;