Skip to content

Commit

Permalink
Use heap system calls directly
Browse files Browse the repository at this point in the history
  • Loading branch information
fwsGonzo committed May 19, 2024
1 parent af9ebe7 commit e5f9bb6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
8 changes: 8 additions & 0 deletions engine/scripts/src/gameplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ PUBLIC(void public_donothing())
/* nothing */
}

static void bench_alloc_free()
{
auto x = std::make_unique_for_overwrite<char[]>(1024);
__asm__("" :: "m"(x[0]) : "memory");
}

PUBLIC(void benchmarks())
{
try
Expand All @@ -76,6 +82,8 @@ PUBLIC(void benchmarks())
measure("Dynamic call handler x4 (inline)", inline_dyncall_handler);
measure("Dynamic call handler x4 (call)", opaque_dyncall_handler);

measure("Allocate 1024-bytes, and free it", bench_alloc_free);

//benchmark_multiprocessing();
}

Expand Down
2 changes: 1 addition & 1 deletion ext/libriscv
1 change: 1 addition & 0 deletions programs/micro/libc/engine.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include "override/new"
#include <exception>
#include <source_location>
#include <utility>
Expand Down
5 changes: 2 additions & 3 deletions programs/micro/libc/override/new
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#pragma once
#include_next<new>
#include <cstddef>

#include <heap.hpp>

inline void* operator new(size_t size) {
inline void* operator new(std::size_t size) {
return sys_malloc(size);
}
inline void* operator new[](size_t size) {
inline void* operator new[](std::size_t size) {
return sys_malloc(size);
}
inline void operator delete(void* ptr) {
Expand Down

0 comments on commit e5f9bb6

Please sign in to comment.