Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optim #104

Merged
merged 60 commits into from Feb 23, 2019
Merged

Optim #104

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
78f7dc2
:art: Fix instr improvements
fennecdjay Jan 25, 2019
dac0fd2
:art: Fix user enums and other improvments
fennecdjay Jan 25, 2019
33c91ae
:art: Try vm with computed gotos
fennecdjay Feb 8, 2019
a7f31ca
:art: Update util (finally)
fennecdjay Feb 8, 2019
1a1d163
:art: no stdxxx buf
fennecdjay Feb 8, 2019
d587c3b
:art: Gack, BCH
fennecdjay Feb 8, 2019
7201889
:art: fix BCH
fennecdjay Feb 8, 2019
049a5d1
:fire: move int.c to prim.c and split funcs
fennecdjay Feb 8, 2019
cd10181
:fire: Really move int.c to prim.c and split funcs
fennecdjay Feb 8, 2019
5cad14e
:art: Move define outside vm
fennecdjay Feb 8, 2019
337d51d
:art: BCH
fennecdjay Feb 8, 2019
3ad7473
:art: More ...
fennecdjay Feb 14, 2019
d37335e
:Fix: Operator emit func->code
fennecdjay Feb 14, 2019
0078f9d
:Fix: Operator emit func->code, add instr
fennecdjay Feb 14, 2019
a9f8aa7
:art: Few fixes
fennecdjay Feb 15, 2019
bbf260f
:art: Split VM_Shred
fennecdjay Feb 15, 2019
4e36de7
:art: Update tests
fennecdjay Feb 15, 2019
89f6241
:art: Remove usless vararg->ptr
fennecdjay Feb 15, 2019
4d8390c
:art: Allow litteral vec emit_var
fennecdjay Feb 15, 2019
8c925fd
:bug: Fix VM_INFO
fennecdjay Feb 15, 2019
54b98a4
Merge branch 'optim' of https://github.com/fennecdjay/gwion into optim
fennecdjay Feb 15, 2019
233fb7d
:art: Update utils
fennecdjay Feb 15, 2019
42d3d92
:art: Push litteral array depth on the stack
fennecdjay Feb 15, 2019
6be734e
:art: array access multi depth on the stack
fennecdjay Feb 15, 2019
b617d1b
:art: push switch map on the stack
fennecdjay Feb 15, 2019
2096e78
:art: RegPushImmX now uses m_val
fennecdjay Feb 15, 2019
e0dbbeb
:fire: Remove broken constprop
fennecdjay Feb 16, 2019
67466d7
:art: FIx member template
fennecdjay Feb 16, 2019
db36d5c
:art: Remove Instr->ptr
fennecdjay Feb 16, 2019
8e833e8
:art: Fix switch
fennecdjay Feb 16, 2019
cb81b8a
:art: finish removibg constprop
fennecdjay Feb 16, 2019
b0b94ed
:bug: Fix include
fennecdjay Feb 17, 2019
5914857
:art: Skip vec.x emission when emit_addr
fennecdjay Feb 17, 2019
330f0da
:art: Fix compiler warnings
fennecdjay Feb 17, 2019
35206d2
:white_check_mark: Test vec emit_addr
fennecdjay Feb 17, 2019
5e2543e
:art: Loops in vm, emit lint
fennecdjay Feb 17, 2019
bb0a548
:art: Start Working on templates
fennecdjay Feb 18, 2019
87ae76c
:art: Add shebang
fennecdjay Feb 19, 2019
9b3c60d
:art: Fix dyn_switch
fennecdjay Feb 19, 2019
4326fb6
:art: Update utils
fennecdjay Feb 19, 2019
1a61dc8
:art: Fixes and performance
fennecdjay Feb 19, 2019
870d7a0
:art: Update ast
fennecdjay Feb 19, 2019
df656cf
:wrench: Update ast
fennecdjay Feb 19, 2019
a06ee3e
:bug: Fix global func
fennecdjay Feb 21, 2019
3b3eae4
:art: Use RegSetImm for switches
fennecdjay Feb 21, 2019
4d1c405
:art: Update modules
fennecdjay Feb 21, 2019
93a5d82
:art: Except opcode offset now fixed
fennecdjay Feb 21, 2019
3368fcc
:art: Improve func call type check, enforce expression type
fennecdjay Feb 21, 2019
dd68a11
:art: Initial module commit :smile:
fennecdjay Feb 22, 2019
6b2bf76
:art: Remove used module argument string
fennecdjay Feb 22, 2019
b2a1e4b
:art: Gwion contains plug info
fennecdjay Feb 22, 2019
1630cfd
:shirt: Remove useless header
fennecdjay Feb 22, 2019
24c6db5
:art: Improve main and args
fennecdjay Feb 22, 2019
ce186cd
:art: Reduce variable scope
fennecdjay Feb 22, 2019
f3960e4
:art: Remove useless functions
fennecdjay Feb 22, 2019
d9c754f
:wrench: BCH ignore headers
fennecdjay Feb 22, 2019
a89005c
:wrench: BCH ignore headers, for real
fennecdjay Feb 22, 2019
1d6d8f4
:wrench: BCH tests
fennecdjay Feb 22, 2019
ce5f9fb
:bug: Fix member dynamicity
fennecdjay Feb 23, 2019
c3b73f5
:art: staticother
fennecdjay Feb 23, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions .bettercodehub.yml
Expand Up @@ -6,12 +6,13 @@ languages:
include:
- /src/.*\.c
exclude:
- /src/ast/parser\.c
- /src/ast/lexer\.c
- /src/lib/soundpipe\.c
- /src/drvr/.*\.c
- /src/vm/vm.c
- /include/.*\.h
- /tests/import/.*\.c
test:
include:
- /tests/test_plugins/.*\.c
- /tests/import/.*\.c

- name: go
production:
Expand Down
2 changes: 1 addition & 1 deletion ast
Submodule ast updated from 8fe7b1 to 787c28
2 changes: 1 addition & 1 deletion examples/array_lit.gw
Expand Up @@ -12,7 +12,7 @@ Object t[2][12][3][4][5];
int k[1][1];


<<<i, j, o, p, r, s, t, k>>>;
<<<i, " ", j, " ", o, " ", p, " ", r, " ", s, " ", t, " ", k>>>;

[ 1.0, 2, 3, 4, 5 ];
[ #(0.0, 0.0) ];
Expand Down
2 changes: 1 addition & 1 deletion examples/binary_tmpl.gw
@@ -1,4 +1,4 @@
template<A> fun void test(A a) { <<<a>>>; }
template<~A~> fun void test(A a) { <<<a>>>; }
1 => test;
1.3 => test;
test(1);
Expand Down
4 changes: 2 additions & 2 deletions examples/class_coverage.gw
Expand Up @@ -4,8 +4,8 @@ class C
float f;
complex c;
polar p;
Vec3 v;
Vec4 w;
Vec3 v;
Vec4 w;
Object o;
dtor { <<<"dtor">>>; }
}
Expand Down
2 changes: 1 addition & 1 deletion examples/class_spork_func.gw
Expand Up @@ -5,7 +5,7 @@ class C
samp => now;
<<<"and now">>>;
}
spork test();
spork this.test();
}

C c;
Expand Down
10 changes: 10 additions & 0 deletions examples/dyn_switch.gw
@@ -0,0 +1,10 @@
3 => const int i;
2 => const int y;
switch(i) {
case 1: <<<1>>>;break;
case 3: <<<3>>>;break;
case y: <<<2>>>;break;
default:
<<<"0">>>;
}
<<<y>>>;
4 changes: 2 additions & 2 deletions examples/op2.gw
Expand Up @@ -12,9 +12,9 @@ operator => Vec3 (Vec3 c, C d){ <<<c.z => d.f>>>; return @(1.2, 6.1, 2.3
operator => Vec4 (Vec4 c, C d){ <<<"Vec4 => C: ", c.w => d.f>>>; return @(1.2, 6.1, 2.3, 9.3);}

operator => float (C d, int c){ <<<"int => C: ", c => d.f>>>; return 2.0;}
operator => float (C d, float f){ <<<"float => C: ", f => d.f>>>; return 2.0;}
operator => float (C d, float f){ <<<"C => float: ", f => d.f>>>; return 2.0;}

operator => float (Vec3 v, float f){ <<<"float => C: ", f, v.x => f>>>; return 2.0;}
operator => float (Vec3 v, float f){ <<<"vec3 => C: ", f, " ", v.x => f>>>; return 2.0;}

operator => complex (C d, complex c){ <<<"complex => C: ", c.re => d.f>>>; return #(1.2, 6.1);}
operator => polar (C d, polar c){ <<<"complex => C: ", c.mod => d.f>>>; return %(2.3, 4.1);}
Expand Down
4 changes: 3 additions & 1 deletion examples/spork_exp.gw
Expand Up @@ -2,11 +2,13 @@ class C
{
12 => int i;
Object o;
<<<this>>>;
spork {
"test";
second => now;
string s;
<<< "test spork exp." >>>;
<<< this, " test spork exp. " , s>>>;

} @=> Shred @shred;
}

Expand Down
6 changes: 3 additions & 3 deletions examples/spork_func.gw
@@ -1,13 +1,13 @@
class C
{
function void test() {
<<<"here">>>;
function void test(int i) {
<<<"here => ", i>>>;
samp => now;
<<<"and now">>>;
}
}

C c;
spork c.test();
spork c.test(2);
me.yield();
4::samp => now;
52 changes: 52 additions & 0 deletions examples/template_dyn.gw
@@ -0,0 +1,52 @@
fun void test(C cc) { <<< cc.test(2) >>>; }

fun void test(C cc, int i) { <<<1>>>; <<<cc.test(i, i)>>>; }


class C {
template<~A~>
fun int test(A a) { <<<" A ", a>>>; }
template<~A~>
fun int test(A a, int i) { <<<" ", a >>>; }
template<~A~>
fun int test(A a, int i, int j) { <<<a>>>; }
}
class D extends C {
template<~A~>
fun int test(A a, int i) { <<<this, " extent ", a, __func__>>>; }
}
class E extends D {
template<~A~>
fun int test(A a, int i) { <<<this, " Extent ", a, __func__>>>; }
}


<<<C c>>>;
<<<D d>>>;
<<<E e>>>;

test(c);
test(d);
test(e);
test(c,1);
test(d,2);
test(e,3);
<<<test>>>;


c.test(1);
c.test(123,1);
c.test(1, 2, 3);

d.test(2);
d.test(123,3);
d.test(2, 2, 3);

e.test(3);
e.test(123,3);
e.test(3, 2, 3);

fun void _test() {<<<"test">>>; }
fun void test() { _test(); }
test();

1 change: 1 addition & 0 deletions examples/vec3.gw
Expand Up @@ -34,3 +34,4 @@ w-10.;
w/10.;
10.*w;
w*10.;
<<<@(23).x>>>;
11 changes: 0 additions & 11 deletions help/lcov.sh
Expand Up @@ -4,17 +4,6 @@ OUTFILE=lcov/lcov.info

[ -d lcov ] || mkdir lcov

#[ -z "$TRAVIS_BUILD_DIR" ] || {
# BASE_DIR=$PWD
# cd tests/test_plugin || return
# for file in *.c
# do
# sed 's/\.c//' <<< "$file"
# test_test_plugin "$(sed 's/\.c//' <<< "$file")"
# done
# cd "$BASE_DIR" || return
#}

lcov --no-external --capture --directory src --output-file "$OUTFILE"

[ -z "$TRAVIS_BUILD_DIR" ] || {
Expand Down
25 changes: 25 additions & 0 deletions help/opcode.sh
@@ -0,0 +1,25 @@
#!/bin/bash
echo "#ifndef __GWION_OPCODES__"
echo "#define __GWION_OPCODES__"

list=$(grep -v "#" opcode.txt)
COUNT=0
echo "enum {"
for a in ${list}
do
[ -z "$a" ] || {
echo " $a,"
COUNT=$((COUNT+1))
}
done
echo "};"
echo ""

for a in ${list}
do
[ -z "$a" ] || echo "#define $a (f_instr)$a"
done | column -t

echo "#endif"

echo "generated" "$COUNT" "opcodes" >&2
5 changes: 2 additions & 3 deletions include/arg.h
Expand Up @@ -6,11 +6,10 @@ typedef struct {
struct Vector_ add;
struct Vector_ rem;
struct Vector_ lib;
Vector ref;
struct Vector_ mod;
m_bool loop;
unsigned quit : 1;
} Arg;

ANN void arg_init(Arg* arg);
ANN void arg_release(Arg* arg);
ANN uint parse_args(Arg*, DriverInfo*);
#endif
1 change: 0 additions & 1 deletion include/array.h
Expand Up @@ -3,7 +3,6 @@
typedef struct M_Vector_ * M_Vector;
typedef struct ArrayInfo_ {
m_int depth;
// Type type, base;
struct Vector_ type;
Type base;
M_Object* data;
Expand Down
1 change: 0 additions & 1 deletion include/context.h
Expand Up @@ -12,5 +12,4 @@ struct Context_ {
ANN2(2) ANEW Context new_context(const Ast, const m_str);
ANN void load_context(const Context, const Env);
ANN void unload_context(const Context, const Env);
ANN void free_context(const Context);
#endif
1 change: 0 additions & 1 deletion include/env.h
Expand Up @@ -48,7 +48,6 @@ ANN m_bool compat_func(const __restrict__ Func_Def, const __restrict__ Func_Def)
ANN Type known_type(const Env env, const Type_Decl*);
ANN m_bool env_access(const Env env, const ae_flag flag);
ANN void env_storage(const Env env, ae_flag* flag);
ANN2(1,2) void env_add_value(const Env, const m_str, const Type, const m_bool, void*);
ANN void env_add_type(const Env, const Type);
ANN Type find_type(const Env, ID_List);
ANN m_bool already_defined(const Env env, const Symbol s, const uint pos);
Expand Down
4 changes: 4 additions & 0 deletions include/gack.h
@@ -0,0 +1,4 @@
#ifndef __GACK
#define __GACK
ANN void gack(const m_bit*, const Instr);
#endif
12 changes: 10 additions & 2 deletions include/gwion.h
@@ -1,7 +1,12 @@
#ifndef __GWION
#define __GWION
typedef struct Gwion_* Gwion;
#include "plug.h"
#include "driver.h"
struct Gwion_ {
PlugInfo plug;
Driver* driver;
// scanner
// sym
// mem
// rnd
Expand All @@ -10,6 +15,9 @@ struct Gwion_ {
Emitter emit;
VM* vm;
};
ANN void gwion_init(Gwion gwion);
ANN void gwion_release(Gwion gwion);
ANN void gwion_init(const Gwion, const Vector);
ANN m_bool gwion_audio(const Gwion gwion, DriverInfo* di);
ANN void gwion_run(const Gwion gwion, DriverInfo* di);
ANN m_bool gwion_engine(const Gwion gwion);
ANN void gwion_release(const Gwion gwion, DriverInfo* di);
#endif
18 changes: 13 additions & 5 deletions include/import.h
Expand Up @@ -2,16 +2,22 @@
#define __IMPORT
#define DLARG_MAX 6

typedef void (*f_xtor)(const M_Object o, const VM_Shred sh);
typedef void (*f_xtor)(const M_Object o, const m_bit*, const VM_Shred);
//typedef void (*f_xtor)(const M_Object o, const VM_Shred);
typedef void (*f_mfun)(const M_Object o, const m_bit* RETURN, const VM_Shred sh);
typedef void (*f_sfun)(const m_bit* RETURN, const VM_Shred sh);
//typedef void (*f_sfun)(const m_bit*, const m_bit* RETURN, const VM_Shred sh);
typedef void (*f_xfun)();
typedef struct Gwi_* Gwi;

#define MFUN(a) ANN void a(const M_Object o __attribute__((unused)), const m_bit* RETURN __attribute__((unused)), const VM_Shred shred __attribute__((unused)))
#define SFUN(a) ANN void a(const m_bit* RETURN __attribute__((unused)), const VM_Shred shred __attribute__((unused)))
#define CTOR(a) ANN void a(const M_Object o, const VM_Shred shred __attribute__((unused)))
#define DTOR(a) ANN void a(const M_Object o, const VM_Shred shred __attribute__((unused)))
//#define SFUN(a) ANN void a(const m_bit* mem __attribute__((unused)), const m_bit* RETURN
//__attribute__((unused)), const VM_Shred shred __attribute__((unused)))
#define CTOR(a) ANN void a(const M_Object o, const m_bit* _ __attribute__((unused)), const VM_Shred shred __attribute__((unused)))
//#define CTOR(a) ANN void a(const M_Object o, const VM_Shred shred __attribute__((unused)))
#define DTOR(a) ANN void a(const M_Object o, const m_bit* _ __attribute__((unused)), const VM_Shred shred __attribute__((unused)))
//#define DTOR(a) ANN void a(const M_Object o, const VM_Shred shred __attribute__((unused)))
#define OP_CHECK(a) ANN Type a(const Env env __attribute__((unused)), void* data __attribute__((unused)))
#define OP_EMIT(a) ANN m_bool a(const Emitter emit __attribute__((unused)), void* data __attribute__((unused)))
#ifdef GWION_BUILTIN
Expand All @@ -28,8 +34,6 @@ typedef struct Gwi_* Gwi;
ANN VM* gwi_vm(const Gwi);
ANN2(1,2) ANEW Type gwi_mk_type(const Gwi, const m_str, const m_uint, const Type);
ANN m_int gwi_add_type(const Gwi gwi, Type type);
ANN2(1,2,3)m_int gwi_add_value(const Gwi gwi, const m_str name, Type type, const m_bool is_const, void* data);

ANN2(1,2)m_int gwi_class_ini(const Gwi gwi, const Type type, const f_xtor pre_ctor, const f_xtor dtor);
ANN m_int gwi_class_ext(const Gwi gwi, Type_Decl* td);
ANN m_int gwi_class_end(const Gwi gwi);
Expand Down Expand Up @@ -73,4 +77,8 @@ OP_CHECK(opck_basic_cast);
OP_CHECK(opck_new);
OP_EMIT(opem_basic_cast);
OP_EMIT(opem_new);


ANN /*static */ Type_List str2tl(const Env env, const m_str s, m_uint *depth);

#endif