@@ -535,16 +535,20 @@ class WASMBinaryReader : public wabt::WASMBinaryReaderDelegate {
535
535
536
536
m_vmStack.push_back (VMStackInfo (*this , type, pos, m_functionStackSizeSoFar, localIndex));
537
537
size_t allocSize = Walrus::valueStackAllocatedSize (type);
538
- if ( UNLIKELY (m_functionStackSizeSoFar + allocSize > std::numeric_limits<Walrus::ByteCodeStackOffset>:: max ())) {
539
- throw std::string ( " too many stack usage. we could not support this(yet). " );
540
- }
538
+ // FIXME too many stack usage. we could not support this(yet)
539
+ ASSERT (m_functionStackSizeSoFar + allocSize <= std::numeric_limits<Walrus::ByteCodeStackOffset>:: max () );
540
+
541
541
m_functionStackSizeSoFar += allocSize;
542
542
m_currentFunction->m_requiredStackSize = std::max (
543
543
m_currentFunction->m_requiredStackSize , m_functionStackSizeSoFar);
544
544
}
545
545
546
546
VMStackInfo popVMStackInfo ()
547
547
{
548
+ // FIXME This error can occur during the parsing process because of invalid wasm instructions
549
+ // e.g. a function with no end opcode
550
+ ASSERT (m_vmStack.size () > 0 );
551
+
548
552
auto info = m_vmStack.back ();
549
553
m_functionStackSizeSoFar -= Walrus::valueStackAllocatedSize (info.valueType ());
550
554
m_vmStack.pop_back ();
@@ -567,24 +571,27 @@ class WASMBinaryReader : public wabt::WASMBinaryReaderDelegate {
567
571
return info;
568
572
}
569
573
570
- size_t popVMStack ()
574
+ VMStackInfo& peekVMStackInfo ()
571
575
{
572
- return popVMStackInfo ().position ();
576
+ // FIXME This error can occur during the parsing process because of invalid wasm instructions
577
+ // e.g. a function with no end opcode
578
+ ASSERT (m_vmStack.size () > 0 );
579
+ return m_vmStack.back ();
573
580
}
574
581
575
- size_t peekVMStack ()
582
+ size_t popVMStack ()
576
583
{
577
- return m_vmStack. back ().position ();
584
+ return popVMStackInfo ().position ();
578
585
}
579
586
580
- VMStackInfo& peekVMStackInfo ()
587
+ size_t peekVMStack ()
581
588
{
582
- return m_vmStack. back ();
589
+ return peekVMStackInfo (). position ();
583
590
}
584
591
585
592
Walrus::Value::Type peekVMStackValueType ()
586
593
{
587
- return m_vmStack. back ().valueType ();
594
+ return peekVMStackInfo ().valueType ();
588
595
}
589
596
590
597
void beginFunction (Walrus::ModuleFunction* mf, bool inInitExpr)
0 commit comments