V8 on Angstrom Zaurus

Chrome shines! V8 rocks!

I've been using Chrome since release and love more and more. Chrome is maximized on my desktop all the time and I'm crusing the Net with shortcut keys.

Chrome on Android is rumored. And amazingly V8 the Javascript engine is already ported to ARM. I couldn't wait for Android Chrome, so tried to build V8 for Zaurus.

First of all, grab the source code.
svn checkout http://v8.googlecode.com/svn/trunk/ v8
I tried to cross compile by modifing scons scripts, but no luck. Next I tried to port scons itself to Angstrom but so many problems, then forgot about it.

Quick dirty hack. Batch build, I tried.

First dry run scons on PC to generate script file.
$ scons -nQ toolchain=gcc arch=arm library=static os=linux sample=shell > build.sh  2>&1
Copy it and add #!/bin/sh at the fist line, add executable permission and fire it.
# ./build.sh
src/macro-assembler-arm.cc:66:2: error: #error "for thumb inter-working we require architecture v5t or above"
It looks V8 is really ported to ARM. It is promissing. I modified build.sh adding;
-march=armv5te -mtune=xscale
to tell compile generate Armv5t binary. There is a little patch required to compile platform-linux.cc
diff -ur --exclude .o v8/src/platform-linux.cc v8-work/src/platform-linux.cc
--- v8/src/platform-linux.cc 2008-09-03 11:42:30.000000000 +0900
+++ v8y-work/src/platform-linux.cc 2008-09-07 11:02:35.226762251 +0900
@@ -567,8 +567,10 @@
ucontext_t* ucontext = reinterpret_cast(context);
mcontext_t& mcontext = ucontext->uc_mcontext;
#if defined (__arm__) || defined(__thumb__)
- sample.pc = mcontext.gregs[R15];
- sample.sp = mcontext.gregs[R13];
+ // sample.pc = mcontext.gregs[R15];
+ // sample.sp = mcontext.gregs[R13];
+ sample.pc = mcontext.arm_pc;
+ sample.sp = mcontext.arm_sp;
sample.pc = mcontext.gregs[REG_EIP];
sample.sp = mcontext.gregs[REG_ESP];
Another and final touch to build.sh is required to avoid JS2C script. Commnet out JS2C line and copy libraries.cc from PC. I guess this libraries.cc is platform independent, so just scons on PC and pull obj/relrease/libraries.cc to Zaurus.

Finally I got libv8.a and shell program
# file shell
shell: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.6.14,
dynamically linked (uses shared libs), not stripped

# ./shell
V8 version 0.3.0
> for (var n in function() { return this } () ) print(n)
> quit()
I tried to run benchmark script in source tree but the program dies in out of memory.
~/work/v8/benchmarks# ../shell run.js 

# Fatal error in CALL_HEAP_FUNCTION
# Allocation failed - process out of memory


Conclusion. V8 does run on ARM. V8 on Android will be possible once source code becomes available.


posted by 安藤恐竜 at 17:18 | Comment(1) | TrackBack(0) | 日記




・マイブログの【設定】 > 【広告設定】 より、「60日間更新が無い場合」 の 「広告を表示しない」にチェックを入れて保存する。