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

New ponyrt #363

Merged
merged 69 commits into from
Apr 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
9e733d3
start updating compiler and normalising names
Feb 22, 2016
152bca4
Update common folder from ponyrt
albertnetymk Feb 25, 2016
d73a108
Update actor folder from ponyrt
albertnetymk Feb 25, 2016
da1290f
Update gc folder from ponyrt
albertnetymk Feb 25, 2016
bfad929
Update sched folder from ponyrt
albertnetymk Feb 25, 2016
af75af2
Update future folder
albertnetymk Feb 25, 2016
05d39a8
Update encore folder
albertnetymk Feb 25, 2016
273be5c
Update rest of libponyrt from ponyrt
albertnetymk Feb 25, 2016
e862a50
Update closure folder
albertnetymk Feb 25, 2016
c2e56b8
Update task folder
albertnetymk Feb 25, 2016
3726f20
refactor ccnames and adding ctx
Feb 25, 2016
355af53
update Expr.hs to use new runtime
Feb 25, 2016
fb37a07
update Closure.hs to use new runtime
Feb 25, 2016
a19e9d7
update Function.hs to use new runtime
Feb 25, 2016
dbcb522
update Header.hs to use new runtime
Feb 25, 2016
67439c6
update Method.hs to use new runtime
Feb 25, 2016
da62c47
update array folder
Feb 25, 2016
6e1c5fe
update tuple folder
Feb 25, 2016
5317d1f
update range folder
Feb 25, 2016
5a79555
update array library
Feb 25, 2016
d39a7bb
update range library
Feb 25, 2016
4dd51db
Update stream folder
albertnetymk Feb 25, 2016
781a0f7
Update future due to change in encore
albertnetymk Feb 25, 2016
1ff0851
add new GC.hs file
Feb 25, 2016
129a7be
update party library
Feb 25, 2016
16d9451
small fixes on encore, task, closure and future
Feb 25, 2016
f610571
small fixes to closures in parties
Feb 25, 2016
4b6a5cc
various fixes
Feb 25, 2016
974493a
small fix
Feb 25, 2016
8c4cb08
Update String.enc to use ctx
albertnetymk Feb 25, 2016
b363b77
fix String library
Feb 25, 2016
d3d5665
Use designated initializer for pony_type_t
albertnetymk Feb 25, 2016
0918c55
Remove actor_current
albertnetymk Feb 25, 2016
d0a041b
Add task_runnner_current in actor.c
albertnetymk Feb 25, 2016
bb89314
Add `dl` for linux
albertnetymk Feb 25, 2016
a6dc1af
Fix designated initializer
albertnetymk Feb 25, 2016
86e0121
Add ctx in tracing functions for polymorphic variables
albertnetymk Feb 25, 2016
b55ce66
Add ctx for closure tracing
albertnetymk Feb 25, 2016
c8a9a76
vtable is one level pointer now
albertnetymk Feb 25, 2016
ef557bb
Add run_hook in actor.c
albertnetymk Feb 25, 2016
8d79b12
Fix pointer to ctx in trait method
albertnetymk Feb 25, 2016
2463e60
Fix eager implementation of coroutine
albertnetymk Feb 25, 2016
f7ca082
Add ctx in capability tracing
albertnetymk Feb 25, 2016
5a70733
pass forgotten ctx to pony_traceactor
Feb 25, 2016
7e4863f
fix tasks tracing and stuff
Feb 25, 2016
826a194
Add ctx for calls related to shared objects.
albertnetymk Feb 26, 2016
cdbb994
Disable peer.enc for it's not supported by the compiler
albertnetymk Feb 26, 2016
9e54fa6
refactor gcSend to a single function
Feb 26, 2016
b2f6978
move gcRecv to single function
Feb 26, 2016
613977c
add ctx to pattern matching on String type
Feb 26, 2016
8c4622e
fix ParT types
Feb 26, 2016
dfae3f1
fix tracing on one way message send
Feb 26, 2016
7c0834b
fix stream code generation
Feb 26, 2016
79c87c7
Drop ctx for await.
albertnetymk Feb 27, 2016
dda53bc
Drop ctx for suspend
albertnetymk Feb 27, 2016
03ee59c
Use prefix underscore for tmp variables
albertnetymk Mar 1, 2016
1b7bcde
Add pony_ctx call in runtime ds constructor
albertnetymk Mar 1, 2016
884ca4e
Expose encore_ctx to non-runtime code
albertnetymk Mar 1, 2016
19403d4
Guard against null pointer on tracing
albertnetymk Mar 1, 2016
f1fb5cb
Early return between batch msg process on blocking
albertnetymk Mar 1, 2016
690515b
Use OO structure for all classes
albertnetymk Mar 1, 2016
0aa7ebe
Allow bang operators on shared objects
albertnetymk Mar 1, 2016
4ae754f
Process batch msgs after resuming
albertnetymk Mar 5, 2016
9d0c5a8
Guard against losing actors on premature exit
albertnetymk Mar 5, 2016
2a480d0
Remove object from objectmap on release msg (bug in ponyrt?)
albertnetymk Mar 5, 2016
831ed69
Revert back changes to task clause in dispatcher
albertnetymk Mar 5, 2016
b3da66a
Call the right tracing function on sending tasks
albertnetymk Mar 6, 2016
df1fb0e
update party references to ctx
Apr 6, 2016
af67e9a
Disable tasks and related tests
albertnetymk Apr 6, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions bundles/standard/String.enc
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ embed
#include <strings.h>
#include <alloca.h>
#include <ctype.h>
array_t *_init_argv(size_t argc, char **argv);
array_t *_init_argv(pony_ctx_t* ctx, size_t argc, char **argv);
body
array_t *_init_argv(size_t argc, char **argv) {
array_t *arr = array_mk(argc, &_enc__passive_String_type);
array_t *_init_argv(pony_ctx_t* ctx, size_t argc, char **argv) {
array_t *arr = array_mk(ctx, argc, &_enc__passive_String_type);
for(int i = 0; i < argc; i++) {
_enc__passive_String_t* s = encore_alloc(sizeof(_enc__passive_String_t));
_enc__passive_String_t* s =
encore_alloc(ctx, sizeof(_enc__passive_String_t));
s->_enc__self_type = &_enc__passive_String_type;
_enc__method_String__init(s, argv[i]);
_enc__method_String__init(ctx, s, argv[i]);
array_set(arr, i, (encore_arg_t){.p = s});
}
return arr;
Expand All @@ -19,14 +20,14 @@ end

def string_from_char(c : char) : String
let
s = embed (embed char* end) encore_alloc(2); end
s = embed (embed char* end) encore_alloc(_ctx, 2); end
in
new String(embed (embed char* end) *#{s} = #{c}; #{s}; end)

def string_from_array(arr : [char]) : String
let
len = |arr|
s = embed (embed char* end) encore_alloc(#{len} + 1); end
s = embed (embed char* end) encore_alloc(_ctx, #{len} + 1); end
p = s
in{
for c in arr
Expand Down Expand Up @@ -64,7 +65,7 @@ passive class String
b_data = b.data
in
new String(embed (embed char* end)
void *str = encore_alloc(#{t_len} + #{b_len} + 1);
void *str = encore_alloc(_ctx, #{t_len} + #{b_len} + 1);
strncpy(str, (char *)#{t_data}, #{t_len});
strncat(str, (char *)#{b_data}, #{b_len});
str;
Expand All @@ -76,7 +77,7 @@ passive class String
data = this.data
in
new String(embed (embed char* end)
char *str = encore_alloc(#{t_len} + 1);
char *str = encore_alloc(_ctx, #{t_len} + 1);
strncpy(str, (char *)#{data}, #{t_len} + 1);
str;
end)
Expand Down Expand Up @@ -117,7 +118,7 @@ passive class String
data = this.data
in
new String(embed (embed char* end)
char *str = encore_alloc(#{t_len} + 1);
char *str = encore_alloc(_ctx, #{t_len} + 1);
for (int i = 0; i < #{t_len}; ++i)
{
str[i] = toupper(((char *)#{data})[i]);
Expand All @@ -133,7 +134,7 @@ passive class String
data = this.data
in
new String(embed (embed char* end)
char *str = encore_alloc(#{t_len} + 1);
char *str = encore_alloc(_ctx, #{t_len} + 1);
for (int i = 0; i < #{t_len}; ++i)
{
str[i] = tolower(((char *)#{data})[i]);
Expand Down Expand Up @@ -164,7 +165,7 @@ passive class String
then Just new String(embed (embed char* end)
int siz = #{to} - #{from};
siz = siz < #{t_len} ? siz : #{t_len};
char *str = encore_alloc(siz + 1);
char *str = encore_alloc(_ctx, siz + 1);
strncpy(str, ((char *)#{data})+#{from}, siz);
str[siz] = '\0';
str;
Expand Down Expand Up @@ -251,7 +252,7 @@ passive class String
char *pattern = #{s}->_enc__field_data;
char *tmp = NULL;

if (#{to_len} > STACK_ALLOC_MAX) { tmp = encore_alloc(#{to_len} + 1); } else { tmp = alloca(#{to_len}); }
if (#{to_len} > STACK_ALLOC_MAX) { tmp = encore_alloc(_ctx, #{to_len} + 1); } else { tmp = alloca(#{to_len}); }

int copied = 0;
int skipped = 0;
Expand All @@ -263,7 +264,7 @@ passive class String
}
strcpy(tmp + copied, from + copied + skipped);

char *result = encore_alloc(copied + 1);
char *result = encore_alloc(_ctx, copied + 1);
strcpy(result, tmp);
result;
end)
Expand Down Expand Up @@ -318,4 +319,4 @@ passive class String
};
result[occurrences] = match this.substring(start, this.length()) with Just s => s;
result;
}
}
1 change: 1 addition & 0 deletions src/back/CCode/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,4 @@ data CCode a where
Annotated :: String -> CCode a -> CCode a
FunPtrDecl :: CCode Ty -> CCode Name -> [CCode Ty] -> CCode Stat
CompoundLiteral :: CCode Ty -> [(CCode Lval, CCode Expr)] -> CCode Expr
DesignatedInitializer :: [(CCode Name, CCode Expr)] -> CCode Expr
6 changes: 6 additions & 0 deletions src/back/CCode/PrettyCCode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ pp' (CompoundLiteral t pairs) =
braced = text "{" <> body <> text "}"
in
text "&" <> struct <> braced
pp' (DesignatedInitializer pairs) =
let
pairs' = [text "." <> pp' l <> text "=" <> pp' r | (l,r) <- pairs]
body = hcat $ intersperse (text ", ") pairs'
in
text "{" <> body <> text "}"

commaList :: [CCode a] -> Doc
commaList l = hcat $ intersperse (text ", ") $ map pp' l
Expand Down
138 changes: 138 additions & 0 deletions src/back/CodeGen/CCodeNames.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import Data.List

import qualified AST.AST as A

import Text.Printf (printf)

char :: CCode Ty
char = Typ "char"

Expand Down Expand Up @@ -60,6 +62,18 @@ isEncoreArgT _ = False
ponyMsgT :: CCode Ty
ponyMsgT = Typ "pony_msg_t"

ponyMainMsgName :: String
ponyMainMsgName = "pony_main_msg_t"

ponyMainMsgT :: CCode Ty
ponyMainMsgT = Typ ponyMainMsgName

encActiveMainName :: String
encActiveMainName = "_enc__active_Main_t"

encActiveMainT :: CCode Ty
encActiveMainT = Typ encActiveMainName

encMsgT :: CCode Ty
encMsgT = Typ "encore_fut_msg_t"

Expand Down Expand Up @@ -92,6 +106,9 @@ rangeT = Typ "range_t"
range :: CCode Ty
range = Ptr rangeT

optionT :: CCode Name
optionT = Nam "option_t"

option :: CCode Ty
option = Ptr $ Typ "option_t"

Expand All @@ -104,6 +121,12 @@ capability = Ptr $ Typ "capability_t"
ponyTraceFnType :: CCode Ty
ponyTraceFnType = Typ "pony_trace_fn"

ponyTraceObject :: CCode Name
ponyTraceObject = Nam "pony_traceobject"

ponyTraceActor :: CCode Name
ponyTraceActor = Nam "pony_traceactor"

unit :: CCode Lval
unit = Embed "UNIT"

Expand All @@ -130,6 +153,10 @@ methodImplOneWayName :: Ty.Type -> ID.Name -> CCode Name
methodImplOneWayName clazz mname =
Nam $ methodImplOneWayNameStr clazz mname

methodImplStreamName :: Ty.Type -> ID.Name -> CCode Name
methodImplStreamName clazz mname =
Nam $ encoreName "method" $ printf "%s_%s_stream" (Ty.getId clazz) (show mname)

methodImplNameStr :: Ty.Type -> ID.Name -> String
methodImplNameStr clazz mname =
encoreName "method" $ (Ty.getId clazz) ++ "_" ++ (show mname)
Expand All @@ -148,6 +175,9 @@ constructorImplName clazz = Nam $ encoreName "constructor" (Ty.getId clazz)
encoreCreateName :: CCode Name
encoreCreateName = Nam "encore_create"

encoreAllocName :: CCode Name
encoreAllocName = Nam "encore_alloc"

partySequence :: CCode Name
partySequence = Nam "party_sequence"

Expand Down Expand Up @@ -306,6 +336,12 @@ ponySendvName = Nam "pony_sendv"
ponyGcSendName :: CCode Name
ponyGcSendName = Nam "pony_gc_send"

ponyGcRecvName :: CCode Name
ponyGcRecvName = Nam "pony_gc_recv"

ponyRecvDoneName :: CCode Name
ponyRecvDoneName = Nam "pony_recv_done"

ponySendDoneName :: CCode Name
ponySendDoneName = Nam "pony_send_done"

Expand All @@ -321,9 +357,60 @@ runtimeTypeName ref = Nam $ (typeNamePrefix ref) ++ "_type"
futureTraceFn :: CCode Name
futureTraceFn = Nam "future_trace"

futureFulfil :: CCode Name
futureFulfil = Nam "future_fulfil"

futureAwait :: CCode Name
futureAwait = Nam "future_await"

futureGetActor :: CCode Name
futureGetActor = Nam "future_get_actor"

futureChainActor :: CCode Name
futureChainActor = Nam "future_chain_actor"

actorSuspend :: CCode Name
actorSuspend = Nam "actor_suspend"

streamGet :: CCode Name
streamGet = Nam "stream_get"

streamPut :: CCode Name
streamPut = Nam "stream_put"

streamClose :: CCode Name
streamClose = Nam "stream_close"

streamGetNext :: CCode Name
streamGetNext = Nam "stream_get_next"

streamEos :: CCode Name
streamEos = Nam "stream_eos"

streamMkFn :: CCode Name
streamMkFn = Nam "stream_mk"

futureMkFn :: CCode Name
futureMkFn = Nam "future_mk"

rangeMkFn :: CCode Name
rangeMkFn = Nam "range_mk"

taskMkFn :: CCode Name
taskMkFn = Nam "task_mk"

arrayMkFn :: CCode Name
arrayMkFn = Nam "array_mk"

tupleMkFn :: CCode Name
tupleMkFn = Nam "tuple_mk"

closureMkFn :: CCode Name
closureMkFn = Nam "closure_mk"

closureCallName :: CCode Name
closureCallName = Nam "closure_call"

closureTraceFn :: CCode Name
closureTraceFn = Nam "closure_trace"

Expand All @@ -347,3 +434,54 @@ rangeTypeRecName = Nam $ "range_type"

partyTypeRecName :: CCode Name
partyTypeRecName = Nam $ "party_type"

encoreCtxName :: CCode Name
encoreCtxName = Nam "_ctx"

encoreCtxT :: CCode Ty
encoreCtxT = Typ "pony_ctx_t"

encoreCtxVar :: CCode Lval
encoreCtxVar = Var "_ctx"

arrayGet :: CCode Name
arrayGet = Nam "array_get"

arraySet :: CCode Name
arraySet = Nam "array_set"

arraySize :: CCode Name
arraySize = Nam "array_size"

tupleSet :: CCode Name
tupleSet = Nam "tuple_set"

tupleGet :: CCode Name
tupleGet = Nam "tuple_get"

tupleSetType :: CCode Name
tupleSetType = Nam "tuple_set_type"

rangeStart :: CCode Name
rangeStart = Nam "range_start"

rangeStop :: CCode Name
rangeStop = Nam "range_stop"

rangeStep :: CCode Name
rangeStep = Nam "range_step"

rangeAssertStep :: CCode Name
rangeAssertStep = Nam "range_assert_step"

taskAttachFut :: CCode Name
taskAttachFut = Nam "task_attach_fut"

taskSchedule :: CCode Name
taskSchedule = Nam "task_schedule"

taskRunner :: CCode Name
taskRunner = Nam "task_runner"

taskFree :: CCode Name
taskFree = Nam "task_free"
Loading