1212#include " openminecraft/vm/pixeltower/v0/om_pixeltower_klass.hpp"
1313#include " openminecraft/vm/pixeltower/v0/om_pixeltower_oop.hpp"
1414#include " openminecraft/vm/pixeltower/v0/om_pixeltower_threads.hpp"
15- #include < cstring>
1615#include < vector>
1716
1817namespace openminecraft ::vm::pixeltower::v0
@@ -58,17 +57,17 @@ void OMInterpreter::call(OMMethod *met)
5857 met->args * sizeof (void *));
5958 nextframe->method = met;
6059
60+ // TODO: optimization
61+ for (int i = 0 ; i < met->maxLocals ; i++)
62+ {
63+ *localAccess<void *>(i, nextframe) = nullptr ;
64+ }
6165 std::vector<void *> args (met->args );
6266 for (int i = met->args - 1 ; i >= 0 ; i--)
6367 {
6468 args[i] = stackTopAccess<void *>();
6569 stackPop ();
6670 }
67-
68- for (int i = 0 ; i < met->maxLocals ; i++)
69- {
70- *localAccess<void *>(i, nextframe) = nullptr ;
71- }
7271 for (int i = 0 ; i < args.size (); i++)
7372 {
7473 *localAccess<void *>(i, nextframe) = args[i];
@@ -87,12 +86,6 @@ void OMInterpreter::call(OMMethod *met)
8786
8887void OMInterpreter::callDynamic (OMMethod *met)
8988{
90- if (met->accessFlags & JVM_Acc_Native)
91- {
92- throw err::OMValidationError{err::Instructions, " native functions not supported!" ,
93- fmt::format (" {}.{}{}" , met->klass ->name , met->name , met->desc )};
94- }
95-
9689 auto frame = currentThread.currentFrame ;
9790 auto nextframe = (OMFrame *)((uint8_t *)currentThread.stackPointer - sizeof (OMFrame) + sizeof (void *) +
9891 met->args * sizeof (void *));
@@ -109,7 +102,8 @@ void OMInterpreter::callDynamic(OMMethod *met)
109102 OMMethod *codetarget = cls->vtable [hash_compile_time (temp.c_str ())];
110103 if (codetarget == nullptr )
111104 {
112- codetarget = met;
105+ throw err::OMValidationError{err::Instructions, fmt::format (" vtable corruption found at klass {}" , cls->name ),
106+ methodName (frame->method )};
113107 }
114108 nextframe->method = codetarget;
115109
@@ -365,15 +359,10 @@ jint OMInterpreter::execute()
365359 return EXEC_OK ;
366360 }
367361 default : {
368- endExec:
369- logger.debug (" unknown operand at {}" , (void *)currentThread.pc );
370- logger.debug (" thread {}" , (void *)¤tThread.id );
371- logger.debug (" pc pointed at {} ({}.{}{} + {})" , (void *)currentThread.pc ,
372- currentThread.currentFrame ->method ->klass ->name , currentThread.currentFrame ->method ->name ,
373- currentThread.currentFrame ->method ->desc ,
374- reinterpret_cast <size_t >(
375- reinterpret_cast <void *>(static_cast <uint8_t *>(currentThread.pc ) -
376- static_cast <uint8_t *>(currentThread.currentFrame ->method ->code ))));
362+ logger.error (" We are hitting Mazarine End!" );
363+ logger.error (" unknown operand at {}" , fmt::ptr (currentThread.pc ));
364+ logger.error (" thread {}" , fmt::ptr (¤tThread.id ));
365+ logger.error (" pc pointed at {} ({})" , fmt::ptr (currentThread.pc ), currentPosition ());
377366
378367 debugger.debugStack ();
379368
0 commit comments