Skip to content

Commit

Permalink
Fix minor code defects
Browse files Browse the repository at this point in the history
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
  • Loading branch information
clover2123 authored and ksh8281 committed Oct 4, 2023
1 parent 708e231 commit 88f8822
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/parser/WASMParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,11 @@ class WASMBinaryReader : public wabt::WASMBinaryReaderDelegate {
}

m_vmStack.push_back(VMStackInfo(*this, type, pos, m_functionStackSizeSoFar, localIndex));
m_functionStackSizeSoFar += Walrus::valueStackAllocatedSize(type);
if (UNLIKELY(m_functionStackSizeSoFar > std::numeric_limits<Walrus::ByteCodeStackOffset>::max())) {
size_t allocSize = Walrus::valueStackAllocatedSize(type);
if (UNLIKELY(m_functionStackSizeSoFar + allocSize > std::numeric_limits<Walrus::ByteCodeStackOffset>::max())) {
throw std::string("too many stack usage. we could not support this(yet).");
}
m_functionStackSizeSoFar += allocSize;
m_currentFunction->m_requiredStackSize = std::max(
m_currentFunction->m_requiredStackSize, m_functionStackSizeSoFar);
}
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/Memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Memory::Memory(uint64_t initialSizeInByte, uint64_t maximumSizeInByte)
, m_maximumSizeInByte(maximumSizeInByte)
, m_buffer(nullptr)
{
RELEASE_ASSERT(initialSizeInByte <= std::numeric_limits<size_t>::max());
ASSERT(initialSizeInByte <= std::numeric_limits<size_t>::max());
#if defined(WALRUS_USE_MMAP)
if (m_maximumSizeInByte) {
#ifndef WALRUS_32_MEMORY_INITIAL_MMAP_RESERVED_ADDRESS_SIZE
Expand Down
7 changes: 4 additions & 3 deletions src/shell/Shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,9 @@ static void executeWAST(Store* store, const std::string& filename, const std::ve
auto result = wabt::ParseWastScript(lexer.get(), &script, &errors, &parse_wast_options);
if (!wabt::Succeeded(result)) {
printf("Syntax error(s):\n");
for (auto e : errors)
for (auto& e : errors) {
printf(" %s\n", e.message.c_str());
}
printf("\n");
RELEASE_ASSERT_NOT_REACHED();
}
Expand Down Expand Up @@ -1000,15 +1001,15 @@ int main(int argc, char* argv[])
FILE* fp = fopen(filePath.data(), "r");
if (fp) {
fseek(fp, 0, SEEK_END);
auto sz = ftell(fp);
size_t sz = ftell(fp);
fseek(fp, 0, SEEK_SET);
std::vector<uint8_t> buf;
buf.resize(sz);
int ret = fread(buf.data(), 1, sz, fp);
fclose(fp);
// read again with binary mode if result is not success
// this one needs for windows
if (ret != sz) {
if (UNLIKELY((size_t)ret != sz)) {
FILE* fp = fopen(filePath.data(), "rb");
fread(buf.data(), sz, 1, fp);
fclose(fp);
Expand Down

0 comments on commit 88f8822

Please sign in to comment.