fibjs / fibjs Goto Github PK
View Code? Open in Web Editor NEWJavaScript on Fiber (built on Chrome's V8 JavaScript engine)
Home Page: https://fibjs.org
License: Other
JavaScript on Fiber (built on Chrome's V8 JavaScript engine)
Home Page: https://fibjs.org
License: Other
//栈向上增长
stack = (void **) fb + stacksize / sizeof(void *) - 5;
请问下,这里为什么要 -5?
line 39:
GIT_INFO=`git show | sed -n 's/commit /-DGIT_INFO=/p'`
这句,在对build文件进行了提交后,git show的内容在sed中会找到多个"commit ",导致替换出错
修改为
GIT_INFO=`git log -n 1 --pretty=format:"%H"`
cmake -DBUILD_TYPE=$1 -DGIT_INFO=$GIT_INFO
结果应该是一致的,请确认。
I checked one project named: node-webkit. It glues nodejs and chrome content API, seems useful and stared more than 10 000+. What is your opinion, Mr. xicilion ?
Need an English version of Documentation.
[ 0%] Building C object CMakeFiles/v8.dir/os.c.o
cc1: warning: command line option ‘-std=gnu++11’ is valid for C++/ObjC++ but not for C [enabled by default]
/root/fibjs/vender/v8/os.c:7:2: error: #error cmake_OS Linux
#error cmake_OS Linux
^
/root/fibjs/vender/v8/os.c:30:2: error: #error cmake_OS unknown
#error cmake_OS unknown
^
make[2]: *** [CMakeFiles/v8.dir/os.c.o] Error 1
make[1]: *** [CMakeFiles/v8.dir/all] Error 2
make: *** [all] Error 2
[ 0%] Building CXX object CMakeFiles/v8.dir/src/runtime/runtime-scopes.cc.o
In file included from fibjs/vender/v8/src/checks.h:9,
from fibjs/vender/v8/src/v8.h:31,
from fibjs/vender/v8/src/runtime/runtime-scopes.cc:5:
fibjs/vender/v8/src/base/logging.h: In function ‘std::string* v8::base::CheckEQImpl(const Lhs&, const Rhs&, const char*)’:
。。。
fibjs/vender/v8/src/objects-inl.h: In member function ‘void v8::internal::ExecutableAccessorInfo::clear_setter()’:
fibjs/vender/v8/src/objects-inl.h:7100: error: ‘nullptr’ was not declared in this scope
fibjs/vender/v8/src/objects-inl.h:7100: error: unable to deduce ‘auto’ from ‘’
In file included from
fibjs/vender/v8/src/runtime/runtime-scopes.cc:5:
fibjs/vender/v8/src/v8.h: In static member function ‘static void v8::internal::V8::SetArrayBufferAllocator(v8::ArrayBuffer::Allocator*)’:
fibjs/vender/v8/src/v8.h:77: error: ‘nullptr’ was not declared in this scope
make[2]: *** [CMakeFiles/v8.dir/src/runtime/runtime-scopes.cc.o] Error 1
make[1]: *** [CMakeFiles/v8.dir/all] Error 2
[code]
var http = require('http');
var server = new http.Server('127.0.0.1', 1337, function(){});
server.stop();
------------------------------------------
[test]
$ fibjs test.js
Segmentation fault: 11 (core dumped)
------------------------------------------
[version]
os: Darwin Kernel Version 15.5.0
fibjs:
{
"fibjs": "0.2.0",
"git": "v0.2.0-54-gaaf20a3",
"clang": "7.3",
"date": "Jun 7 2016 13:32:15",
"vender": {
"ev": "4.20",
"expat": "2.1.0",
"gd": "2.1.1",
"jpeg": "8.3",
"leveldb": "1.17",
"mongo": "0.7",
"pcre": "8.21",
"png": "1.5.4",
"mbedtls": "2.2.1",
"snappy": "1.1.2",
"sqlite": "3.11.0",
"tiff": "3.9.5",
"uuid": "1.6.2",
"v8": "5.3.53",
"zlib": "1.2.7"
}
}
最近正在学习fibjs,这两个方法用处挺多的,希望增加
环境:
OS:Centos 6.5 32位
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/i686-pc-linux-gnu/4.8.3/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ./configure --prefix=/usr --enable-checking=release --enable-languages=c,c++ --disable-multilib
Thread model: posix
gcc version 4.8.3 (GCC)
cmake --version
cmake version 2.8.12.2
make -v
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for i386-redhat-linux-gnu
出错的文件
[ 17%] Building CXX object CMakeFiles/fibjs.dir/src/ssl/SslSocket.cpp.o
/home/weixin/fibjs/fibjs/src/ssl/SslSocket.cpp: In destructor 鈥榲irtual fibjs::SslSocket::~SslSocket()鈥?
/home/weixin/fibjs/fibjs/src/ssl/SslSocket.cpp:90:36: error: 鈥榤emset鈥?was not declared in this scope
memset(&m_ssl, 0, sizeof(m_ssl));
^
/home/weixin/fibjs/fibjs/src/ssl/SslSocket.cpp: In member function 鈥榠nt fibjs::SslSocket::my_recv(unsigned char_, size_t)鈥?
/home/weixin/fibjs/fibjs/src/ssl/SslSocket.cpp:134:49: error: 鈥榤emcpy鈥?was not declared in this scope
memcpy(buf, m_recv.c_str() + m_recv_pos, len);
^
make[2]: *_* [CMakeFiles/fibjs.dir/src/ssl/SslSocket.cpp.o] Error 1
make[1]: *** [CMakeFiles/fibjs.dir/all] Error 2
make: *** [all] Error 2
已经编译了几编了
Breakpoint 1, exlib::Service::switchtonext (this=0x194b650) at /home/jiangling/workspace/fibjs/vender/exlib/src/fbService.cpp:163
163 if (!m_resume.empty())
(gdb) n
165 Fiber *old = m_running;
(gdb) n
167 m_running = m_resume.get();
(gdb) p old
$7 = (exlib::Fiber *) 0x19bac30
(gdb) p m_running
$8 = (exlib::Fiber *) 0x19bac30
(gdb) n
169 fb_switch(&old->m_cntxt, &m_running->m_cntxt);
(gdb) n
171 if (m_recycle)
(gdb) n
177 break;
(gdb) p old->m_cntxt
$9 = {Rbp = 27503328, Rbx = 0, Rcx = 26523480, Rdx = 26979392, Rsi = 26979392, Rdi = 26979392, R12 = 0, R13 = 0, R14 = 0, R15 = 0, Rsp = 27503280, Rip = 6391402}
(gdb) p m_running->m_cntxt
$10 = {Rbp = 27503328, Rbx = 0, Rcx = 26523480, Rdx = 26979392, Rsi = 26979392, Rdi = 26979392, R12 = 0, R13 = 0, R14 = 0, R15 = 0, Rsp = 27503280,
Rip = 6391402}
(gdb)
发现old和m_running一样,这里是否不需要fb_switch
? @xicilion
fibjs 可否有功能比较完善的 web 开发框架(类似于 nodejs 的 express, koa 等)?看了 fibjs 的介绍,感觉不错。不过工作中开发任务很紧,不可能从零自己实现一个框架。
孢子社区是成熟的产品,是否基于 fibjs 开发的有 web 框架?
貌似只在工程文件中有,没看有到 fibjs 中使用呢。。
希望能够完全兼容利用npm包管理。
方法1:加上启动参数 -npm
,依赖查找的目录直接改成node_modules
方法2:加上启动参数 -deps dirname
,根据提供的依赖目录去查找
第二种应该感觉更灵活些
console.timeEnd()方法在所用时间大于数小时时,存在溢出问题(如:4768600条MongoDB记录插入:-1656499.98ms,运行不足12小时)
解决办法:/fibjs/src/console/console.cpp:200,使用int64_t代替long
对于js端的CPU密集型处理协程与vm都无能为力;fibjs的可执行文件对于大部分项目来说确实有点大。
这么长的时间都没有人来占个楼层,我就不客气了。。。哇哈哈
是否会有类似npm的包管理软件?
sprintf(msg, "XmlParser: error on line %lu at colum %lu: %s", XML_GetCurrentLineNumber(xml_parser),
at fibjs/src/xml/XmlParser.cpp:217
colum
应为column
RT,对于JS这种语言,是否考虑把模块方法打出来?
类似于命令行参数这种受主观影响比较大的东西随便提pull request感觉不太好,之前加的那个-j放前面个人感觉比较别扭,
征求下意见,可否改成类似于如下形式?
$ ./build.sh
Usage: build.sh <release | release32 | debug | debug32 | clean> [-j jobs] [-v]
-j : enable make -j. jobs: job count
-v : verbose
说明:
另,-h显示usage感觉可有可无。。。
@xicilion 觉得呢?
代码:
var http = require('http');
var svr = new http.Server(9004, function(r){
console.log(r)
r.response.write(r.query.id);
});
svr.run();
命令行:
curl http://localhost:9004?qq=2&id=3
得到的输出中,querySting为:"queryString": "qq=2"
&
后面的没有取到。不过在浏览器中倒是都能取到。
我在js main.js
时,里面有一些报错。不知道是否是这个有影响。包括前面#26.
系统是mac
能够从fib_modules目录读取package.json读取配置,加载包文件。
编译fibjs bin的时候,如果加入-Wall,会出现很多警告,
最多的是类似
Buffer.h:159:3: warning: missing initializer for member ‘fibjs::ClassData::ClassProperty::bStatic’ [-Wmissing-field-initializers]
的问题,
好像所有的初始化
static ClassData::ClassMethod s_method[] =
{
{ "dispose", s_dispose },
{ "toString", s_toString },
{ "toJSON", s_toJSON },
{ "ValueOf", s_ValueOf }
};
确实少了个成员,有没有好的方法可以解决?
var a = new Buffer([0x01,0x02,0x03]);
var b = new Buffer([0x04,0x05,0x06]);
var c = new Buffer([a,b]); // new 或者write操作,传入Buffer数组
console.log(c.length); // 7
console.log(c.hex()); // 0102032c040506
数组的连接符被当做数据赋值了
并行sweeper和主线程无关,和fiber应该也没有关系,可以考虑放开,而不是现在的fiber切换。
@xicilion
It looks like there is already a htonll
macro in Yosemite (apache/zookeeper#19)
#define htonll(x) ((__uint64_t)(x))
ProductName: Mac OS X
ProductVersion: 10.10
BuildVersion: 14A389
sh build Release
In file included from /Users/dusty/Workspace/oss/fibjs_master/vender/zookeeper/include/zookeeper.jute.h:21:
/Users/dusty/Workspace/oss/fibjs_master/vender/zookeeper/include/recordio.h:76:9: error: expected ')'
int64_t htonll(int64_t v);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/sys/_endian.h:141:25: note: expanded from macro 'htonll'
#define htonll(x) __DARWIN_OSSwapInt64(x)
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libkern/_OSByteOrder.h:78:30: note: expanded from macro '__DARWIN_OSSwapInt64'
(__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt64(x) : _OSSwapInt64(x))
^
/Users/dusty/Workspace/oss/fibjs_master/vender/zookeeper/include/recordio.h:76:9: note: to match this '('
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/sys/_endian.h:141:25: note: expanded from macro 'htonll'
#define htonll(x) __DARWIN_OSSwapInt64(x)
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libkern/_OSByteOrder.h:78:5: note: expanded from macro '__DARWIN_OSSwapInt64'
(__builtin_constant_p(x) ? __DARWIN_OSSwapConstInt64(x) : _OSSwapInt64(x))
^
In file included from /Users/dusty/Workspace/oss/fibjs_master/vender/zookeeper/src/mt_adaptor.c:30:
In file included from /Users/dusty/Workspace/oss/fibjs_master/vender/zookeeper/src/zk_adaptor.h:21:
In file included from /Users/dusty/Workspace/oss/fibjs_master/vender/zookeeper/include/zookeeper.jute.h:21:
/Users/dusty/Workspace/oss/fibjs_master/vender/zookeeper/include/recordio.h:76:9: error: conflicting types for '__builtin_constant_p'
int64_t htonll(int64_t v);
sh: build: No such file or directory 我用的是zsh,这有关系么,反正按着文档不能继续
请教前辈:目前我有一个想法是将callback和coroutine结合起来,因为我的需求是需要在某一个coroutine中做IO多路复用,同时发起多路IO操作,但是我不想创建多个coroutine来实现这个功能。设想基于libuv来做,对uv_write等函数添加阻塞调用的方式:即cb变量为NULL时为阻塞调用,非NULL时为callback通知。
但是只将callback用于IO多路复用,在callback中还是使用阻塞式调用,即fibjs的使用方式。
不知想法是否可行,请指教。
Error is:
Scanning dependencies of target snappy
[ 20%] Building CXX object CMakeFiles/snappy.dir/src/snappy-c.cc.o
[ 40%] Building CXX object CMakeFiles/snappy.dir/src/snappy-sinksource.cc.o
[ 60%] Building CXX object CMakeFiles/snappy.dir/src/snappy-stubs-internal.cc.o
[ 80%] Building CXX object CMakeFiles/snappy.dir/src/snappy.cc.o
[100%] Linking CXX static library /tmp/fibjs20150914-1068-1rzgov0/bin/Darwin_Release/vender/libsnappy.a
[100%] Built target snappy
Scanning dependencies of target ev
[ 50%] Building C object CMakeFiles/ev.dir/src/ev.c.o
/tmp/fibjs20150914-1068-1rzgov0/vender/ev/src/ev.c:970:42: error: '_Noreturn' keyword must precede function declarator
ecb_inline void ecb_unreachable (void) ecb_noreturn;
^~~~~~~~~~~~
_Noreturn
/tmp/fibjs20150914-1068-1rzgov0/vender/ev/src/ev.c:773:26: note: expanded from macro 'ecb_noreturn'
#define ecb_noreturn _Noreturn
^
1 error generated.
make[2]: *** [CMakeFiles/ev.dir/src/ev.c.o] Error 1
make[1]: *** [CMakeFiles/ev.dir/all] Error 2
make: *** [all] Error 2
Failure to compile still against the master (xicilion@0179842) here & was reported to Homebrew in Homebrew/legacy-homebrew#42490.
Configuration tested is:
OS X: 10.11-x86_64
Xcode: 7.0
CLT: 7.0.0.0.1.1441394355
Clang: 7.0 build 700
之前一直玩ruby on rails
,最近因为项目需要,用了nodejs
,大概有一个月了。对于nodejs蹩脚的回调,还有调试的不友好,感觉很失望。于是,找到了这里。
我个人觉得,fibjs
是很有希望的项目。发展起来之后,在js语言开发领域,就与nodejs,io.js并驾齐驱,给了开发者另一个很好的选择。
**人,做技术的人很多,优秀的人也很多,但重量级的很少,干脆说没有。我觉得,个中原因就是浮躁,害怕失败。从这个角度,作者 @xicilion 响马,值得俺学习。
看看小日本,几乎每个优秀的开源项目,在支持英文的同时,另一种语言就是日文。ruby也是小日本搞起来的,最初几年同样全是批评的声音,直到rails的出现,才真正火了起来。
优秀是一种品质。失败的产品多种多样,成功的产品都具有共同的特点:完善的文档、简单的开发调试方法、优秀的扩展机制,这些足可以让社区自我复制和发展,当然如果有兼容其他已有资源的特点,或类似rails的伟大应用实例,更有引爆社区的力量。
fibjs
可能还有很长一段路要走,但是只要有了起点,终点就一定不会远。
先fork
了,看我能做些什么?
`
var db = require("db");
//#号貌似有问题
var mysql = db.openMySQL("mysql://user:n#[email protected]/db");
var rs = mysql.execute("select count(1) from ddd");
console.log(rs)
`
最近想用fibjs搞一个网络检测类似的东西,发现fibjs没有对应的组件。
以后会支持吗
➜ fibjs-master ./build Release
sh: build: No such file or directory
➜ fibjs-master sh build Release
sh: build: No such file or directory
➜ fibjs-master sh build
Usage: build <Release | Release32 | Debug | Debug32 | clean> [-jn] [-v]
-j: enable make '-j' option.
if 'n' is not given, will set jobs to auto detected core count, otherwise n is used.
-v: verbose make
已经装过 cmake。brew install cmake
@xicilion 目前使用 Fibjs 内建的 HTTP 模块创建的 HTTP Server 是不是不支持识别 客户端传送过来的 Content-Type
呢?目前似乎在 客户端的 request 里面指定 body
数据的格式是 'application/json' 就直接出错误哦。
另外, 要怎么读取出 这个 request 的 http body 段的原内容呢?这样的话,可以自己解析。
在console_base::readLine() 中linux下加载libreadline.so时,可否加入对动态库版本的支持?
想法为:
before:
#ifdef MacOS
void *handle = dlopen("libreadline.dylib", RTLD_LAZY);
#else
void *handle = dlopen("libreadline.so", RTLD_LAZY);
#endif
after:
#ifdef MacOS
void *handle = dlopen("libreadline.dylib", RTLD_LAZY);
#else
#define ARRAYSIZE(a) \
((sizeof(a) / sizeof(*(a))) / static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
const char* readline_dlib_names[] = {
"libreadline.so.6",
"libreadline.so.5",
"libreadline.so"
};
const size_t readline_dlib_names_size = ARRAYSIZE(readline_dlib_names);
void *handle = 0;
for(size_t i = 0; i < readline_dlib_names_size; i++){
handle = dlopen(readline_dlib_names[i], RTLD_LAZY);
if(handle) break;
}
#undef ARRAYSIZE
#endif
俺英文不好就不用英文提issue了。我觉得fibjs的出现当然是好的,作者将其开源更是令人鼓舞和钦佩的。像node-webkit一样,一定会成会优秀的开源项目(个人所见)。不过,前提是要国际化额,node-webkit就做得很好。。commit时要用英文,readme最好中英两份,注释也要用英文,提issue也要用英文(要不老外也看不懂),然后适时去国外论坛推广下,才会有更多的国际牛人参与这个开源项目,要不凭一个公司或国内少数人的努力,那等其成熟被人接受要慢好多年呐。如上。
原谅我强迫症 😃
最近,我分别在Rust/Golang/Swift/Ocaml/Python/PHP这几个语言里面测试了 存储一个有 1 0000 0000 个整数列表 ,分别需要多大的空间。
Rust 表现最好,只需要300MB.
Golang 需要734MB.
Swift 需要 1GB.
Python 需要 3GB.
PHP 需要 13.75GB内存..... ( 并且执行时间超过 20秒, python 只需要 2秒 )
以下是 Fibjs 的内存占用,截至程序崩溃,fibjs 需要内存 530 多 MB.
不知道是 V8引擎的问题还是fibjs的问题。
➜ Linux_Release git:(master) ./fibjs test_mem.js
<--- Last few GCs --->
1140 ms: Mark-sweep 958.4 (995.3) -> 575.9 (612.8) MB, 77.3 / 0 ms (+ 0.0 ms in 1 steps since start of marking, biggest step 0.0 ms) [allocation failure] [GC in old space requested].
1241 ms: Mark-sweep 575.9 (612.8) -> 575.9 (612.8) MB, 100.7 / 0 ms [allocation failure] [GC in old space requested].
1337 ms: Mark-sweep 575.9 (612.8) -> 575.9 (612.8) MB, 96.3 / 0 ms [last resort gc].
1439 ms: Mark-sweep 575.9 (612.8) -> 575.9 (612.8) MB, 101.5 / 0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x1c94a4e36619 <JS Object>
2: /* anonymous */ [test_mem.js:~1] [pc=0x31515ea7784a] (this=0x2f3f38c9e869 <an Object with map 0x2660c25065c9>,require=0x2f3f38c10ec9 <JS Function (SharedFunctionInfo 0x2f3f38c10e39)>,run=0x2f3f38c11069 <JS Function (SharedFunctionInfo 0x2f3f38c10fd9)>)
==== Details ================================================
[2]: /* anonymous */ [test_mem.js:~1] [pc=0x31515ea7784a] (this=0x2f3f38c...
#
# Fatal error in CALL_AND_RETRY_LAST
# Allocation failed - process out of memory
#
考虑到 coroutine.start(func, ...)
已经有这个功能了,另外修改 Function.prototype
感觉还是有点不够严谨,再说了 someFunction.start
看起来也不够扎眼(不仅仅是人眼,还有静态检查器).. 能否将 coroutine.start(func, ...)
定为推荐使用方式,而将 Function::start
逐步淡出呢?
当然也并不是说 Function::start(...)
非常的不好,fibjs 作为一个语言层面上的 coroutine 实现,和原本的 js 有些不同也是完全可以接受的。我只是感觉从一个语法的角度上来看,可能有更好的方法。
Function::start(...)
Since we have already got coroutine.start(func, ...)
, I think maybe we could deprecate Function::start(...)
. The former can be identified in the code and analyzed by static checkers more easily. Another reason is that I don't like the way that the latter is implemented (by modifying a builtin type's prototype).
Thank you.
fs.readFile 有时候只能读取出部分内容,可能因为文件里有个别奇怪的字符的问题,但是不管遇到什么字符都应该能读取完整的文件内容
我有测试文件,但是我怎么上传呢
var smtp = require("Smtp");貌似报错的。
两个CMakeLists.txt里面的这一行
-c
好像属于gcc的命令行选项,flag里面应该不需要,请确认。
看到 fibjs 受到了全球各地人们的关注,是件很开心的事情。是不是能够建立一个线上的社区呢?还是比较推荐 Discourse 的,可以讨论,可以聊天也可以当做邮件列表。
代码如下:
var http = require('http');
var svr = new http.Server(9005, function(r){
console.log(r.query.id)
r.response.write('x');
});
svr.run();
浏览器中打开网址http://localhost:9005/?qq=2&id=3
命令行中输入如下:
3
undefined
貌似是执行了两次。第二次r.query为空。因此无法输出id。
如果上面的代码改为
var http = require('http');
var svr = new http.Server(9005, function(r){
// console.log(r.query.id)
r.response.write(r.query.id);
});
svr.run();
浏览器中看到输出只有3,没有undefined。
初次接触,不知是何缘故。
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.