Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

capi: Add memory_pages_limit parameter to fizzy_instantiate #780

Merged
merged 3 commits into from
Apr 19, 2021

Conversation

gumb0
Copy link
Collaborator

@gumb0 gumb0 commented Apr 7, 2021

No description provided.

@codecov
Copy link

codecov bot commented Apr 7, 2021

Codecov Report

Merging #780 (1339c5c) into master (c17fb2a) will decrease coverage by 0.03%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #780      +/-   ##
==========================================
- Coverage   99.24%   99.21%   -0.04%     
==========================================
  Files          79       78       -1     
  Lines       11964    11270     -694     
==========================================
- Hits        11874    11181     -693     
+ Misses         90       89       -1     
Flag Coverage Δ
rust ?
spectests 90.54% <ø> (ø)
unittests 99.21% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
lib/fizzy/capi.cpp 97.54% <100.00%> (+<0.01%) ⬆️
test/unittests/capi_test.cpp 99.89% <100.00%> (+<0.01%) ⬆️
test/utils/fizzy_c_engine.cpp 96.66% <100.00%> (ø)

@gumb0 gumb0 force-pushed the capi-memory-hard-limit branch 2 times, most recently from 219e1c6 to 6a8321a Compare April 9, 2021 16:02
@gumb0 gumb0 marked this pull request as ready for review April 9, 2021 16:03
@gumb0 gumb0 mentioned this pull request Apr 9, 2021
49 tasks
@gumb0 gumb0 requested review from chfast and axic April 9, 2021 16:36
@@ -410,6 +410,7 @@ bool fizzy_module_has_start_function(const FizzyModule* module) FIZZY_NOEXCEPT;
/// @param imported_globals Pointer to the imported globals array. Can be NULL iff
/// @p imported_globals_size equals 0.
/// @param imported_globals_size Size of the imported global array. Can be zero.
/// @param memory_pages_limit Hard limit for memory growth in pages. Cannot be above 65536.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, would it be a good idea allowing 0 for allowing "default setting"? Or perhaps someone actually wants to disable memory, and then 0 makes sense for that? If so, perhaps uint32_t(-1) to signal "use default"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, not a fan of special magic values.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is annoying is hardcoding 4096 in multiple places, like in rust.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could define default constant in fizzy.h, then it could be reused in tests and in rust.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think we should export the "default".

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree here. Looks good otherwise.

@gumb0 gumb0 force-pushed the capi-memory-hard-limit branch 2 times, most recently from 95c9ec7 to f7d105d Compare April 12, 2021 14:13
@@ -11,6 +11,8 @@

namespace fizzy::test
{
constexpr uint32_t DefaultMemoryPagesLimit = 4096; // 256MB
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use the one from the header?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot about this one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@@ -18,6 +18,7 @@ static_assert(MaxMemoryPagesLimit == 65536);

/// The default hard limit of the memory size (256MB) as number of pages.
constexpr uint32_t DefaultMemoryPagesLimit = (256 * 1024 * 1024ULL) / PageSize;
static_assert(DefaultMemoryPagesLimit == 4096);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this is defined twice then?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it doesn't worth to introduce a dependency form C++ to C API only for this yet.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can add a static_assert(::DefaultMemoryPagesLimit == fizzy::DefaultMemoryPagesLimit) in capi_test.cpp?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can add a static_assert(::DefaultMemoryPagesLimit == fizzy::DefaultMemoryPagesLimit) in capi_test.cpp?

Added.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it doesn't worth to introduce a dependency form C++ to C API only for this yet.

I don't agree here. This case returns from time to time.

@gumb0 gumb0 force-pushed the capi-memory-hard-limit branch 2 times, most recently from 912af4a to ef4d7a9 Compare April 12, 2021 19:01
@gumb0 gumb0 requested a review from chfast April 16, 2021 16:56
@@ -18,6 +18,7 @@ static_assert(MaxMemoryPagesLimit == 65536);

/// The default hard limit of the memory size (256MB) as number of pages.
constexpr uint32_t DefaultMemoryPagesLimit = (256 * 1024 * 1024ULL) / PageSize;
static_assert(DefaultMemoryPagesLimit == 4096);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it doesn't worth to introduce a dependency form C++ to C API only for this yet.

I don't agree here. This case returns from time to time.

@gumb0 gumb0 merged commit 5027151 into master Apr 19, 2021
@gumb0 gumb0 deleted the capi-memory-hard-limit branch April 19, 2021 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants