소스 검색

small optimizaitons

master
FelixBrendel 6 년 전
부모
커밋
e02db00b86
16개의 변경된 파일574개의 추가작업 그리고 576개의 파일을 삭제
  1. +1
    -1
      3rd/ftb
  2. BIN
     
  3. +2
    -3
      build.bat
  4. +2
    -0
      include/assert.hpp
  5. +11
    -4
      include/define_macros.hpp
  6. +15
    -17
      include/libslime.h
  7. +527
    -527
      manual/built-in-docs.org
  8. +2
    -1
      src/built_ins.cpp
  9. +2
    -2
      src/define_macros.hpp
  10. +5
    -5
      src/env.cpp
  11. +1
    -1
      src/forward_decls.cpp
  12. +1
    -4
      src/io.cpp
  13. +0
    -3
      src/libslime.cpp
  14. +0
    -3
      src/main.cpp
  15. +2
    -2
      src/platform.cpp
  16. +3
    -3
      src/testing.cpp

+ 1
- 1
3rd/ftb

@@ -1 +1 @@
Subproject commit 3959dd2fc12eefbd4955fd20a1e4220562730508
Subproject commit d2133205a73c3ae3455e8cc3e0a910ce0aaae518


+ 2
- 3
build.bat 파일 보기

@@ -8,11 +8,10 @@ taskkill /F /IM %exeName% > NUL 2> NUL

echo ---------- Compiling ----------
call ..\timecmd cl ^
../src/main.cpp ^
../src/main.cpp^
/I../3rd/ ^
/D_PROFILING /D_DEBUG /D_DONT_BREAK_ON_ERRORS ^
/Zi /std:c++latest /Fe%exeName% /W3 /wd4003 /nologo /EHsc ^
/link /NODEFAULTLIB:libucrt libucrtd.lib
/Zi /std:c++latest /Fe%exeName% /W3 /wd4003 /nologo /EHsc

rem call ..\timecmd clang-cl ../src/main.cpp -o %exeName% /O2 /std:c++latest /W3 /Zi /EHsc



+ 2
- 0
include/assert.hpp 파일 보기

@@ -52,3 +52,5 @@
# define assert_type(_node, _type) do {} while (0)
# define assert(condition) do {} while (0)
#endif



+ 11
- 4
include/define_macros.hpp 파일 보기

@@ -14,11 +14,11 @@
} \
} while(0)

#define if_error_log_location_and_return() \
#define if_error_log_location_and_return(val) \
do { \
if (Globals::error) { \
log_location(); \
return; \
return val; \
} \
} while(0)

@@ -114,13 +114,13 @@
Parser::parser_col = 0; \
auto label(params,__LINE__) = Parser::parse_single_expression( \
Memory::get_c_str(Memory::create_string(#def))); \
if_error_log_location_and_return(); \
if_error_log_location_and_return(nullptr); \
assert_type(label(params,__LINE__), Lisp_Object_Type::Pair); \
assert_type(label(params,__LINE__)->value.pair.first, Lisp_Object_Type::Symbol); \
auto label(sym,__LINE__) = label(params,__LINE__)->value.pair.first; \
auto label(sfun,__LINE__) = Memory::create_lisp_object_cfunction(special); \
create_arguments_from_lambda_list_and_inject(label(params,__LINE__)->value.pair.rest, label(sfun,__LINE__)); \
if_error_log_location_and_return(); \
if_error_log_location_and_return(nullptr); \
label(sfun,__LINE__)->docstring = Memory::create_string(docs); \
define_symbol(label(sym,__LINE__), label(sfun,__LINE__)); \
label(sfun,__LINE__)->value.cFunction->body = []() -> Lisp_Object*
@@ -132,6 +132,7 @@
Globals::Current_Execution::envi_stack.next_index-1)



/*
* iterate over lisp vectors
*/
@@ -151,3 +152,9 @@
for (Lisp_Object* head = l, *it; \
Memory::get_type(head) == Lisp_Object_Type::Pair && (it = head->value.pair.first); \
head = head->value.pair.rest, ++it_index)







+ 15
- 17
include/libslime.h 파일 보기

@@ -67,16 +67,6 @@ namespace Slime {
int column;
};

struct Symbol {
String* identifier;
u64 hash;
};

struct Keyword {
String* identifier;
u64 hash;
};

struct Pair {
Lisp_Object* first;
Lisp_Object* rest;
@@ -110,6 +100,11 @@ namespace Slime {
struct Environment {
Array_List<Environment*> parents;
Hash_Map<void*, Lisp_Object*> hm;

~Environment() {
parents.~Array_List();
hm.~Hash_Map();
}
};

struct Function {
@@ -120,7 +115,7 @@ namespace Slime {
};

struct cFunction {
std::function<Lisp_Object* ()> body;
Lisp_Object* (*body)();
Arguments args;
bool is_special_form;
};
@@ -130,18 +125,20 @@ namespace Slime {
u64 flags;
Lisp_Object* userType; // keyword
String* docstring;
union {
Symbol symbol; // used for symbols and keywords
union value {
String* symbol; // used for symbols and keywords
double number;
String* string;
Pair pair;
Vector vector;
Function function;
Function* function;
cFunction* cFunction;
void* pointer;
Continuation continuation;
Hash_Map<Lisp_Object*, Lisp_Object*> hashMap;
Continuation* continuation;
Hash_Map<Lisp_Object*, Lisp_Object*>* hashMap;
~value() {}
} value;
~Lisp_Object();
};

struct Error {
@@ -151,6 +148,7 @@ namespace Slime {
String* message;
};


const wchar_t* char_to_wchar(const char* c);
char* read_entire_file(char* filename);
void add_to_load_path(const char*);
@@ -165,7 +163,7 @@ namespace Slime {
Lisp_Object* eval_expr(Lisp_Object*);
bool is_truthy (Lisp_Object*);
int list_length(Lisp_Object*);
void load_built_ins_into_environment();
void* load_built_ins_into_environment();
void create_arguments_from_lambda_list_and_inject(Lisp_Object* formal_arguments, Lisp_Object* function);

Lisp_Object* lookup_symbol(Lisp_Object* symbol, Environment*);


+ 527
- 527
manual/built-in-docs.org
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기


+ 2
- 1
src/built_ins.cpp 파일 보기

@@ -111,7 +111,7 @@ proc built_in_import(String* file_name) -> Lisp_Object* {
return Memory::nil;
}

proc load_built_ins_into_environment() -> void {
proc load_built_ins_into_environment() -> void* {
String* file_name_built_ins = Memory::create_string(__FILE__);

define((helper), "") {
@@ -1065,4 +1065,5 @@ proc load_built_ins_into_environment() -> void {

return Memory::create_lisp_object_string(resulting_string);
};
return nullptr;
}

+ 2
- 2
src/define_macros.hpp 파일 보기

@@ -114,13 +114,13 @@
Parser::parser_col = 0; \
auto label(params,__LINE__) = Parser::parse_single_expression( \
Memory::get_c_str(Memory::create_string(#def))); \
if_error_log_location_and_return(); \
if_error_log_location_and_return(nullptr); \
assert_type(label(params,__LINE__), Lisp_Object_Type::Pair); \
assert_type(label(params,__LINE__)->value.pair.first, Lisp_Object_Type::Symbol); \
auto label(sym,__LINE__) = label(params,__LINE__)->value.pair.first; \
auto label(sfun,__LINE__) = Memory::create_lisp_object_cfunction(special); \
create_arguments_from_lambda_list_and_inject(label(params,__LINE__)->value.pair.rest, label(sfun,__LINE__)); \
if_error_log_location_and_return(); \
if_error_log_location_and_return(nullptr); \
label(sfun,__LINE__)->docstring = Memory::create_string(docs); \
define_symbol(label(sym,__LINE__), label(sfun,__LINE__)); \
label(sfun,__LINE__)->value.cFunction->body = []() -> Lisp_Object*


+ 5
- 5
src/env.cpp 파일 보기

@@ -92,11 +92,11 @@ proc print_environment_indent(Environment* env, int indent) -> void {
}
};

if(env == get_root_environment()) {
print_indent(indent);
printf("[built-ins]-Environment (%lld)\n", (long long)env);
return;
}
// if(env == get_root_environment()) {
// print_indent(indent);
// printf("[built-ins]-Environment (%lld)\n", (long long)env);
// return;
// }

for_hash_map (env->hm) {
print_indent(indent);


+ 1
- 1
src/forward_decls.cpp 파일 보기

@@ -10,7 +10,7 @@ Lisp_Object* eval_arguments(Lisp_Object*);
Lisp_Object* eval_expr(Lisp_Object*);
bool is_truthy (Lisp_Object*);
int list_length(Lisp_Object*);
void load_built_ins_into_environment();
void* load_built_ins_into_environment();
void create_arguments_from_lambda_list_and_inject(Lisp_Object* formal_arguments, Lisp_Object* function);

Lisp_Object* lookup_symbol(Lisp_Object* symbol, Environment*);


+ 1
- 4
src/io.cpp 파일 보기

@@ -116,7 +116,7 @@ proc unescape_string(char* in) -> int {

/* Set the end of string. */
*out = '\0';
return out - in;
return (int)(out - in);
}

proc read_entire_file(char* filename) -> char* {
@@ -456,7 +456,4 @@ proc log_error() -> void {
fputs(" in: ", stdout);
print_call_stack();
puts(console_normal);

// HACK(Felix): we should control the stack size in eval_expr not here
// Globals::Current_Execution::call_stack.next_index = 0;
}

+ 0
- 3
src/libslime.cpp 파일 보기

@@ -1,7 +1,6 @@
#define _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_DEPRECATE

#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>

#include <stdio.h>
@@ -12,10 +11,8 @@
#include <stdarg.h>
#include <errno.h>
#include <new>
// #include <functional>

#ifdef _MSC_VER
# include <crtdbg.h>
# include <direct.h>
# include <windows.h>
#else


+ 0
- 3
src/main.cpp 파일 보기

@@ -6,9 +6,6 @@ int main(int argc, char* argv[]) {
int res = Slime::run_all_tests();
Slime::built_in_load(Slime::Memory::create_string("generate-docs.slime"));
Slime::Memory::free_everything();
#ifdef _MSC_VER
_CrtDumpMemoryLeaks();
#endif
return res ? 0 : 1;
}



+ 2
- 2
src/platform.cpp 파일 보기

@@ -28,12 +28,12 @@ int vasprintf(char **strp, const char *fmt, va_list ap) {
return -1;
}
size_t size = (size_t)len + 1;
char *str = malloc(size);
char *str = (char*)malloc(size);
if (!str) {
return -1;
}
// _vsprintf_s is the "secure" version of vsprintf
int r = _vsprintf_s(str, len + 1, fmt, ap);
int r = vsprintf_s(str, len + 1, fmt, ap);
if (r == -1) {
free(str);
return -1;


+ 3
- 3
src/testing.cpp 파일 보기

@@ -609,9 +609,9 @@ proc run_all_tests() -> bool {
try Memory::init(409600);

printf("-- Util --\n");
// invoke_test(test_array_lists_adding_and_removing);
// invoke_test(test_array_lists_sorting);
// invoke_test(test_array_lists_searching);
invoke_test(test_array_lists_adding_and_removing);
invoke_test(test_array_lists_sorting);
invoke_test(test_array_lists_searching);

printf("\n -- Parsing --\n");
invoke_test(test_parse_atom);


불러오는 중...
취소
저장