some more wrk towards nrc eval
This commit is contained in:
@@ -2,13 +2,13 @@ TIMEFORMAT=%3lU
|
|||||||
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||||
pushd $SCRIPTPATH > /dev/null
|
pushd $SCRIPTPATH > /dev/null
|
||||||
|
|
||||||
# echo ""
|
echo ""
|
||||||
# echo "----------------------"
|
echo "----------------------"
|
||||||
# echo " compiling libslime "
|
echo " compiling libslime "
|
||||||
# echo "----------------------"
|
echo "----------------------"
|
||||||
# time clang++ --std=c++17 \
|
time clang++ --std=c++17 \
|
||||||
# src/libslime.cpp -c -o libslime.o \
|
src/libslime.cpp -c -o libslime.o \
|
||||||
# -I3rd/ || exit 1
|
-I3rd/ || exit 1
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "------------------------------"
|
echo "------------------------------"
|
||||||
@@ -18,15 +18,15 @@ time clang++ -D_DEBUG -D_DONT_BREAK_ON_ERRORS \
|
|||||||
src/main.cpp -gfull -gdwarf -o ./bin/slime_d --std=c++17 \
|
src/main.cpp -gfull -gdwarf -o ./bin/slime_d --std=c++17 \
|
||||||
-I3rd/ || exit 1
|
-I3rd/ || exit 1
|
||||||
|
|
||||||
# echo ""
|
echo ""
|
||||||
# echo "--------------------------------"
|
echo "--------------------------------"
|
||||||
# echo " compiling fullslime (release) "
|
echo " compiling fullslime (release) "
|
||||||
# echo "--------------------------------"
|
echo "--------------------------------"
|
||||||
# time clang++ -D_DONT_BREAK_ON_ERRORS -O3 \
|
time clang++ -D_DONT_BREAK_ON_ERRORS -O3 \
|
||||||
# src/main.cpp -g -o ./bin/slime --std=c++17 \
|
src/main.cpp -g -o ./bin/slime --std=c++17 \
|
||||||
# -I3rd/ || exit 1
|
-I3rd/ || exit 1
|
||||||
|
|
||||||
# pushd ./bin > /dev/null
|
pushd ./bin > /dev/null
|
||||||
|
|
||||||
# echo ""
|
# echo ""
|
||||||
# echo "----------------------"
|
# echo "----------------------"
|
||||||
@@ -34,17 +34,17 @@ time clang++ -D_DEBUG -D_DONT_BREAK_ON_ERRORS \
|
|||||||
# echo "----------------------"
|
# echo "----------------------"
|
||||||
# time valgrind -q ./slime_d --generate-docs || exit 1
|
# time valgrind -q ./slime_d --generate-docs || exit 1
|
||||||
|
|
||||||
# echo ""
|
echo ""
|
||||||
# echo "----------------------"
|
echo "----------------------"
|
||||||
# echo " running tests "
|
echo " running tests "
|
||||||
# echo "----------------------"
|
echo "----------------------"
|
||||||
# time valgrind -q --track-origins=yes --leak-check=full --show-leak-kinds=all ./slime_d --run-tests || exit 1
|
time valgrind -q --track-origins=yes --leak-check=full --show-leak-kinds=all ./slime_d --run-tests || exit 1
|
||||||
|
|
||||||
# echo ""
|
echo ""
|
||||||
# echo "------------------------"
|
echo "------------------------"
|
||||||
# echo " running benches "
|
echo " running benches "
|
||||||
# echo "------------------------"
|
echo "------------------------"
|
||||||
# hyperfine -s color --warmup 5 "./slime --run-tests > /dev/null"
|
hyperfine -s color --warmup 5 "./slime --run-tests > /dev/null"
|
||||||
|
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
# popd > /dev/null
|
# popd > /dev/null
|
||||||
|
|||||||
+17
-16
@@ -1,7 +1,9 @@
|
|||||||
namespace Slime {
|
namespace Slime {
|
||||||
|
|
||||||
proc create_extended_environment_for_function_application_nrc(
|
proc create_extended_environment_for_function_application_nrc(
|
||||||
Array_List<Lisp_Object*> cs,
|
// TODO(Felix): pass cs as value as soon as we got rid of
|
||||||
|
// destructors, to prevent destroying it on scope exit
|
||||||
|
Array_List<Lisp_Object*>* cs,
|
||||||
Lisp_Object* function,
|
Lisp_Object* function,
|
||||||
int arg_start,
|
int arg_start,
|
||||||
int arg_count) -> Environment*
|
int arg_count) -> Environment*
|
||||||
@@ -45,7 +47,7 @@ namespace Slime {
|
|||||||
int obligatory_keywords_count = 0;
|
int obligatory_keywords_count = 0;
|
||||||
int read_obligatory_keywords_count = 0;
|
int read_obligatory_keywords_count = 0;
|
||||||
|
|
||||||
Lisp_Object* next_arg = cs.data[arg_start];
|
Lisp_Object* next_arg = cs->data[arg_start];
|
||||||
|
|
||||||
proc read_positional_args = [&] {
|
proc read_positional_args = [&] {
|
||||||
for (int i = 0; i < arg_spec->positional.symbols.next_index; ++i) {
|
for (int i = 0; i < arg_spec->positional.symbols.next_index; ++i) {
|
||||||
@@ -65,7 +67,7 @@ namespace Slime {
|
|||||||
sym,
|
sym,
|
||||||
Memory::copy_lisp_object_except_pairs(next_arg));
|
Memory::copy_lisp_object_except_pairs(next_arg));
|
||||||
}
|
}
|
||||||
next_arg = cs[++arg_start];
|
next_arg = cs->data[++arg_start];
|
||||||
--arg_count;
|
--arg_count;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -142,7 +144,7 @@ namespace Slime {
|
|||||||
|
|
||||||
// if not set it and then add it to the array list
|
// if not set it and then add it to the array list
|
||||||
try_void sym = Memory::get_symbol(next_arg->value.symbol);
|
try_void sym = Memory::get_symbol(next_arg->value.symbol);
|
||||||
next_arg = cs[++arg_start];
|
next_arg = cs->data[++arg_start];
|
||||||
--arg_count;
|
--arg_count;
|
||||||
// NOTE(Felix): It seems we do not need to evaluate the argument here...
|
// NOTE(Felix): It seems we do not need to evaluate the argument here...
|
||||||
if (is_c_function) {
|
if (is_c_function) {
|
||||||
@@ -157,7 +159,7 @@ namespace Slime {
|
|||||||
++read_obligatory_keywords_count;
|
++read_obligatory_keywords_count;
|
||||||
|
|
||||||
// overstep both for next one
|
// overstep both for next one
|
||||||
next_arg = cs[++arg_start];
|
next_arg = cs->data[++arg_start];
|
||||||
--arg_count;
|
--arg_count;
|
||||||
|
|
||||||
if (arg_count == 0) {
|
if (arg_count == 0) {
|
||||||
@@ -213,12 +215,12 @@ namespace Slime {
|
|||||||
Lisp_Object* list;
|
Lisp_Object* list;
|
||||||
try_void list = Memory::create_list(next_arg);
|
try_void list = Memory::create_list(next_arg);
|
||||||
Lisp_Object* head = list;
|
Lisp_Object* head = list;
|
||||||
next_arg = cs[++arg_start];
|
next_arg = cs->data[++arg_start];
|
||||||
--arg_count;
|
--arg_count;
|
||||||
while (arg_count > 0) {
|
while (arg_count > 0) {
|
||||||
try_void head->value.pair.rest = Memory::create_list(next_arg);
|
try_void head->value.pair.rest = Memory::create_list(next_arg);
|
||||||
head = head->value.pair.rest;
|
head = head->value.pair.rest;
|
||||||
next_arg = cs[++arg_start];
|
next_arg = cs->data[++arg_start];
|
||||||
--arg_count;
|
--arg_count;
|
||||||
}
|
}
|
||||||
define_symbol(arg_spec->rest, list);
|
define_symbol(arg_spec->rest, list);
|
||||||
@@ -238,7 +240,6 @@ namespace Slime {
|
|||||||
try read_rest_arg();
|
try read_rest_arg();
|
||||||
|
|
||||||
// TODO(Felix): fucking destructors
|
// TODO(Felix): fucking destructors
|
||||||
cs.data = nullptr;
|
|
||||||
return new_env;
|
return new_env;
|
||||||
}
|
}
|
||||||
proc create_extended_environment_for_function_application(
|
proc create_extended_environment_for_function_application(
|
||||||
@@ -781,7 +782,6 @@ namespace Slime {
|
|||||||
Lisp_Object* args = pcs[--pcs.next_index];
|
Lisp_Object* args = pcs[--pcs.next_index];
|
||||||
int length = list_length(args);
|
int length = list_length(args);
|
||||||
cs.reserve(length);
|
cs.reserve(length);
|
||||||
printf("aaaaaa\n\n");
|
|
||||||
for_lisp_list(args) {
|
for_lisp_list(args) {
|
||||||
cs.data[cs.next_index - 1 + (length - it_index)] = it;
|
cs.data[cs.next_index - 1 + (length - it_index)] = it;
|
||||||
nas.append(Action::Eval);
|
nas.append(Action::Eval);
|
||||||
@@ -798,7 +798,7 @@ namespace Slime {
|
|||||||
Action current_action;
|
Action current_action;
|
||||||
Lisp_Object* pc;
|
Lisp_Object* pc;
|
||||||
while (nas.next_index > 0) {
|
while (nas.next_index > 0) {
|
||||||
debug_step();
|
// debug_step();
|
||||||
|
|
||||||
current_action = nas.data[--nas.next_index];
|
current_action = nas.data[--nas.next_index];
|
||||||
switch (current_action) {
|
switch (current_action) {
|
||||||
@@ -871,7 +871,7 @@ namespace Slime {
|
|||||||
Lisp_Object_Type type = Memory::get_type(function);
|
Lisp_Object_Type type = Memory::get_type(function);
|
||||||
Environment* extended_env =
|
Environment* extended_env =
|
||||||
create_extended_environment_for_function_application_nrc(
|
create_extended_environment_for_function_application_nrc(
|
||||||
cs, function, am+1, cs.next_index-am-1);
|
&cs, function, am+1, cs.next_index-am-1);
|
||||||
cs.next_index = am;
|
cs.next_index = am;
|
||||||
push_environment(extended_env);
|
push_environment(extended_env);
|
||||||
if (type == Lisp_Object_Type::CFunction) {
|
if (type == Lisp_Object_Type::CFunction) {
|
||||||
@@ -914,12 +914,13 @@ namespace Slime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
debug_step();
|
// debug_step();
|
||||||
|
|
||||||
return cs.data[--cs.next_index];
|
return cs.data[--cs.next_index];
|
||||||
}
|
}
|
||||||
|
|
||||||
proc eval_expr(Lisp_Object* node) -> Lisp_Object* {
|
proc eval_expr(Lisp_Object* node) -> Lisp_Object* {
|
||||||
|
return nrc_eval(node);
|
||||||
profile_this();
|
profile_this();
|
||||||
|
|
||||||
using namespace Globals::Current_Execution;
|
using namespace Globals::Current_Execution;
|
||||||
@@ -1020,12 +1021,12 @@ namespace Slime {
|
|||||||
Lisp_Object* parsed, * evaluated;
|
Lisp_Object* parsed, * evaluated;
|
||||||
while (true) {
|
while (true) {
|
||||||
[&] {
|
[&] {
|
||||||
// delete_error();
|
delete_error();
|
||||||
fputs("> ", stdout);
|
fputs("> ", stdout);
|
||||||
line = read_expression();
|
line = read_expression();
|
||||||
// defer {
|
defer {
|
||||||
// free(line);
|
free(line);
|
||||||
// };
|
};
|
||||||
try_void parsed = Parser::parse_single_expression(line);
|
try_void parsed = Parser::parse_single_expression(line);
|
||||||
try_void evaluated = nrc_eval(parsed);
|
try_void evaluated = nrc_eval(parsed);
|
||||||
if (evaluated != Memory::nil) {
|
if (evaluated != Memory::nil) {
|
||||||
|
|||||||
Reference in New Issue
Block a user