From acce384bcc88d5b300b913c14b9872081a182155 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 3 Jan 2018 00:31:10 -0800 Subject: 4179 - experiment: rip out memory reclamation I have a plan for a way to avoid use-after-free errors without all the overheads of maintaining refcounts. Has the nice side-effect of requiring manual memory management. The Mu way is to leak memory by default and build tools to help decide when and where to expend effort plugging memory leaks. Arguably programs should be distributed with summaries of their resource use characteristics. Eliminating refcount maintenance reduces time to run tests by 30% for `mu edit`: this commit parent mu test: 3.9s 4.5s mu test edit: 2:38 3:48 Open questions: - making reclamation easier; some sort of support for destructors - reclaiming local scopes (which are allocated on the heap) - should we support automatically reclaiming allocations inside them? --- 082scenario_screen.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to '082scenario_screen.cc') diff --git a/082scenario_screen.cc b/082scenario_screen.cc index 0c75fb6c..31cbfcc9 100644 --- a/082scenario_screen.cc +++ b/082scenario_screen.cc @@ -250,11 +250,11 @@ struct raw_string_stream { :(code) void check_screen(const string& expected_contents, const int color) { - int screen_location = get_or_insert(Memory, SCREEN)+/*skip refcount*/1; + int screen_location = get_or_insert(Memory, SCREEN); int data_offset = find_element_name(get(Type_ordinal, "screen"), "data", ""); assert(data_offset >= 0); int screen_data_location = screen_location+data_offset; // type: address:array:character - int screen_data_start = get_or_insert(Memory, screen_data_location) + /*skip refcount*/1; // type: array:character + int screen_data_start = get_or_insert(Memory, screen_data_location); // type: array:character int width_offset = find_element_name(get(Type_ordinal, "screen"), "num-columns", ""); int screen_width = get_or_insert(Memory, screen_location+width_offset); int height_offset = find_element_name(get(Type_ordinal, "screen"), "num-rows", ""); @@ -385,7 +385,7 @@ case _DUMP_SCREEN: { :(code) void dump_screen() { - int screen_location = get_or_insert(Memory, SCREEN) + /*skip refcount*/1; + int screen_location = get_or_insert(Memory, SCREEN); int width_offset = find_element_name(get(Type_ordinal, "screen"), "num-columns", ""); int screen_width = get_or_insert(Memory, screen_location+width_offset); int height_offset = find_element_name(get(Type_ordinal, "screen"), "num-rows", ""); @@ -393,7 +393,7 @@ void dump_screen() { int data_offset = find_element_name(get(Type_ordinal, "screen"), "data", ""); assert(data_offset >= 0); int screen_data_location = screen_location+data_offset; // type: address:array:character - int screen_data_start = get_or_insert(Memory, screen_data_location) + /*skip refcount*/1; // type: array:character + int screen_data_start = get_or_insert(Memory, screen_data_location); // type: array:character assert(get_or_insert(Memory, screen_data_start) == screen_width*screen_height); int top_index_offset = find_element_name(get(Type_ordinal, "screen"), "top-idx", ""); int top_index = get_or_insert(Memory, screen_location+top_index_offset); -- cgit 1.4.1-2-gfad0