sebastien / k7 Goto Github PK
View Code? Open in Web Editor NEWA standard library for the V8 JavaScript interpreter
A standard library for the V8 JavaScript interpreter
I'd like to be able to write glue code in a manner similar to this.
OBJECT( posix_FILE, 1, FILE* file )
{
OBJECT_SCOPE_START();
OBJECT_INTERNAL_SETUP( 1 );
INTERNAL( 0, file );
return( self );
};
FUNCTION( posix_fputs )
{
SCOPE_START();
ARG_utf8( str, 0 );
ARG_obj( fObj, 1 );
EXTERNAL( FILE*, file, fObj, 0 );
return( JS_int( fputs( *str, file ) ) );
}
K7 doesn't have any db bindings, so starting with tokyocabinet would be good.
Only initialize modules when they are actually referenced... if that's possible. This would allow to load K7 as fast as possible.
For now, when throwing an exception from C/C++ code when libtask is enabled makes k7 core dump
It would help reduce K7 binary size and allow to spread loading time over a larger period
Right now, I don't think they work properly, but they are really important.
Dyncall is like libFFI, only better and simpler
http://dyncall.org/
K7 should offer primitive for accessing and manipulating modules (in plain C++):
as right now the documentation is a bit poor...
This would be good for libnode support
With latest version of K7, I get a segfault when executing
./k7 tests/module-system- event.js
bound!
event added fd 5
yep,added
expected err: Error: Operation now in progress
connected
event added fd 6
Uncaught exception: Error: Invalid argument
Segmentation fault
With gdb output
[Switching to Thread 0xb796f6f0 (LWP 30101)]
0xb7ce6613 in strlen () from /lib/tls/i686/cmov/libc.so.6
(gdb) backtrace
#0 0xb7ce6613 in strlen () from /lib/tls/i686/cmov/libc.so.6
#1 0x08066264 in v8::String::New ()
#2 0xbfd8d1ec in ?? ()
#3 0x08076441 in v8::internal::Builtin_HandleApiCall ()
#4 0x00000001 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
To me, having python & scons required to build k7 (and v8) is barrier to making k7 more portable. To remove, python & scons, the following is needed:
I have some notes on this and was working on this in a private tree.
Libevent 1 is the default on most systems. If libevent 2 is better, then we should ship it with K7 and embed it in the deps so that it gets compiled as a dependency and then statically linked.
I'd personnaly prefer that the event module uses libevent1 by default and then has an option to use libevent2.
Extend offers OOP, utility function and python-like datatypes that could be really useful for better server-side programming.
Here are some examples that should be ported to K7
http://lua-users.org/wiki/LuaCoroutinesVersusPythonGenerators
It's small and probably better than what we use so far
Right now, when a script fails we don't have a lot of useful information. For instance, running Narwhal leads to this:
./bin/narwhal
native runtime.js:160: TypeError: boolean is not a function
throw %MakeTypeError('called_non_callable', [typeof callee]);
^
While we'd like to have full traceback. This is very likely doable using K7, and quite important as otherwise debugging is hard. Maybe have a look at the D8 scripts shipped with V8.
Traceback (most recent call last):
File "tools/js2h", line 25, in <module>
for c in jsmin.jsmin(f.read()):
AttributeError: 'module' object has no attribute 'jsmin'
g++ -DK7_VERSION=20100617 -g -DSTATIC -DWITH_LIBTASK -DWITH_LIBNODE -DEV_MULTIPLICITY=0 -Ideps/v8/include -Isrc -Ideps -Ideps/node -Ideps/node/src -Ideps/node/deps/coupling -Ideps/node/deps/evcom -Ideps/node/deps/http_parser -Ideps/node/deps/libeio -Ideps/node/deps/libev -Ideps/node/deps/udns -Ideps/node/build/default/src -Ibuild/include/core/extend/ -c lib/core/extend/extend.cpp -o build/core/extend/extend.o
lib/core/extend/extend.cpp: In function ‘v8::Handle<v8::Object> core_extend(v8::Handle<v8::Object>)’:
lib/core/extend/extend.cpp:18: error: ‘EXTEND_JS’ was not declared in this scope
make: *** [build/core/extend/extend.o] Error 1
Liboii would probably allow high-performance computation, especially useful for stats
Old-style parameter macros look ugly when instantiated in big numbers, allow an unnecessary degree of freedom (parameter indexes).
#define ARG_obj(v,i) v8::Local<v8::Object> v=args[i]->ToObject();
leads to
ARG_COUNT(4);
ARG_utf8(data,0);
ARG_int(size,1);
ARG_int(nmemb,2);
ARG_obj(fileObj,3);
ARGINT-style macros may add too much overhead.
Need a new syntax, e.g.
FUNCTION(some_function, P_int(a), P_str(b), P_obj(c)) {
// a will be an int, b will be a str and c will be an obj
} END
plus pluggable error processing code, e.g.
#define ARGS_INVALID return JS_undefined;
Right now startup times are about 80ms on my machine, while Python starts in 40ms and spidermonkey in 4ms...
Maximum execution time
Maximum memory consumption
Script termination from the side has now been added to V8. Look for
the TerminateExecution methods in the API and have a look at the
test/cctest/test-thread-termination.cc test file for examples of using
it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.