GithubHelp home page GithubHelp logo

kerneis / cpc Goto Github PK

View Code? Open in Web Editor NEW
111.0 111.0 13.0 32.87 MB

Continuation Passing C

Home Page: http://www.pps.univ-paris-diderot.fr/~kerneis/software/cpc

License: Other

Perl 6.94% C 36.77% C++ 0.46% Shell 6.50% OCaml 49.33%

cpc's People

Contributors

boutier avatar ctshepherd avatar egrimley-arm avatar haihaoshen avatar jech avatar jim-grundy avatar joshi-prasad avatar kerneis avatar liblit avatar nwatkiss avatar yakobowski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cpc's Issues

Error: wrong number of arguments in function call for typedef's in structures

Using the sample file, I get the error:

Error: coroutine-cpc.c:10: wrong number of arguments in function call: *(s->f)
Fatal error: exception Errormsg.Error

I think this is due to the assertion at line 1839 in src/ext/cpc.ml failing, however I was unable to debug it further. Hopefully this is a pretty minimal testcase.

CPC compilation does not finish

It stops at

/tmp/cpc-0.9.1/bin/cpc.native --out /tmp/cil-VkoZo7Zq.cil.c --warnall /tmp/cil-1o8J_C5l.i

where the program never finishes (and use 100% CPU).

This happens both on the git and the released version.

cpc_spawn return value

No error are raised when a value is returned in a cpc_spawn (like "return 0;"), but the program will fail.
I don't have check if spawning a cps function returning a value also fails.

Implement cpc_longjmp()

CPC runtime has its own cpc_condvar, so it should have CPC-specific longjmp as well.

Desired use case: replace broken Asincify in EmScripten. It's stated that:

ASYNCIFY has a bad worst-case of large code size: If it needs to modify many methods, it can grow code size very significantly (even 10x more was seen).

I don't understand what's wrong with it, but CPC is not growing code size that much, is it?

A good test case would be to replace emterpreter in em-dosbox. Currently most of dosbox code is being compiled as usual, but 40 functions are whitelisted to be executed on emterpreter. I believe, CPC would do better than emterpreter.

For this to work best, CPC should be able to accept blacklists or whitelists like emcc and not require altering of source code. No need to put "cpc" marks.

Problem with GCC builtins

While working on QEMU I've noticed a problematic interaction between GCC builtins and CPC.

I think the problem lies with CIL rather than CPC. GCC builtins have no prototypes, so CIL inserts a default prototype. GCC then sees the prototype in the source file and decides this means the builtin function shouldn't be used.

Unfortunately I'm not sure what the best solution to this is. I don't know if GCC's behaviour is very standard compliant.

A minimal example (__atomic_thread_fence is a GCC builtin used in QEMU):
http://codepad.org/lDgazDSD

Test:
http://codepad.org/TawMay3B

libev

I cannot compile a cpc code with libev (with cpc_runtime.o, it works).
Here is the code :

$ cat toto.cpc 
#include <cpc/cpc_runtime.h>
#include <stdio.h>
#include <stdlib.h>

int
main(int argc, char **argv)
{
    cpc_spawn {
        printf("toto\n");
    }
    cpc_main_loop();
}

And the compiling result :

$ cpc toto.cpc -I cpc -lcpc -pthread
gcc -D_GNUCC -E -I cpc -pthread -DCIL=1 -x c toto.cpc -o /tmp/cil-F0cPvMyf.i
/home/offline/programmation/cpc/obj/cpc.asm.exe --out /tmp/cil-ZdI8fJM3.cil.c /tmp/cil-F0cPvMyf.i
toto.cpc:11: Warning: Body of function main falls-through. Adding a return statement
gcc -D_GNUCC -E -I cpc -pthread /tmp/cil-ZdI8fJM3.cil.c -o /tmp/cil-tLwj1G8h.cil.i
gcc -D_GNUCC -c -I cpc -pthread -pthread -o /tmp/cil-LT9VhhkX.o /tmp/cil-tLwj1G8h.cil.i
gcc -D_GNUCC -o a.out -I cpc -pthread -pthread /tmp/cil-LT9VhhkX.o -lcpc -pthread
/usr/local/lib/libcpc.a(cpc_libev.o): In function `periodic_recalc':
/home/offline/programmation/cpc/runtime/libev/ev.c:2218: undefined reference to `ceil'
/home/offline/programmation/cpc/runtime/libev/ev.c:2218: undefined reference to `ceil'
/home/offline/programmation/cpc/runtime/libev/ev.c:2218: undefined reference to `ceil'
collect2: error: ld returned 1 exit status

missing declaration for static assignment

static assignment is bugged.

The following code will produce:
file.cpc:48:3: error: 'bugged_pointer___0' undeclared (first use in this function)

include <cpc/cpc_runtime.h>

include <cpc/cpc_io.h>

static void *bugged_pointer;

cps void*
get_pointer(void)
{
return NULL;
}

cps void
big_bug(void)
{
bugged_pointer = get_pointer();
}

int
main(int argc, char **argv)
{
cpc_spawn big_bug();
cpc_main_loop();
return 0;
}

Error: Unbound value Util.memoize

There is a missing dependency. I'm on debian with the usual packages.

 /usr/bin/ocamlopt.opt -c -I src/ext -I ocamlutil -I src -I src/frontc -I src/ext/pta -o src/ext/blockinggraph.cmx src/ext/blockinggraph.ml
File "src/ext/blockinggraph.ml", line 121, characters 2-14:
Error: Unbound value Util.memoize

Warnings in dead-code

Dead code may lead to that kind of Warning :
dead-code.cpc:3: Warning: Body of function ret falls-through. Adding a return statement

Example of code :

/* dead-code.cpc */
int main()
{
    do {
        return 0;
    } while(0);
    /* dead-code : adding "return 0;" avoid the warning. */
}

(checked on Windows -- cygwin)

Unknown flexlink "-g" option when compiling under cygwin.

Compilation of the "windows-aio" branch of cpc fail under cygwin, due to an unrecognize -g option for flexlink. A similar problem appeared for CIL:

http://www.mail-archive.com/[email protected]/msg00383.html

Remark than now, ocamlutil/Makefile.ocaml doesn't exists anymore in the CIL repository, but still exists in the CPC repository.

Here are the log of the failed compilation of CPC:

http://pastebin.com/YtHpRnUd

and the successful one of CIL:

http://pastebin.com/mPcbLxW4

CPC converts tcg/tcg.c in QEMU into invalid C

/home/cs648/qemu/tcg/tcg.c:1642: Warning: Body of function tcg_reg_alloc falls-through. Adding a return statement
gcc -D_GNUCC -E -I/home/cs648/qemu/tcg -I/home/cs648/qemu/tcg/i386 -I/home/cs648/qemu/linux-headers -I/home/cs648/qemu/bin/current/linux-headers -I. -I/home/cs648/qemu -I/home/cs648/qemu/include -I/home/cs648/qemu/tcg -Itcg -DPIE -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -U__SSE2__ -w -Dcoroutine_fn=attribute((cps)) -Dnocps=attribute((nocps)) -I/usr/include/p11-kit-1 -I/usr/include/libpng12 -I/usr/include/pixman-1 -I../linux-headers -I.. -I/home/cs648/qemu/target-i386 -DNEED_CPU_H -I/home/cs648/qemu/include -pthread -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -O2 -D_FORTIFY_SOURCE=2 -g ./tcg.cil.c -o ./tcg.cil.i
gcc -D_GNUCC -c -I/home/cs648/qemu/tcg -I/home/cs648/qemu/tcg/i386 -I/home/cs648/qemu/linux-headers -I/home/cs648/qemu/bin/current/linux-headers -I. -I/home/cs648/qemu -I/home/cs648/qemu/include -I/home/cs648/qemu/tcg -Itcg -DPIE -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -U__SSE2__ -w -Dcoroutine_fn=attribute((cps)) -Dnocps=attribute((nocps)) -I/usr/include/p11-kit-1 -I/usr/include/libpng12 -I/usr/include/pixman-1 -I../linux-headers -I.. -I/home/cs648/qemu/target-i386 -DNEED_CPU_H -I/home/cs648/qemu/include -pthread -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -O2 -D_FORTIFY_SOURCE=2 -g -Werror -fPIE -m64 -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -w -Wendif-labels -Wmissing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -fstack-protector-all -pthread -O2 -g -o tcg/tcg.o ./tcg.cil.i
/home/cs648/qemu/tcg/tcg.c:2547:61: error: ‘img’ undeclared here (not in a function)
.e_ident[EI_MAG2] = ELFMAG2,
^
make: *** [tcg/tcg.o] Error 1
make: Leaving directory `/home/cs648/qemu/bin/convert-block/x86_64-softmmu'

tcg.c: http://codepad.org/u5PyyVjO
tcg.i: http://codepad.org/vS3gR45p
tcg.cil.c: http://codepad.org/OaUDEJkp
tcg.cil.i: http://codepad.org/QFJXikz6

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.