@@ -257,6 +257,199 @@ enum class ProfilingStrategy {
257
257
Vtune = WASMTIME_PROFILING_STRATEGY_VTUNE,
258
258
};
259
259
260
+ /* *
261
+ * \brief Pool allocation configuration for Wasmtime.
262
+ *
263
+ * For more information be sure to consult the [rust
264
+ * documentation](https://docs.wasmtime.dev/api/wasmtime/struct.PoolingAllocationConfig.html).
265
+ */
266
+ class PoolAllocationConfig {
267
+ friend class Config ;
268
+
269
+ struct deleter {
270
+ void operator ()(wasmtime_pooling_allocation_config_t *p) const {
271
+ wasmtime_pooling_allocation_config_delete (p);
272
+ }
273
+ };
274
+
275
+ std::unique_ptr<wasmtime_pooling_allocation_config_t , deleter> ptr;
276
+
277
+ public:
278
+ PoolAllocationConfig () : ptr(wasmtime_pooling_allocation_config_new()) {}
279
+
280
+ // / \brief Configures the maximum number of “unused warm slots” to retain in
281
+ // / the pooling allocator.
282
+ // /
283
+ // / https://docs.wasmtime.dev/api/wasmtime/struct.PoolingAllocationConfig.html#method.max_unused_warm_slots.
284
+ void max_unused_warm_slots (uint32_t max) {
285
+ wasmtime_pooling_allocation_config_max_unused_warm_slots_set (ptr.get (),
286
+ max);
287
+ }
288
+
289
+ // / \brief The target number of decommits to do per batch.
290
+ // /
291
+ // / https://docs.wasmtime.dev/api/wasmtime/struct.PoolingAllocationConfig.html#method.decommit_batch_size.
292
+ void decommit_batch_size (size_t batch_size) {
293
+ wasmtime_pooling_allocation_config_decommit_batch_size_set (ptr.get (),
294
+ batch_size);
295
+ }
296
+
297
+ // / \brief How much memory, in bytes, to keep resident for async stacks
298
+ // / allocated with the pooling allocator.
299
+ // /
300
+ // / https://docs.wasmtime.dev/api/wasmtime/struct.PoolingAllocationConfig.html#method.async_stack_keep_resident.
301
+ void async_stack_keep_resident (size_t size) {
302
+ wasmtime_pooling_allocation_config_async_stack_keep_resident_set (ptr.get (),
303
+ size);
304
+ }
305
+
306
+ // / \brief How much memory, in bytes, to keep resident for each linear memory
307
+ // / after deallocation.
308
+ // /
309
+ // / https://docs.wasmtime.dev/api/wasmtime/struct.PoolingAllocationConfig.html#method.linear_memory_keep_resident.
310
+ void linear_memory_keep_resident (size_t size) {
311
+ wasmtime_pooling_allocation_config_linear_memory_keep_resident_set (
312
+ ptr.get (), size);
313
+ }
314
+
315
+ // / \brief How much memory, in bytes, to keep resident for each table after
316
+ // / deallocation.
317
+ // /
318
+ // / https://docs.wasmtime.dev/api/wasmtime/struct.PoolingAllocationConfig.html#method.table_keep_resident.
319
+ void table_keep_resident (size_t size) {
320
+ wasmtime_pooling_allocation_config_table_keep_resident_set (ptr.get (), size);
321
+ }
322
+
323
+ // / \brief The maximum number of concurrent component instances supported
324
+ // / (default is 1000).
325
+ // /
326
+ // / https://docs.wasmtime.dev/api/wasmtime/struct.PoolingAllocationConfig.html#method.total_component_instances.
327
+ void total_component_instances (uint32_t count) {
328
+ wasmtime_pooling_allocation_config_total_component_instances_set (ptr.get (),
329
+ count);
330
+ }
331
+
332
+ // / \brief The maximum size, in bytes, allocated for a component instance’s
333
+ // / VMComponentContext metadata.
334
+ // /
335
+ // / https://docs.wasmtime.dev/api/wasmtime/struct.PoolingAllocationConfig.html#method.max_component_instance_size.
336
+ void max_component_instance_size (size_t size) {
337
+ wasmtime_pooling_allocation_config_max_component_instance_size_set (
338
+ ptr.get (), size);
339
+ }
340
+
341
+ // / \brief The maximum number of core instances a single component may contain
342
+ // / (default is unlimited).
343
+ // /
344
+ // / https://docs.wasmtime.dev/api/wasmtime/struct.PoolingAllocationConfig.html#method.max_core_instances_per_component.
345
+ void max_core_instances_per_component (uint32_t count) {
346
+ wasmtime_pooling_allocation_config_max_core_instances_per_component_set (
347
+ ptr.get (), count);
348
+ }
349
+
350
+ // / \brief The maximum number of Wasm linear memories that a single component
351
+ // / may transitively contain (default is unlimited).
352
+ // /
353
+ // / https://docs.wasmtime.dev/api/wasmtime/struct.PoolingAllocationConfig.html#method.max_memories_per_component.
354
+ void max_memories_per_component (uint32_t count) {
355
+ wasmtime_pooling_allocation_config_max_memories_per_component_set (ptr.get (),
356
+ count);
357
+ }
358
+
359
+ // / \brief The maximum number of tables that a single component may
360
+ // / transitively contain (default is unlimited).
361
+ // /
362
+ // / https://docs.wasmtime.dev/api/wasmtime/struct.PoolingAllocationConfig.html#method.max_tables_per_component.
363
+ void max_tables_per_component (uint32_t count) {
364
+ wasmtime_pooling_allocation_config_max_tables_per_component_set (ptr.get (),
365
+ count);
366
+ }
367
+
368
+ // / \brief The maximum number of concurrent Wasm linear memories supported
369
+ // / (default is 1000).
370
+ // /
371
+ // / https://docs.wasmtime.dev/api/wasmtime/struct.PoolingAllocationConfig.html#method.total_memories.
372
+ void total_memories (uint32_t count) {
373
+ wasmtime_pooling_allocation_config_total_memories_set (ptr.get (), count);
374
+ }
375
+
376
+ // / \brief The maximum number of concurrent tables supported (default is
377
+ // / 1000).
378
+ // /
379
+ // / https://docs.wasmtime.dev/api/wasmtime/struct.PoolingAllocationConfig.html#method.total_tables.
380
+ void total_tables (uint32_t count) {
381
+ wasmtime_pooling_allocation_config_total_tables_set (ptr.get (), count);
382
+ }
383
+
384
+ // / \brief The maximum number of execution stacks allowed for asynchronous
385
+ // / execution, when enabled (default is 1000).
386
+ // /
387
+ // / https://docs.wasmtime.dev/api/wasmtime/struct.PoolingAllocationConfig.html#method.total_stacks.
388
+ void total_stacks (uint32_t count) {
389
+ wasmtime_pooling_allocation_config_total_stacks_set (ptr.get (), count);
390
+ }
391
+
392
+ // / \brief The maximum number of concurrent core instances supported (default
393
+ // / is 1000).
394
+ // /
395
+ // / https://docs.wasmtime.dev/api/wasmtime/struct.PoolingAllocationConfig.html#method.total_core_instances.
396
+ void total_core_instances (uint32_t count) {
397
+ wasmtime_pooling_allocation_config_total_core_instances_set (ptr.get (),
398
+ count);
399
+ }
400
+
401
+ // / \brief The maximum size, in bytes, allocated for a core instance’s
402
+ // / VMContext metadata.
403
+ // /
404
+ // / https://docs.wasmtime.dev/api/wasmtime/struct.PoolingAllocationConfig.html#method.max_core_instance_size.
405
+ void max_core_instance_size (size_t size) {
406
+ wasmtime_pooling_allocation_config_max_core_instance_size_set (ptr.get (),
407
+ size);
408
+ }
409
+
410
+ // / \brief The maximum number of defined tables for a core module (default is
411
+ // / 1).
412
+ // /
413
+ // / https://docs.wasmtime.dev/api/wasmtime/struct.PoolingAllocationConfig.html#method.max_tables_per_module.
414
+ void max_tables_per_module (uint32_t tables) {
415
+ wasmtime_pooling_allocation_config_max_tables_per_module_set (ptr.get (),
416
+ tables);
417
+ }
418
+
419
+ // / \brief The maximum table elements for any table defined in a module
420
+ // / (default is 20000).
421
+ // /
422
+ // / https://docs.wasmtime.dev/api/wasmtime/struct.PoolingAllocationConfig.html#method.table_elements.
423
+ void table_elements (size_t elements) {
424
+ wasmtime_pooling_allocation_config_table_elements_set (ptr.get (), elements);
425
+ }
426
+
427
+ // / \brief The maximum number of defined linear memories for a module (default
428
+ // / is 1).
429
+ // /
430
+ // / https://docs.wasmtime.dev/api/wasmtime/struct.PoolingAllocationConfig.html#method.max_memories_per_module.
431
+ void max_memories_per_module (uint32_t memories) {
432
+ wasmtime_pooling_allocation_config_max_memories_per_module_set (ptr.get (),
433
+ memories);
434
+ }
435
+
436
+ // / \brief The maximum byte size that any WebAssembly linear memory may grow
437
+ // / to.
438
+ // /
439
+ // / https://docs.wasmtime.dev/api/wasmtime/struct.PoolingAllocationConfig.html#method.max_memory_size.
440
+ void max_memory_size (size_t bytes) {
441
+ wasmtime_pooling_allocation_config_max_memory_size_set (ptr.get (), bytes);
442
+ }
443
+
444
+ // / \brief The maximum number of concurrent GC heaps supported (default is
445
+ // / 1000).
446
+ // /
447
+ // / https://docs.wasmtime.dev/api/wasmtime/struct.PoolingAllocationConfig.html#method.total_gc_heaps.
448
+ void total_gc_heaps (uint32_t count) {
449
+ wasmtime_pooling_allocation_config_total_gc_heaps_set (ptr.get (), count);
450
+ }
451
+ };
452
+
260
453
/* *
261
454
* \brief Configuration for Wasmtime.
262
455
*
@@ -433,6 +626,13 @@ public:
433
626
}
434
627
return std::monostate ();
435
628
}
629
+
630
+ // / \brief Enables and configures the pooling allocation strategy.
631
+ // /
632
+ // / https://docs.wasmtime.dev/api/wasmtime/struct.Config.html#method.allocation_strategy
633
+ void pooling_allocation_strategy (const PoolAllocationConfig &config) {
634
+ wasmtime_pooling_allocation_strategy_set (ptr.get (), config.ptr .get ());
635
+ }
436
636
};
437
637
438
638
/* *
0 commit comments