webruby 0.2.2 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (245) hide show
  1. checksums.yaml +4 -4
  2. data/lib/webruby/config.rb +4 -9
  3. data/lib/webruby/rake/files.rake +2 -2
  4. data/modules/emscripten/AUTHORS +9 -1
  5. data/modules/emscripten/CONTRIBUTING.markdown +5 -0
  6. data/modules/emscripten/ChangeLog +435 -0
  7. data/modules/emscripten/cmake/Modules/FindOpenAL.cmake +26 -0
  8. data/modules/emscripten/cmake/Platform/Emscripten.cmake +9 -2
  9. data/modules/emscripten/em++ +0 -2
  10. data/modules/emscripten/emcc +92 -32
  11. data/modules/emscripten/emlink.py +16 -13
  12. data/modules/emscripten/emmake +1 -1
  13. data/modules/emscripten/emrun +918 -0
  14. data/modules/emscripten/emrun.bat +2 -0
  15. data/modules/emscripten/emscripten.py +545 -20
  16. data/modules/emscripten/src/analyzer.js +6 -1
  17. data/modules/emscripten/src/compiler.js +25 -16
  18. data/modules/emscripten/src/emrun_postjs.js +20 -0
  19. data/modules/emscripten/{tests → src}/hello_world.js +0 -0
  20. data/modules/emscripten/src/intertyper.js +45 -16
  21. data/modules/emscripten/src/jsifier.js +78 -48
  22. data/modules/emscripten/src/library.js +381 -96
  23. data/modules/emscripten/src/library_browser.js +50 -53
  24. data/modules/emscripten/src/library_egl.js +66 -24
  25. data/modules/emscripten/src/library_fs.js +122 -90
  26. data/modules/emscripten/src/library_gl.js +739 -353
  27. data/modules/emscripten/src/library_glfw.js +9 -3
  28. data/modules/emscripten/src/library_glut.js +10 -5
  29. data/modules/emscripten/src/library_idbfs.js +14 -14
  30. data/modules/emscripten/src/library_memfs.js +65 -41
  31. data/modules/emscripten/src/library_nodefs.js +61 -9
  32. data/modules/emscripten/src/library_openal.js +4 -4
  33. data/modules/emscripten/src/library_path.js +9 -13
  34. data/modules/emscripten/src/library_sdl.js +301 -64
  35. data/modules/emscripten/src/library_sockfs.js +7 -5
  36. data/modules/emscripten/src/modules.js +62 -22
  37. data/modules/emscripten/src/parseTools.js +135 -102
  38. data/modules/emscripten/src/postamble.js +3 -4
  39. data/modules/emscripten/src/preamble.js +49 -29
  40. data/modules/emscripten/src/proxyClient.js +1 -1
  41. data/modules/emscripten/src/proxyWorker.js +10 -10
  42. data/modules/emscripten/src/relooper/Relooper.cpp +15 -4
  43. data/modules/emscripten/src/runtime.js +32 -8
  44. data/modules/emscripten/src/settings.js +25 -8
  45. data/modules/emscripten/src/shell.html +6 -3
  46. data/modules/emscripten/src/shell.js +13 -11
  47. data/modules/emscripten/src/simd.js +602 -432
  48. data/modules/emscripten/src/struct_info.json +22 -2
  49. data/modules/emscripten/src/utility.js +32 -17
  50. data/modules/emscripten/system/include/SDL/SDL_events.h +1 -0
  51. data/modules/emscripten/system/include/compat/ctype.h +17 -0
  52. data/modules/emscripten/system/include/compat/wchar.h +23 -0
  53. data/modules/emscripten/system/include/compat/wctype.h +23 -0
  54. data/modules/emscripten/system/include/emscripten/emmintrin.h +87 -0
  55. data/modules/emscripten/system/include/emscripten/emscripten.h +30 -4
  56. data/modules/emscripten/system/include/emscripten/vector.h +29 -1
  57. data/modules/emscripten/system/include/emscripten/xmmintrin.h +131 -0
  58. data/modules/emscripten/system/include/libcxx/CREDITS.TXT +9 -1
  59. data/modules/emscripten/system/include/libcxx/__bit_reference +8 -8
  60. data/modules/emscripten/system/include/libcxx/__config +95 -17
  61. data/modules/emscripten/system/include/libcxx/__debug +25 -4
  62. data/modules/emscripten/system/include/libcxx/__functional_03 +7 -7
  63. data/modules/emscripten/system/include/libcxx/__functional_base +169 -9
  64. data/modules/emscripten/system/include/libcxx/__functional_base_03 +1 -1
  65. data/modules/emscripten/system/include/libcxx/__hash_table +25 -25
  66. data/modules/emscripten/system/include/libcxx/__locale +21 -19
  67. data/modules/emscripten/system/include/libcxx/__mutex_base +2 -33
  68. data/modules/emscripten/system/include/libcxx/__split_buffer +9 -9
  69. data/modules/emscripten/system/include/libcxx/__std_stream +14 -0
  70. data/modules/emscripten/system/include/libcxx/__tree +35 -26
  71. data/modules/emscripten/system/include/libcxx/__tuple +15 -15
  72. data/modules/emscripten/system/include/libcxx/__tuple_03 +2 -2
  73. data/modules/emscripten/system/include/libcxx/__undef_min_max +8 -0
  74. data/modules/emscripten/system/include/libcxx/algorithm +121 -110
  75. data/modules/emscripten/system/include/libcxx/array +15 -15
  76. data/modules/emscripten/system/include/libcxx/bitset +4 -4
  77. data/modules/emscripten/system/include/libcxx/chrono +51 -17
  78. data/modules/emscripten/system/include/libcxx/cmath +25 -23
  79. data/modules/emscripten/system/include/libcxx/codecvt +21 -18
  80. data/modules/emscripten/system/include/libcxx/complex +48 -7
  81. data/modules/emscripten/system/include/libcxx/cstddef +1 -1
  82. data/modules/emscripten/system/include/libcxx/cstdio +8 -1
  83. data/modules/emscripten/system/include/libcxx/cstdlib +1 -1
  84. data/modules/emscripten/system/include/libcxx/cwchar +1 -1
  85. data/modules/emscripten/system/include/libcxx/deque +26 -12
  86. data/modules/emscripten/system/include/libcxx/dynarray +311 -0
  87. data/modules/emscripten/system/include/libcxx/exception +4 -4
  88. data/modules/emscripten/system/include/libcxx/ext/__hash +3 -3
  89. data/modules/emscripten/system/include/libcxx/ext/hash_map +19 -15
  90. data/modules/emscripten/system/include/libcxx/ext/hash_set +7 -3
  91. data/modules/emscripten/system/include/libcxx/forward_list +33 -7
  92. data/modules/emscripten/system/include/libcxx/fstream +4 -4
  93. data/modules/emscripten/system/include/libcxx/functional +200 -170
  94. data/modules/emscripten/system/include/libcxx/future +83 -39
  95. data/modules/emscripten/system/include/libcxx/initializer_list +24 -11
  96. data/modules/emscripten/system/include/libcxx/iomanip +147 -0
  97. data/modules/emscripten/system/include/libcxx/ios +24 -16
  98. data/modules/emscripten/system/include/libcxx/iosfwd +19 -19
  99. data/modules/emscripten/system/include/libcxx/istream +13 -8
  100. data/modules/emscripten/system/include/libcxx/iterator +108 -417
  101. data/modules/emscripten/system/include/libcxx/limits +8 -4
  102. data/modules/emscripten/system/include/libcxx/list +28 -8
  103. data/modules/emscripten/system/include/libcxx/locale +153 -390
  104. data/modules/emscripten/system/include/libcxx/map +280 -100
  105. data/modules/emscripten/system/include/libcxx/memory +49 -97
  106. data/modules/emscripten/system/include/libcxx/mutex +2 -2
  107. data/modules/emscripten/system/include/libcxx/new +43 -14
  108. data/modules/emscripten/system/include/libcxx/numeric +2 -2
  109. data/modules/emscripten/system/include/libcxx/optional +697 -0
  110. data/modules/emscripten/system/include/libcxx/ostream +17 -8
  111. data/modules/emscripten/system/include/libcxx/queue +5 -5
  112. data/modules/emscripten/system/include/libcxx/random +53 -51
  113. data/modules/emscripten/system/include/libcxx/ratio +11 -11
  114. data/modules/emscripten/system/include/libcxx/readme.txt +1 -1
  115. data/modules/emscripten/system/include/libcxx/regex +23 -20
  116. data/modules/emscripten/system/include/libcxx/scoped_allocator +1 -1
  117. data/modules/emscripten/system/include/libcxx/set +166 -2
  118. data/modules/emscripten/system/include/libcxx/shared_mutex +419 -0
  119. data/modules/emscripten/system/include/libcxx/sstream +4 -4
  120. data/modules/emscripten/system/include/libcxx/stack +3 -3
  121. data/modules/emscripten/system/include/libcxx/streambuf +5 -5
  122. data/modules/emscripten/system/include/libcxx/string +372 -324
  123. data/modules/emscripten/system/include/libcxx/support/ibm/limits.h +99 -0
  124. data/modules/emscripten/system/include/libcxx/support/ibm/support.h +54 -0
  125. data/modules/emscripten/system/include/libcxx/support/ibm/xlocale.h +326 -0
  126. data/modules/emscripten/system/include/libcxx/support/win32/limits_win32.h +6 -6
  127. data/modules/emscripten/system/include/libcxx/support/win32/locale_win32.h +15 -15
  128. data/modules/emscripten/system/include/libcxx/support/win32/math_win32.h +2 -0
  129. data/modules/emscripten/system/include/libcxx/support/win32/support.h +6 -1
  130. data/modules/emscripten/system/include/libcxx/system_error +14 -8
  131. data/modules/emscripten/system/include/libcxx/thread +7 -8
  132. data/modules/emscripten/system/include/libcxx/tuple +29 -88
  133. data/modules/emscripten/system/include/libcxx/type_traits +253 -209
  134. data/modules/emscripten/system/include/libcxx/typeindex +3 -3
  135. data/modules/emscripten/system/include/libcxx/unordered_map +162 -101
  136. data/modules/emscripten/system/include/libcxx/unordered_set +79 -2
  137. data/modules/emscripten/system/include/libcxx/utility +20 -20
  138. data/modules/emscripten/system/include/libcxx/valarray +23 -23
  139. data/modules/emscripten/system/include/libcxx/vector +114 -91
  140. data/modules/emscripten/system/lib/libc/musl/src/regex/regcomp.c +3352 -0
  141. data/modules/emscripten/system/lib/libc/musl/src/regex/regerror.c +35 -0
  142. data/modules/emscripten/system/lib/libc/musl/src/regex/regexec.c +1011 -0
  143. data/modules/emscripten/system/lib/libc/musl/src/regex/tre-mem.c +158 -0
  144. data/modules/emscripten/system/lib/libc/musl/src/regex/tre.h +231 -0
  145. data/modules/emscripten/system/lib/libcextra.symbols +7 -0
  146. data/modules/emscripten/system/lib/libcxx/CREDITS.TXT +9 -1
  147. data/modules/emscripten/system/lib/libcxx/algorithm.cpp +1 -0
  148. data/modules/emscripten/system/lib/libcxx/debug.cpp +66 -42
  149. data/modules/emscripten/system/lib/libcxx/exception.cpp +88 -16
  150. data/modules/emscripten/system/lib/libcxx/future.cpp +6 -0
  151. data/modules/emscripten/system/lib/libcxx/ios.cpp +7 -2
  152. data/modules/emscripten/system/lib/libcxx/iostream.cpp +8 -8
  153. data/modules/emscripten/system/lib/libcxx/locale.cpp +38 -11
  154. data/modules/emscripten/system/lib/libcxx/mutex.cpp +3 -0
  155. data/modules/emscripten/system/lib/libcxx/new.cpp +44 -10
  156. data/modules/emscripten/system/lib/libcxx/optional.cpp +25 -0
  157. data/modules/emscripten/system/lib/libcxx/random.cpp +26 -0
  158. data/modules/emscripten/system/lib/libcxx/readme.txt +1 -1
  159. data/modules/emscripten/system/lib/libcxx/shared_mutex.cpp +101 -0
  160. data/modules/emscripten/system/lib/libcxx/stdexcept.cpp +11 -7
  161. data/modules/emscripten/system/lib/libcxx/string.cpp +3 -1
  162. data/modules/emscripten/system/lib/libcxx/strstream.cpp +7 -7
  163. data/modules/emscripten/system/lib/libcxx/support/win32/locale_win32.cpp +12 -13
  164. data/modules/emscripten/system/lib/libcxx/support/win32/support.cpp +33 -36
  165. data/modules/emscripten/system/lib/libcxx/symbols +187 -168
  166. data/modules/emscripten/system/lib/libcxx/system_error.cpp +1 -0
  167. data/modules/emscripten/system/lib/libcxx/thread.cpp +7 -3
  168. data/modules/emscripten/system/lib/libcxx/typeinfo.cpp +9 -6
  169. data/modules/emscripten/system/lib/libcxx/valarray.cpp +2 -0
  170. data/modules/emscripten/third_party/lzma.js/doit.bat +4 -0
  171. data/modules/emscripten/third_party/lzma.js/doit.sh +9 -2
  172. data/modules/emscripten/tools/cache.py +5 -7
  173. data/modules/emscripten/tools/cache.pyc +0 -0
  174. data/modules/emscripten/tools/eliminator/asm-eliminator-test-output.js +7 -0
  175. data/modules/emscripten/tools/eliminator/asm-eliminator-test.js +9 -1
  176. data/modules/emscripten/tools/eliminator/eliminator-test-output.js +3 -0
  177. data/modules/emscripten/tools/eliminator/eliminator-test.js +9 -1
  178. data/modules/emscripten/tools/file_packager.py +93 -50
  179. data/modules/emscripten/tools/js-optimizer.js +98 -48
  180. data/modules/emscripten/tools/js_optimizer.py +4 -4
  181. data/modules/emscripten/tools/js_optimizer.pyc +0 -0
  182. data/modules/emscripten/tools/jsrun.py +1 -1
  183. data/modules/emscripten/tools/jsrun.pyc +0 -0
  184. data/modules/emscripten/tools/response_file.py +6 -0
  185. data/modules/emscripten/tools/response_file.pyc +0 -0
  186. data/modules/emscripten/tools/settings_template_readonly.py +2 -0
  187. data/modules/emscripten/tools/shared.py +88 -34
  188. data/modules/emscripten/tools/shared.pyc +0 -0
  189. data/modules/emscripten/tools/split.py +21 -13
  190. data/modules/mruby/build_config.rb +7 -1
  191. data/modules/mruby/doc/compile/README.md +5 -9
  192. data/modules/mruby/include/mrbconf.h +5 -2
  193. data/modules/mruby/include/mruby/array.h +1 -0
  194. data/modules/mruby/include/mruby/compile.h +2 -4
  195. data/modules/mruby/include/mruby/dump.h +7 -16
  196. data/modules/mruby/include/mruby/hash.h +1 -1
  197. data/modules/mruby/include/mruby/irep.h +14 -2
  198. data/modules/mruby/include/mruby/khash.h +8 -7
  199. data/modules/mruby/include/mruby/string.h +1 -0
  200. data/modules/mruby/include/mruby/value.h +5 -2
  201. data/modules/mruby/include/mruby.h +12 -13
  202. data/modules/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +16 -6
  203. data/modules/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +18 -30
  204. data/modules/mruby/mrbgems/mruby-fiber/src/fiber.c +21 -0
  205. data/modules/mruby/mrbgems/mruby-math/src/math.c +1 -1
  206. data/modules/mruby/mrbgems/mruby-random/src/random.c +144 -47
  207. data/modules/mruby/mrbgems/mruby-random/test/random.rb +44 -0
  208. data/modules/mruby/mrbgems/mruby-struct/src/struct.c +5 -5
  209. data/modules/mruby/mrblib/numeric.rb +99 -33
  210. data/modules/mruby/src/array.c +11 -4
  211. data/modules/mruby/src/backtrace.c +2 -2
  212. data/modules/mruby/src/class.c +49 -30
  213. data/modules/mruby/src/codegen.c +131 -79
  214. data/modules/mruby/src/debug.c +1 -1
  215. data/modules/mruby/src/dump.c +213 -163
  216. data/modules/mruby/src/error.c +17 -17
  217. data/modules/mruby/src/error.h +1 -1
  218. data/modules/mruby/src/etc.c +10 -0
  219. data/modules/mruby/src/gc.c +35 -17
  220. data/modules/mruby/src/hash.c +5 -5
  221. data/modules/mruby/src/kernel.c +36 -14
  222. data/modules/mruby/src/load.c +238 -296
  223. data/modules/mruby/src/numeric.c +18 -98
  224. data/modules/mruby/src/object.c +3 -5
  225. data/modules/mruby/src/parse.y +63 -56
  226. data/modules/mruby/src/proc.c +8 -5
  227. data/modules/mruby/src/re.h +0 -1
  228. data/modules/mruby/src/state.c +65 -27
  229. data/modules/mruby/src/string.c +3 -31
  230. data/modules/mruby/src/symbol.c +3 -3
  231. data/modules/mruby/src/variable.c +12 -5
  232. data/modules/mruby/src/vm.c +90 -72
  233. data/modules/mruby/tasks/mruby_build.rake +10 -1
  234. data/modules/mruby/tasks/toolchains/gcc.rake +12 -2
  235. data/modules/mruby/tasks/toolchains/{vs2012.rake → visualcpp.rake} +1 -1
  236. data/modules/mruby/test/driver.c +3 -3
  237. data/modules/mruby/test/t/array.rb +5 -5
  238. data/modules/mruby/test/t/class.rb +14 -1
  239. data/modules/mruby/test/t/kernel.rb +4 -0
  240. data/modules/mruby/test/t/module.rb +4 -4
  241. data/modules/mruby/test/t/nameerror.rb +1 -1
  242. data/modules/mruby/tools/mrbc/mrbc.c +23 -17
  243. data/modules/mruby/travis_config.rb +10 -1
  244. metadata +28 -5
  245. data/modules/mruby/tasks/toolchains/vs2010.rake +0 -3
@@ -14,9 +14,9 @@
14
14
  #include "limits"
15
15
  #include <sys/types.h>
16
16
  #if !defined(_WIN32)
17
- #if !defined(__sun__) && !defined(__linux__)
17
+ #if !defined(__sun__) && !defined(__linux__) && !defined(_AIX)
18
18
  #include <sys/sysctl.h>
19
- #endif // !__sun__ && !__linux__
19
+ #endif // !__sun__ && !__linux__ && !_AIX
20
20
  #include <unistd.h>
21
21
  #endif // !_WIN32
22
22
 
@@ -89,7 +89,11 @@ thread::hardware_concurrency() _NOEXCEPT
89
89
  #else // defined(CTL_HW) && defined(HW_NCPU)
90
90
  // TODO: grovel through /proc or check cpuid on x86 and similar
91
91
  // instructions on other architectures.
92
- #warning hardware_concurrency not yet implemented
92
+ # if defined(_MSC_VER) && ! defined(__clang__)
93
+ _LIBCPP_WARNING("hardware_concurrency not yet implemented")
94
+ # else
95
+ # warning hardware_concurrency not yet implemented
96
+ # endif
93
97
  return 0; // Means not computable [thread.thread.static]
94
98
  #endif // defined(CTL_HW) && defined(HW_NCPU)
95
99
  }
@@ -20,12 +20,18 @@
20
20
 
21
21
  #include "typeinfo"
22
22
 
23
- #if !(defined(_LIBCPPABI_VERSION) || defined(LIBCXXRT))
23
+ #if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION)
24
24
 
25
25
  std::bad_cast::bad_cast() _NOEXCEPT
26
26
  {
27
27
  }
28
28
 
29
+ std::bad_typeid::bad_typeid() _NOEXCEPT
30
+ {
31
+ }
32
+
33
+ #ifndef __GLIBCXX__
34
+
29
35
  std::bad_cast::~bad_cast() _NOEXCEPT
30
36
  {
31
37
  }
@@ -36,10 +42,6 @@ std::bad_cast::what() const _NOEXCEPT
36
42
  return "std::bad_cast";
37
43
  }
38
44
 
39
- std::bad_typeid::bad_typeid() _NOEXCEPT
40
- {
41
- }
42
-
43
45
  std::bad_typeid::~bad_typeid() _NOEXCEPT
44
46
  {
45
47
  }
@@ -67,4 +69,5 @@ std::bad_typeid::what() const _NOEXCEPT
67
69
  }
68
70
  #endif
69
71
 
70
- #endif // _LIBCPPABI_VERSION
72
+ #endif // !__GLIBCXX__
73
+ #endif // !LIBCXXRT && !_LIBCPPABI_VERSION
@@ -7,6 +7,8 @@
7
7
  //
8
8
  //===----------------------------------------------------------------------===//
9
9
 
10
+ #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
11
+
10
12
  #include "valarray"
11
13
 
12
14
  _LIBCPP_BEGIN_NAMESPACE_STD
@@ -0,0 +1,4 @@
1
+ cd lzip
2
+ call mingw32-make lzip
3
+ copy /Y lzip.exe ..\lzma-native.exe
4
+ cd ..
@@ -5,7 +5,14 @@ export CXX=`../../../em-config LLVM_ROOT`/clang++
5
5
  echo "native"
6
6
  make clean
7
7
  DECODER_ONLY=0 make lzip -j 4 # native build
8
- mv lzip ../lzma-native
8
+ case `uname` in
9
+ *_NT*)
10
+ mv lzip.exe ../lzma-native.exe
11
+ ;;
12
+ *)
13
+ mv lzip ../lzma-native
14
+ ;;
15
+ esac
9
16
 
10
17
  exit # just build natively, that's it
11
18
 
@@ -18,7 +25,7 @@ echo "bitcode decoder only"
18
25
  make clean
19
26
  DECODER_ONLY=1 ../../../emmake make lzip -j 4
20
27
  mv lzip lzip-decoder.bc
21
-
28
+
22
29
  cd ..
23
30
 
24
31
  echo "javascript full"
@@ -13,8 +13,7 @@ class Cache:
13
13
  self.debug = debug
14
14
 
15
15
  def ensure(self):
16
- if not os.path.exists(self.dirname):
17
- os.makedirs(self.dirname)
16
+ shared.safe_ensure_dirs(self.dirname)
18
17
 
19
18
  def erase(self):
20
19
  tempfiles.try_delete(self.dirname)
@@ -48,11 +47,7 @@ class JCache:
48
47
 
49
48
  def ensure(self):
50
49
  self.cache.ensure()
51
- if not os.path.exists(self.dirname):
52
- try:
53
- os.makedirs(self.dirname)
54
- except (IOError, OSError):
55
- pass
50
+ shared.safe_ensure_dirs(self.dirname)
56
51
 
57
52
  def get_shortkey(self, keys):
58
53
  if type(keys) not in [list, tuple]:
@@ -196,3 +191,6 @@ def chunkify(funcs, chunk_size, chunking_file, DEBUG=False):
196
191
  # if previous_mapping.get(ident) != new_mapping.get(ident):
197
192
  # print >> sys.stderr, 'mapping inconsistency', ident, previous_mapping.get(ident), new_mapping.get(ident)
198
193
  return [''.join([func[1] for func in chunk]) for chunk in chunks] # remove function names
194
+
195
+ import shared
196
+
Binary file
@@ -291,4 +291,11 @@ function watIf() {
291
291
  if ($cmp38) {} else {}
292
292
  }
293
293
  }
294
+ function select2($foundBase_0_off0) {
295
+ $foundBase_0_off0 = $foundBase_0_off0 | 0;
296
+ var $call24 = 0;
297
+ $call24 = MUST_RUN() | 0;
298
+ STACKTOP = sp;
299
+ return ($foundBase_0_off0 ? 0 : $call24) | 0;
300
+ }
294
301
 
@@ -362,5 +362,13 @@ function watIf() {
362
362
  }
363
363
  }
364
364
  }
365
- // EMSCRIPTEN_GENERATED_FUNCTIONS: ["asm", "__Z11printResultPiS_j", "_segment_holding", "__ZN5identC2EiPKcPci", "_vec2Length", "exc", "label", "confuusion", "tempDouble", "_org_apache_harmony_luni_util_NumberConverter_freeFormat__", "__ZN23b2EdgeAndPolygonContact8EvaluateEP10b2ManifoldRK11b2TransformS4_", "_java_nio_charset_Charset_forNameInternal___java_lang_String", "looop2", "looop3", "looop4", "looop5", "looop6", "looop7", "looop8", "multiloop", "multiloop2", "tempDouble2", "watIf"]
365
+ function select2($foundBase_0_off0) {
366
+ $foundBase_0_off0 = $foundBase_0_off0 | 0;
367
+ var $call24 = 0, $retval_0 = 0;
368
+ $call24 = MUST_RUN() | 0;
369
+ $retval_0 = $foundBase_0_off0 ? 0 : $call24;
370
+ STACKTOP = sp;
371
+ return $retval_0 | 0;
372
+ }
373
+ // EMSCRIPTEN_GENERATED_FUNCTIONS: ["asm", "__Z11printResultPiS_j", "_segment_holding", "__ZN5identC2EiPKcPci", "_vec2Length", "exc", "label", "confuusion", "tempDouble", "_org_apache_harmony_luni_util_NumberConverter_freeFormat__", "__ZN23b2EdgeAndPolygonContact8EvaluateEP10b2ManifoldRK11b2TransformS4_", "_java_nio_charset_Charset_forNameInternal___java_lang_String", "looop2", "looop3", "looop4", "looop5", "looop6", "looop7", "looop8", "multiloop", "multiloop2", "tempDouble2", "watIf", "select2"]
366
374
 
@@ -6119,4 +6119,7 @@ function intoCond() {
6119
6119
  HEAP32[$115 >> 2] = $NumWords;
6120
6120
  }
6121
6121
  }
6122
+ function math(a, b, c, d) {
6123
+ print(Math_imul(d) + (Math_fround(c) + (a + Math_abs(b))));
6124
+ }
6122
6125
 
@@ -8852,5 +8852,13 @@ function intoCond() {
8852
8852
  HEAP32[$504 >> 2] = $503;
8853
8853
  }
8854
8854
  }
8855
- // EMSCRIPTEN_GENERATED_FUNCTIONS: ["a", "b", "c", "f", "g", "h", "py", "r", "t", "f2", "f3", "llvm3_1", "_inflate", "_malloc", "_mallocNoU", "asm", "phi", "intoCond"]
8855
+ function math(a, b, c, d) {
8856
+ var x, y, z, w;
8857
+ x = a;
8858
+ y = Math_abs(b);
8859
+ z = Math_fround(c);
8860
+ w = Math_imul(d);
8861
+ print(x + y + z + w);
8862
+ }
8863
+ // EMSCRIPTEN_GENERATED_FUNCTIONS: ["a", "b", "c", "f", "g", "h", "py", "r", "t", "f2", "f3", "llvm3_1", "_inflate", "_malloc", "_mallocNoU", "asm", "phi", "intoCond", "math"]
8856
8864
 
@@ -11,10 +11,7 @@ data downloads.
11
11
 
12
12
  Usage:
13
13
 
14
- file_packager.py TARGET [--preload A [B..]] [--embed C [D..]] [--compress COMPRESSION_DATA] [--pre-run] [--crunch[=X]] [--js-output=OUTPUT.js] [--no-force]
15
-
16
- --pre-run Will generate wrapper code that does preloading in Module.preRun. This is necessary if you add this
17
- code before the main file has been loading, which includes necessary components like addRunDependency.
14
+ file_packager.py TARGET [--preload A [B..]] [--embed C [D..]] [--compress COMPRESSION_DATA] [--crunch[=X]] [--js-output=OUTPUT.js] [--no-force] [--use-preload-cache] [--no-heap-copy]
18
15
 
19
16
  --crunch=X Will compress dxt files to crn with quality level X. The crunch commandline tool must be present
20
17
  and CRUNCH should be defined in ~/.emscripten that points to it. JS crunch decompressing code will
@@ -30,6 +27,10 @@ Usage:
30
27
 
31
28
  --use-preload-cache Stores package in IndexedDB so that subsequent loads don't need to do XHR. Checks package version.
32
29
 
30
+ --no-heap-copy If specified, the preloaded filesystem is not copied inside the Emscripten HEAP, but kept in a separate typed array outside it.
31
+ The default, if this is not specified, is to embed the VFS inside the HEAP, so that mmap()ing files in it is a no-op.
32
+ Passing this flag optimizes for fread() usage, omitting it optimizes for mmap() usage.
33
+
33
34
  Notes:
34
35
 
35
36
  * The file packager generates unix-style file paths. So if you are on windows and a file is accessed at
@@ -46,7 +47,7 @@ from shared import Compression, execute, suffix, unsuffixed
46
47
  from subprocess import Popen, PIPE, STDOUT
47
48
 
48
49
  if len(sys.argv) == 1:
49
- print '''Usage: file_packager.py TARGET [--preload A...] [--embed B...] [--compress COMPRESSION_DATA] [--pre-run] [--crunch[=X]] [--js-output=OUTPUT.js] [--no-force] [--use-preload-cache]
50
+ print '''Usage: file_packager.py TARGET [--preload A...] [--embed B...] [--compress COMPRESSION_DATA] [--crunch[=X]] [--js-output=OUTPUT.js] [--no-force] [--use-preload-cache] [--no-heap-copy]
50
51
  See the source for more details.'''
51
52
  sys.exit(0)
52
53
 
@@ -69,12 +70,16 @@ in_preload = False
69
70
  in_embed = False
70
71
  has_preloaded = False
71
72
  in_compress = 0
72
- pre_run = False
73
73
  crunch = 0
74
74
  plugins = []
75
75
  jsoutput = None
76
76
  force = True
77
+ # If set to True, IndexedDB (IDBFS in library_idbfs.js) is used to locally cache VFS XHR so that subsequent
78
+ # page loads can read the data from the offline cache instead.
77
79
  use_preload_cache = False
80
+ # If set to True, the blob received from XHR is moved to the Emscripten HEAP, optimizing for mmap() performance.
81
+ # If set to False, the XHR blob is kept intact, and fread()s etc. are performed directly to that data. This optimizes for minimal memory usage and fread() performance.
82
+ no_heap_copy = True
78
83
 
79
84
  for arg in sys.argv[1:]:
80
85
  if arg == '--preload':
@@ -91,15 +96,12 @@ for arg in sys.argv[1:]:
91
96
  in_compress = 1
92
97
  in_preload = False
93
98
  in_embed = False
94
- elif arg == '--pre-run':
95
- pre_run = True
96
- in_preload = False
97
- in_embed = False
98
- in_compress = 0
99
99
  elif arg == '--no-force':
100
100
  force = False
101
101
  elif arg == '--use-preload-cache':
102
102
  use_preload_cache = True
103
+ elif arg == '--no-heap-copy':
104
+ no_heap_copy = False
103
105
  elif arg.startswith('--js-output'):
104
106
  jsoutput = arg.split('=')[1] if '=' in arg else None
105
107
  elif arg.startswith('--crunch'):
@@ -141,6 +143,13 @@ if (not force) and len(data_files) == 0:
141
143
  has_preloaded = False
142
144
 
143
145
  ret = '''
146
+ var Module;
147
+ if (typeof Module === 'undefined') Module = eval('(function() { try { return Module || {} } catch(e) { return {} } })()');
148
+ if (!Module.expectedDataFileDownloads) {
149
+ Module.expectedDataFileDownloads = 0;
150
+ Module.finishedDataFileDownloads = 0;
151
+ }
152
+ Module.expectedDataFileDownloads++;
144
153
  (function() {
145
154
  '''
146
155
 
@@ -345,18 +354,9 @@ if has_preloaded:
345
354
  send: function() {},
346
355
  onload: function() {
347
356
  var byteArray = this.byteArray.subarray(this.start, this.end);
348
- if (this.crunched) {
349
- var ddsHeader = byteArray.subarray(0, 128);
350
- var that = this;
351
- requestDecrunch(this.name, byteArray.subarray(128), function(ddsData) {
352
- byteArray = new Uint8Array(ddsHeader.length + ddsData.length);
353
- byteArray.set(ddsHeader, 0);
354
- byteArray.set(ddsData, 128);
355
- that.finish(byteArray);
356
- });
357
- } else {
357
+ %s
358
358
  this.finish(byteArray);
359
- }
359
+ %s
360
360
  },
361
361
  finish: function(byteArray) {
362
362
  var that = this;
@@ -366,13 +366,26 @@ if has_preloaded:
366
366
  if (that.audio) {
367
367
  Module['removeRunDependency']('fp ' + that.name); // workaround for chromium bug 124926 (still no audio with this, but at least we don't hang)
368
368
  } else {
369
- Runtime.warn('Preloading file ' + that.name + ' failed');
369
+ Module.printErr('Preloading file ' + that.name + ' failed');
370
370
  }
371
371
  }, false, true); // canOwn this data in the filesystem, it is a slide into the heap that will never change
372
372
  this.requests[this.name] = null;
373
373
  },
374
374
  };
375
- '''
375
+ ''' % ('' if not crunch else '''
376
+ if (this.crunched) {
377
+ var ddsHeader = byteArray.subarray(0, 128);
378
+ var that = this;
379
+ requestDecrunch(this.name, byteArray.subarray(128), function(ddsData) {
380
+ byteArray = new Uint8Array(ddsHeader.length + ddsData.length);
381
+ byteArray.set(ddsHeader, 0);
382
+ byteArray.set(ddsData, 128);
383
+ that.finish(byteArray);
384
+ });
385
+ } else {
386
+ ''', '' if not crunch else '''
387
+ }
388
+ ''')
376
389
 
377
390
  counter = 0
378
391
  for file_ in data_files:
@@ -412,11 +425,17 @@ for file_ in data_files:
412
425
 
413
426
  if has_preloaded:
414
427
  # Get the big archive and split it up
415
- use_data = '''
428
+ if no_heap_copy:
429
+ use_data = '''
416
430
  // copy the entire loaded file into a spot in the heap. Files will refer to slices in that. They cannot be freed though.
417
431
  var ptr = Module['_malloc'](byteArray.length);
418
432
  Module['HEAPU8'].set(byteArray, ptr);
419
433
  DataRequest.prototype.byteArray = Module['HEAPU8'].subarray(ptr, ptr+byteArray.length);
434
+ '''
435
+ else:
436
+ use_data = '''
437
+ // Reuse the bytearray from the XHR as the source for file reads.
438
+ DataRequest.prototype.byteArray = byteArray;
420
439
  '''
421
440
  for file_ in data_files:
422
441
  if file_['mode'] == 'preload':
@@ -432,18 +451,19 @@ if has_preloaded:
432
451
  ''' % use_data
433
452
 
434
453
  package_uuid = uuid.uuid4();
454
+ remote_package_name = os.path.basename(Compression.compressed_name(data_target) if Compression.on else data_target)
435
455
  code += r'''
436
- if (!Module.expectedDataFileDownloads) {
437
- Module.expectedDataFileDownloads = 0;
438
- Module.finishedDataFileDownloads = 0;
456
+ var PACKAGE_PATH;
457
+ if (typeof window === 'object') {
458
+ PACKAGE_PATH = window['encodeURIComponent'](window.location.pathname.toString().substring(0, window.location.pathname.toString().lastIndexOf('/')) + '/');
459
+ } else {
460
+ // worker
461
+ PACKAGE_PATH = encodeURIComponent(location.pathname.toString().substring(0, location.pathname.toString().lastIndexOf('/')) + '/');
439
462
  }
440
- Module.expectedDataFileDownloads++;
441
-
442
- var PACKAGE_PATH = window['encodeURIComponent'](window.location.pathname.toString().substring(0, window.location.pathname.toString().lastIndexOf('/')) + '/');
443
463
  var PACKAGE_NAME = '%s';
444
464
  var REMOTE_PACKAGE_NAME = '%s';
445
465
  var PACKAGE_UUID = '%s';
446
- ''' % (data_target, os.path.basename(Compression.compressed_name(data_target) if Compression.on else data_target), package_uuid)
466
+ ''' % (data_target, remote_package_name, package_uuid)
447
467
 
448
468
  if use_preload_cache:
449
469
  code += r'''
@@ -536,7 +556,7 @@ if has_preloaded:
536
556
  };
537
557
  '''
538
558
 
539
- code += r'''
559
+ ret += r'''
540
560
  function fetchRemotePackage(packageName, callback, errback) {
541
561
  var xhr = new XMLHttpRequest();
542
562
  xhr.open('GET', packageName, true);
@@ -564,9 +584,9 @@ if has_preloaded:
564
584
  num++;
565
585
  }
566
586
  total = Math.ceil(total * Module.expectedDataFileDownloads/num);
567
- Module['setStatus']('Downloading data... (' + loaded + '/' + total + ')');
587
+ if (Module['setStatus']) Module['setStatus']('Downloading data... (' + loaded + '/' + total + ')');
568
588
  } else if (!Module.dataFileDownloads) {
569
- Module['setStatus']('Downloading data...');
589
+ if (Module['setStatus']) Module['setStatus']('Downloading data...');
570
590
  }
571
591
  };
572
592
  xhr.onload = function(event) {
@@ -576,6 +596,12 @@ if has_preloaded:
576
596
  xhr.send(null);
577
597
  };
578
598
 
599
+ function handleError(error) {
600
+ console.error('package error:', error);
601
+ };
602
+ '''
603
+
604
+ code += r'''
579
605
  function processPackageData(arrayBuffer) {
580
606
  Module.finishedDataFileDownloads++;
581
607
  assert(arrayBuffer, 'Loading data file failed.');
@@ -584,15 +610,10 @@ if has_preloaded:
584
610
  %s
585
611
  };
586
612
  Module['addRunDependency']('datafile_%s');
587
-
588
- function handleError(error) {
589
- console.error('package error:', error);
590
- };
591
613
  ''' % (use_data, data_target) # use basename because from the browser's point of view, we need to find the datafile in the same dir as the html file
592
614
 
593
615
  code += r'''
594
- if (!Module.preloadResults)
595
- Module.preloadResults = {};
616
+ if (!Module.preloadResults) Module.preloadResults = {};
596
617
  '''
597
618
 
598
619
  if use_preload_cache:
@@ -631,21 +652,43 @@ if has_preloaded:
631
652
  if (Module['setStatus']) Module['setStatus']('Downloading...');
632
653
  '''
633
654
  else:
655
+ # Not using preload cache, so we might as well start the xhr ASAP, potentially before JS parsing of the main codebase if it's after us.
656
+ # Only tricky bit is the fetch is async, but also when runWithFS is called is async, so we handle both orderings.
657
+ ret += r'''
658
+ var fetched = null, fetchedCallback = null;
659
+ fetchRemotePackage('%s', function(data) {
660
+ if (fetchedCallback) {
661
+ fetchedCallback(data);
662
+ fetchedCallback = null;
663
+ } else {
664
+ fetched = data;
665
+ }
666
+ }, handleError);
667
+ ''' % os.path.basename(Compression.compressed_name(data_target) if Compression.on else data_target)
668
+
634
669
  code += r'''
635
670
  Module.preloadResults[PACKAGE_NAME] = {fromCache: false};
636
- fetchRemotePackage(REMOTE_PACKAGE_NAME, processPackageData, handleError);
671
+ if (fetched) {
672
+ processPackageData(fetched);
673
+ fetched = null;
674
+ } else {
675
+ fetchedCallback = processPackageData;
676
+ }
637
677
  '''
638
678
 
639
- if pre_run:
640
- ret += '''
641
- if (typeof Module == 'undefined') Module = {};
642
- if (!Module['preRun']) Module['preRun'] = [];
643
- Module["preRun"].push(function() {
679
+ ret += '''
680
+ function runWithFS() {
644
681
  '''
645
682
  ret += code
646
-
647
- if pre_run:
648
- ret += ' });\n'
683
+ ret += '''
684
+ }
685
+ if (Module['calledRun']) {
686
+ runWithFS();
687
+ } else {
688
+ if (!Module['preRun']) Module['preRun'] = [];
689
+ Module["preRun"].push(runWithFS); // FS is not initialized yet, wait for it
690
+ }
691
+ '''
649
692
 
650
693
  if crunch:
651
694
  ret += '''