Migrated engine to using dlmalloc through eng::

This commit is contained in:
2022-02-24 02:17:41 -05:00
parent acc00289fb
commit f467944095
61 changed files with 631 additions and 590 deletions

View File

@@ -70,7 +70,7 @@ World::World(util::WorldType wt) {
// Initialize the SourceDB. At this stage, the sourcedb is
// empty, so it's just populating the lua builtins.
source_db_.init(state());
std::string srcerrs = source_db_.rebuild();
eng::string srcerrs = source_db_.rebuild();
// Clear the clock.
clock_ = 0;
@@ -144,7 +144,7 @@ Tangible *World::tangible_get(const LuaStack &LS, LuaSlot tab) {
return result;
}
Tangible *World::tangible_make(lua_State *L, int64_t id, const std::string &plane, bool pushdb) {
Tangible *World::tangible_make(lua_State *L, int64_t id, const eng::string &plane, bool pushdb) {
// Get a state if we don't already have one.
if (L == nullptr) {
L = state();
@@ -263,7 +263,7 @@ int64_t World::create_login_actor() {
return tan->id();
}
std::string World::probe_lua(int64_t actor_id, const std::string &lua) {
eng::string World::probe_lua(int64_t actor_id, const eng::string &lua) {
assert(stack_is_clear());
lua_State *L = state();
@@ -294,7 +294,7 @@ std::string World::probe_lua(int64_t actor_id, const std::string &lua) {
// If there's an error message, print it.
// Otherwise, pretty-print the results.
std::ostream *ostream = lthread_print_stream();
eng::ostream *ostream = lthread_print_stream();
if (status == LUA_OK) {
for (int i = top + 1; i <= lua_gettop(L); i++) {
LuaSpecial root(i);
@@ -311,7 +311,7 @@ std::string World::probe_lua(int64_t actor_id, const std::string &lua) {
// Collect the lthread_prints (and also make sure they
// don't go into the printbuffer).
std::string result = lthread_prints_->str();
eng::string result = lthread_prints_->str();
lthread_prints_.reset();
close_lthread_state();
@@ -387,7 +387,7 @@ void World::update_source(const util::LuaSourceVec &source) {
assert(stack_is_clear());
source_db_.update(source);
assert(stack_is_clear());
std::string errs = source_db_.rebuild();
eng::string errs = source_db_.rebuild();
// I don't have a good place to send the error messages right
// now. The engine needs a catch-all place to send errors that
// occur at unexpected times.
@@ -428,7 +428,7 @@ void World::invoke(const Invocation &inv) {
}
}
void World::invoke_flush_prints(int64_t actor_id, int64_t place_id, const std::string &action, const InvocationData &data) {
void World::invoke_flush_prints(int64_t actor_id, int64_t place_id, const eng::string &action, const InvocationData &data) {
assert(stack_is_clear());
// Check argument sanity.
if (actor_id != place_id) {
@@ -448,7 +448,7 @@ void World::invoke_flush_prints(int64_t actor_id, int64_t place_id, const std::s
void World::invoke_lua(int64_t actor_id, int64_t place_id, const std::string &action, const InvocationData &data) {
void World::invoke_lua(int64_t actor_id, int64_t place_id, const eng::string &action, const InvocationData &data) {
assert(stack_is_clear());
// Make sure that actor and place exist.
@@ -519,7 +519,7 @@ void World::invoke_lua(int64_t actor_id, int64_t place_id, const std::string &ac
assert(stack_is_clear());
}
void World::invoke_plan(int64_t actor_id, int64_t place_id, const std::string &action, const InvocationData &data) {
void World::invoke_plan(int64_t actor_id, int64_t place_id, const eng::string &action, const InvocationData &data) {
assert(stack_is_clear());
// Validate that the action is legal.
@@ -614,7 +614,7 @@ void World::invoke_plan(int64_t actor_id, int64_t place_id, const std::string &a
assert(stack_is_clear());
}
void World::invoke_tick(int64_t actor_id, int64_t place_id, const std::string &action, const InvocationData &data) {
void World::invoke_tick(int64_t actor_id, int64_t place_id, const eng::string &action, const InvocationData &data) {
if (!util::world_type_authoritative(world_type_)) {
return;
}
@@ -622,7 +622,7 @@ void World::invoke_tick(int64_t actor_id, int64_t place_id, const std::string &a
run_scheduled_threads();
}
void World::invoke_lua_source(int64_t actor_id, int64_t place_id, const std::string &action, const InvocationData &data) {
void World::invoke_lua_source(int64_t actor_id, int64_t place_id, const eng::string &action, const InvocationData &data) {
if (!util::world_type_authoritative(world_type_)) {
return;
}
@@ -683,7 +683,7 @@ void World::run_scheduled_threads() {
lua_State *CO = LS.ckthread(thread);
open_lthread_state(LS.ckinteger(actorid), sched.place_id(), LS.ckboolean(useppool), true);
int status = lua_resume(CO, nullptr, LS.ckint(nargs));
std::ostream *ostream = lthread_print_stream();
eng::ostream *ostream = lthread_print_stream();
// Three possible outcomes: finished, yielded, or errored.
if (!util::world_type_authoritative(world_type_)) {
@@ -763,7 +763,7 @@ void World::open_lthread_state(int64_t actor, int64_t place, bool ppool, bool pr
lthread_place_id_ = place;
lthread_use_ppool_ = ppool;
if (prints) {
lthread_prints_.reset(new std::ostringstream);
lthread_prints_.reset(new eng::ostringstream);
} else {
lthread_prints_.reset();
}
@@ -775,7 +775,7 @@ void World::close_lthread_state() {
// there isn't an actor, or if the actor doesn't have a PrintBuffer,
// send the output to std::cerr.
if (lthread_prints_ != nullptr) {
const std::string &output = lthread_prints_->str();
const eng::string &output = lthread_prints_->str();
Tangible *actor = tangible_get(lthread_actor_id_);
if (actor != nullptr) {
bool auth = util::world_type_authoritative(world_type_);
@@ -786,7 +786,7 @@ void World::close_lthread_state() {
clear_lthread_state();
}
std::ostream *World::lthread_print_stream() const {
eng::ostream *World::lthread_print_stream() const {
if (lthread_prints_ != nullptr) {
return lthread_prints_.get();
} else {