webruby 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/lib/webruby/environment.rb +4 -0
  3. data/lib/webruby/rake/files.rake +2 -1
  4. data/lib/webruby/rake/mruby.rake +4 -2
  5. data/modules/emscripten/AUTHORS +1 -0
  6. data/modules/emscripten/cmake/Platform/Emscripten.cmake +2 -0
  7. data/modules/emscripten/emcc +96 -40
  8. data/modules/emscripten/emrun +301 -136
  9. data/modules/emscripten/emscripten.py +5 -45
  10. data/modules/emscripten/src/analyzer.js +11 -1
  11. data/modules/emscripten/src/compiler.js +1 -1
  12. data/modules/emscripten/src/emrun_postjs.js +2 -2
  13. data/modules/emscripten/src/emrun_prejs.js +5 -0
  14. data/modules/emscripten/src/emscripten-source-map.min.js +31 -0
  15. data/modules/emscripten/src/library.js +187 -0
  16. data/modules/emscripten/src/library_egl.js +20 -0
  17. data/modules/emscripten/src/library_sdl.js +1 -0
  18. data/modules/emscripten/src/preamble.js +4 -0
  19. data/modules/emscripten/src/relooper/Relooper.cpp +33 -15
  20. data/modules/emscripten/src/relooper/Relooper.h +20 -14
  21. data/modules/emscripten/src/relooper/fuzzer.py +6 -0
  22. data/modules/emscripten/src/relooper/test.cpp +28 -0
  23. data/modules/emscripten/src/relooper/test.txt +211 -166
  24. data/modules/emscripten/src/relooper/test2.txt +20 -20
  25. data/modules/emscripten/src/relooper/test3.txt +41 -41
  26. data/modules/emscripten/src/relooper/test4.txt +26 -26
  27. data/modules/emscripten/src/relooper/test5.txt +52 -52
  28. data/modules/emscripten/src/relooper/test6.txt +19 -19
  29. data/modules/emscripten/src/relooper/test_dead.txt +1 -1
  30. data/modules/emscripten/src/relooper/test_debug.txt +31 -31
  31. data/modules/emscripten/src/relooper/test_fuzz1.txt +50 -50
  32. data/modules/emscripten/src/relooper/test_fuzz2.txt +21 -21
  33. data/modules/emscripten/src/relooper/test_fuzz3.txt +18 -18
  34. data/modules/emscripten/src/relooper/test_fuzz4.txt +28 -28
  35. data/modules/emscripten/src/relooper/test_fuzz5.txt +61 -61
  36. data/modules/emscripten/src/relooper/test_fuzz6.txt +179 -179
  37. data/modules/emscripten/src/relooper/test_inf.txt +846 -846
  38. data/modules/emscripten/src/relooper/testit.sh +15 -15
  39. data/modules/emscripten/system/include/emscripten/emscripten.h +64 -0
  40. data/modules/emscripten/tools/eliminator/asm-eliminator-test-output.js +8 -2
  41. data/modules/emscripten/tools/eliminator/asm-eliminator-test.js +9 -1
  42. data/modules/emscripten/tools/eliminator/eliminator-test-output.js +11 -0
  43. data/modules/emscripten/tools/eliminator/eliminator-test.js +16 -1
  44. data/modules/emscripten/tools/file_packager.py +59 -49
  45. data/modules/emscripten/tools/js-optimizer.js +47 -8
  46. data/modules/emscripten/tools/shared.py +3 -3
  47. data/modules/emscripten/tools/test-js-optimizer-asm-pre-output.js +5 -3
  48. data/modules/emscripten/tools/test-js-optimizer-asm-pre.js +4 -0
  49. data/modules/mruby/INSTALL +11 -6
  50. data/modules/mruby/include/mrbconf.h +0 -3
  51. data/modules/mruby/include/mruby/khash.h +34 -36
  52. data/modules/mruby/include/mruby/string.h +3 -0
  53. data/modules/mruby/include/mruby.h +3 -3
  54. data/modules/mruby/mrblib/string.rb +3 -0
  55. data/modules/mruby/src/class.c +12 -12
  56. data/modules/mruby/src/codegen.c +18 -11
  57. data/modules/mruby/src/hash.c +12 -12
  58. data/modules/mruby/src/kernel.c +3 -3
  59. data/modules/mruby/src/load.c +29 -14
  60. data/modules/mruby/src/numeric.c +1 -1
  61. data/modules/mruby/src/object.c +14 -2
  62. data/modules/mruby/src/state.c +13 -10
  63. data/modules/mruby/src/string.c +1 -3
  64. data/modules/mruby/src/symbol.c +44 -18
  65. data/modules/mruby/src/variable.c +6 -6
  66. data/modules/mruby/test/t/class.rb +34 -0
  67. data/modules/mruby/test/t/module.rb +1 -1
  68. data/modules/mruby/test/t/syntax.rb +28 -0
  69. metadata +5 -13
  70. data/modules/emscripten/src/relooper.js +0 -11516
  71. data/modules/emscripten/src/relooper.js.raw.js +0 -11511
  72. data/modules/emscripten/tools/__init__.pyc +0 -0
  73. data/modules/emscripten/tools/cache.pyc +0 -0
  74. data/modules/emscripten/tools/gen_struct_info.pyc +0 -0
  75. data/modules/emscripten/tools/js_optimizer.pyc +0 -0
  76. data/modules/emscripten/tools/jsrun.pyc +0 -0
  77. data/modules/emscripten/tools/response_file.pyc +0 -0
  78. data/modules/emscripten/tools/shared.pyc +0 -0
  79. data/modules/emscripten/tools/tempfiles.pyc +0 -0
@@ -2,61 +2,61 @@
2
2
 
3
3
  echo "test"
4
4
  ./test &> test.out
5
- diff -U 5 test.txt test.out
5
+ diff -w -U 5 test.txt test.out
6
6
 
7
7
  echo "test 2"
8
8
  ./test2 &> test2.out
9
- diff -U 5 test2.txt test2.out
9
+ diff -w -U 5 test2.txt test2.out
10
10
 
11
11
  echo "test 3"
12
12
  ./test3 &> test3.out
13
- diff -U 5 test3.txt test3.out
13
+ diff -w -U 5 test3.txt test3.out
14
14
 
15
15
  echo "test debug"
16
16
  ./test_debug &> test_debug.out
17
- diff -U 5 test_debug.txt test_debug.out
17
+ diff -w -U 5 test_debug.txt test_debug.out
18
18
 
19
19
  echo "test dead"
20
20
  ./test_dead &> test_dead.out
21
- diff -U 5 test_dead.txt test_dead.out
21
+ diff -w -U 5 test_dead.txt test_dead.out
22
22
 
23
23
  echo "test 4"
24
24
  ./test4 &> test4.out
25
- diff -U 5 test4.txt test4.out
25
+ diff -w -U 5 test4.txt test4.out
26
26
 
27
27
  echo "test 5"
28
28
  ./test5 &> test5.out
29
- diff -U 5 test5.txt test5.out
29
+ diff -w -U 5 test5.txt test5.out
30
30
 
31
31
  echo "test 6"
32
32
  ./test6 &> test6.out
33
- diff -U 5 test6.txt test6.out
33
+ diff -w -U 5 test6.txt test6.out
34
34
 
35
35
  echo "test inf"
36
36
  ./test_inf &> test_inf.out
37
- diff -U 5 test_inf.txt test_inf.out
37
+ diff -w -U 5 test_inf.txt test_inf.out
38
38
 
39
39
  echo "test fuzz1"
40
40
  ./test_fuzz1 &> test_fuzz1.out
41
- diff -U 5 test_fuzz1.txt test_fuzz1.out
41
+ diff -w -U 5 test_fuzz1.txt test_fuzz1.out
42
42
 
43
43
  echo "test fuzz2"
44
44
  ./test_fuzz2 &> test_fuzz2.out
45
- diff -U 5 test_fuzz2.txt test_fuzz2.out
45
+ diff -w -U 5 test_fuzz2.txt test_fuzz2.out
46
46
 
47
47
  echo "test fuzz3"
48
48
  ./test_fuzz3 &> test_fuzz3.out
49
- diff -U 5 test_fuzz3.txt test_fuzz3.out
49
+ diff -w -U 5 test_fuzz3.txt test_fuzz3.out
50
50
 
51
51
  echo "test fuzz4"
52
52
  ./test_fuzz4 &> test_fuzz4.out
53
- diff -U 5 test_fuzz4.txt test_fuzz4.out
53
+ diff -w -U 5 test_fuzz4.txt test_fuzz4.out
54
54
 
55
55
  echo "test fuzz5"
56
56
  ./test_fuzz5 &> test_fuzz5.out
57
- diff -U 5 test_fuzz5.txt test_fuzz5.out
57
+ diff -w -U 5 test_fuzz5.txt test_fuzz5.out
58
58
 
59
59
  echo "test fuzz6"
60
60
  ./test_fuzz6 &> test_fuzz6.out
61
- diff -U 5 test_fuzz6.txt test_fuzz6.out
61
+ diff -w -U 5 test_fuzz6.txt test_fuzz6.out
62
62
 
@@ -447,6 +447,70 @@ void emscripten_asm_const(const char *code);
447
447
  int emscripten_asm_const_int(const char *code, ...);
448
448
  double emscripten_asm_const_double(const char *code, ...);
449
449
 
450
+ /* If specified, logs directly to the browser console/inspector
451
+ * window. If not specified, logs via the application Module. */
452
+ #define EM_LOG_CONSOLE 1
453
+ /* If specified, prints a warning message. */
454
+ #define EM_LOG_WARN 2
455
+ /* If specified, prints an error message. If neither EM_LOG_WARN
456
+ * or EM_LOG_ERROR is specified, an info message is printed.
457
+ * EM_LOG_WARN and EM_LOG_ERROR are mutually exclusive. */
458
+ #define EM_LOG_ERROR 4
459
+ /* If specified, prints a callstack that contains filenames referring
460
+ * to original C sources using source map information. */
461
+ #define EM_LOG_C_STACK 8
462
+ /* If specified, prints a callstack that contains filenames referring
463
+ * to lines to the built .js/.html file along with the message. The
464
+ * flags EM_LOG_C_STACK and EM_LOG_JS_STACK can be combined to output
465
+ * both untranslated and translated file+line information. */
466
+ #define EM_LOG_JS_STACK 16
467
+ /* If specified, C/C++ function names are demangled before printing.
468
+ * Otherwise, the mangled post-compilation JS function names are
469
+ * displayed. */
470
+ #define EM_LOG_DEMANGLE 32
471
+ /* If specified, the pathnames of the file information in the call
472
+ * stack will be omitted. */
473
+ #define EM_LOG_NO_PATHS 64
474
+ /* If specified, prints out the actual values of the parameters the
475
+ * functions were invoked with. */
476
+ #define EM_LOG_FUNC_PARAMS 128
477
+
478
+ /*
479
+ * Prints out a message to the console, optionally with the
480
+ * callstack information.
481
+ * @param flags A binary OR of items from the list of EM_LOG_xxx
482
+ * flags that specify printing options.
483
+ * @param '...' A printf-style "format, ..." parameter list that
484
+ * is parsed according to the printf formatting rules.
485
+ */
486
+ void emscripten_log(int flags, ...);
487
+
488
+ /*
489
+ * Programmatically obtains the current callstack.
490
+ * @param flags A binary OR of items from the list of EM_LOG_xxx
491
+ * flags that specify printing options. The
492
+ * items EM_LOG_CONSOLE, EM_LOG_WARN and
493
+ * EM_LOG_ERROR do not apply in this function and
494
+ * are ignored.
495
+ * @param out A pointer to a memory region where the callstack
496
+ * string will be written to. The string outputted
497
+ * by this function will always be null-terminated.
498
+ * @param maxbytes The maximum number of bytes that this function can
499
+ * write to the memory pointed to by 'out'. If
500
+ * there is no enough space, the output will be
501
+ * truncated (but always null-terminated).
502
+ * @return Returns the number of bytes written. (not number of
503
+ * characters, so this will also include the terminating zero)
504
+
505
+ * To query the amount of bytes needed for a callstack without writing
506
+ * it, pass 0 to 'out' and 'maxbytes', in which case the function will
507
+ * return the number of bytes (including the terminating zero) that
508
+ * will be needed to hold the full callstack. Note that this might be
509
+ * fully accurate since subsequent calls will carry different line
510
+ * numbers, so it is best to allocate a few bytes extra to be safe.
511
+ */
512
+ int emscripten_get_callstack(int flags, char *out, int maxbytes);
513
+
450
514
  #ifdef __cplusplus
451
515
  }
452
516
  #endif
@@ -280,9 +280,10 @@ function tempDouble2($46, $14, $28, $42, $20, $32, $45) {
280
280
  $20 = $20 | 0;
281
281
  $32 = $32 | 0;
282
282
  $45 = $45 | 0;
283
- var $_sroa_06_0_insert_insert$1 = 0;
283
+ var $46 = 0, $_sroa_06_0_insert_insert$1 = 0;
284
+ $46 = (HEAPF32[tempDoublePtr >> 2] = ($14 < $28 ? $14 : $28) - $42, HEAP32[tempDoublePtr >> 2] | 0);
284
285
  $_sroa_06_0_insert_insert$1 = (HEAPF32[tempDoublePtr >> 2] = ($20 < $32 ? $20 : $32) - $42, HEAP32[tempDoublePtr >> 2] | 0) | 0;
285
- HEAP32[$45 >> 2] = 0 | (HEAPF32[tempDoublePtr >> 2] = ($14 < $28 ? $14 : $28) - $42, HEAP32[tempDoublePtr >> 2] | 0);
286
+ HEAP32[$45 >> 2] = 0 | $46;
286
287
  HEAP32[$45 + 4 >> 2] = $_sroa_06_0_insert_insert$1;
287
288
  HEAP32[$45 + 8 >> 2] = $_sroa_06_0_insert_insert$1;
288
289
  }
@@ -298,4 +299,9 @@ function select2($foundBase_0_off0) {
298
299
  STACKTOP = sp;
299
300
  return ($foundBase_0_off0 ? 0 : $call24) | 0;
300
301
  }
302
+ function binary(x) {
303
+ x = x | 0;
304
+ memset(f(x)) | 0;
305
+ +dmemset(f(x));
306
+ }
301
307
 
@@ -370,5 +370,13 @@ function select2($foundBase_0_off0) {
370
370
  STACKTOP = sp;
371
371
  return $retval_0 | 0;
372
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"]
373
+ function binary(x) {
374
+ x = x | 0;
375
+ var y = 0, z = 0;
376
+ y = f(x);
377
+ memset(y) | 0;
378
+ z = f(x);
379
+ +dmemset(z);
380
+ }
381
+ // 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", "binary"]
374
382
 
@@ -6122,4 +6122,15 @@ function intoCond() {
6122
6122
  function math(a, b, c, d) {
6123
6123
  print(Math_imul(d) + (Math_fround(c) + (a + Math_abs(b))));
6124
6124
  }
6125
+ function td(x, y) {
6126
+ HEAP32[tempDoublePtr >> 2] = x;
6127
+ var xf = HEAPF32[tempDoublePtr >> 2];
6128
+ HEAP32[tempDoublePtr >> 2] = y;
6129
+ func(xf, HEAPF32[tempDoublePtr >> 2]);
6130
+ HEAPF64[tempDoublePtr >> 3] = x;
6131
+ var xl = HEAP32[tempDoublePtr >> 2];
6132
+ var xh = HEAP32[tempDoublePtr >> 2];
6133
+ HEAPF64[tempDoublePtr >> 3] = y;
6134
+ func(xl, xh, HEAP32[tempDoublePtr >> 2], HEAP32[tempDoublePtr >> 2]);
6135
+ }
6125
6136
 
@@ -8860,5 +8860,20 @@ function math(a, b, c, d) {
8860
8860
  w = Math_imul(d);
8861
8861
  print(x + y + z + w);
8862
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"]
8863
+ function td(x, y) { // tempDoublePtr should invalidate each other
8864
+ HEAP32[tempDoublePtr>>2] = x;
8865
+ var xf = HEAPF32[tempDoublePtr>>2];
8866
+ HEAP32[tempDoublePtr>>2] = y;
8867
+ var yf = HEAPF32[tempDoublePtr>>2];
8868
+ func(xf, yf);
8869
+ //
8870
+ HEAPF64[tempDoublePtr>>3] = x;
8871
+ var xl = HEAP32[tempDoublePtr>>2];
8872
+ var xh = HEAP32[tempDoublePtr>>2];
8873
+ HEAPF64[tempDoublePtr>>3] = y;
8874
+ var yl = HEAP32[tempDoublePtr>>2];
8875
+ var yh = HEAP32[tempDoublePtr>>2];
8876
+ func(xl, xh, yl, yh);
8877
+ }
8878
+ // EMSCRIPTEN_GENERATED_FUNCTIONS: ["a", "b", "c", "f", "g", "h", "py", "r", "t", "f2", "f3", "llvm3_1", "_inflate", "_malloc", "_mallocNoU", "asm", "phi", "intoCond", "math", "td"]
8864
8879
 
@@ -11,7 +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] [--crunch[=X]] [--js-output=OUTPUT.js] [--no-force] [--use-preload-cache] [--no-heap-copy]
14
+ file_packager.py TARGET [--preload A [B..]] [--embed C [D..]] [--exclude E [F..]] [--compress COMPRESSION_DATA] [--crunch[=X]] [--js-output=OUTPUT.js] [--no-force] [--use-preload-cache] [--no-heap-copy]
15
15
 
16
16
  --crunch=X Will compress dxt files to crn with quality level X. The crunch commandline tool must be present
17
17
  and CRUNCH should be defined in ~/.emscripten that points to it. JS crunch decompressing code will
@@ -45,9 +45,10 @@ import posixpath
45
45
  import shared
46
46
  from shared import Compression, execute, suffix, unsuffixed
47
47
  from subprocess import Popen, PIPE, STDOUT
48
+ import fnmatch
48
49
 
49
50
  if len(sys.argv) == 1:
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]
51
+ print '''Usage: file_packager.py TARGET [--preload A...] [--embed B...] [--exclude C...] [--compress COMPRESSION_DATA] [--crunch[=X]] [--js-output=OUTPUT.js] [--no-force] [--use-preload-cache] [--no-heap-copy]
51
52
  See the source for more details.'''
52
53
  sys.exit(0)
53
54
 
@@ -66,10 +67,10 @@ DDS_HEADER_SIZE = 128
66
67
  AV_WORKAROUND = 0 # Set to 1 to randomize file order and add some padding, to work around silly av false positives
67
68
 
68
69
  data_files = []
69
- in_preload = False
70
- in_embed = False
70
+ excluded_patterns = []
71
+ leading = ''
71
72
  has_preloaded = False
72
- in_compress = 0
73
+ compress_cnt = 0
73
74
  crunch = 0
74
75
  plugins = []
75
76
  jsoutput = None
@@ -81,45 +82,40 @@ use_preload_cache = False
81
82
  # 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
83
  no_heap_copy = True
83
84
 
84
- for arg in sys.argv[1:]:
85
+ for arg in sys.argv[2:]:
85
86
  if arg == '--preload':
86
- in_preload = True
87
- in_embed = False
88
87
  has_preloaded = True
89
- in_compress = 0
88
+ leading = 'preload'
90
89
  elif arg == '--embed':
91
- in_embed = True
92
- in_preload = False
93
- in_compress = 0
90
+ leading = 'embed'
91
+ elif arg == '--exclude':
92
+ leading = 'exclude'
94
93
  elif arg == '--compress':
94
+ compress_cnt = 1
95
95
  Compression.on = True
96
- in_compress = 1
97
- in_preload = False
98
- in_embed = False
96
+ leading = 'compress'
99
97
  elif arg == '--no-force':
100
98
  force = False
99
+ leading = ''
101
100
  elif arg == '--use-preload-cache':
102
101
  use_preload_cache = True
102
+ leading = ''
103
103
  elif arg == '--no-heap-copy':
104
104
  no_heap_copy = False
105
+ leading = ''
105
106
  elif arg.startswith('--js-output'):
106
107
  jsoutput = arg.split('=')[1] if '=' in arg else None
108
+ leading = ''
107
109
  elif arg.startswith('--crunch'):
108
110
  from shared import CRUNCH
109
111
  crunch = arg.split('=')[1] if '=' in arg else '128'
110
- in_preload = False
111
- in_embed = False
112
- in_compress = 0
112
+ leading = ''
113
113
  elif arg.startswith('--plugin'):
114
114
  plugin = open(arg.split('=')[1], 'r').read()
115
115
  eval(plugin) # should append itself to plugins
116
- in_preload = False
117
- in_embed = False
118
- in_compress = 0
119
- elif in_preload or in_embed:
120
- mode = 'preload'
121
- if in_embed:
122
- mode = 'embed'
116
+ leading = ''
117
+ elif leading == 'preload' or leading == 'embed':
118
+ mode = leading
123
119
  if '@' in arg:
124
120
  srcpath, dstpath = arg.split('@') # User is specifying destination filename explicitly.
125
121
  else:
@@ -128,16 +124,21 @@ for arg in sys.argv[1:]:
128
124
  data_files.append({ 'srcpath': srcpath, 'dstpath': dstpath, 'mode': mode })
129
125
  else:
130
126
  print >> sys.stderr, 'Warning: ' + arg + ' does not exist, ignoring.'
131
- elif in_compress:
132
- if in_compress == 1:
127
+ elif leading == 'exclude':
128
+ excluded_patterns.append(arg)
129
+ elif leading == 'compress':
130
+ if compress_cnt == 1:
133
131
  Compression.encoder = arg
134
- in_compress = 2
135
- elif in_compress == 2:
132
+ compress_cnt = 2
133
+ elif compress_cnt == 2:
136
134
  Compression.decoder = arg
137
- in_compress = 3
138
- elif in_compress == 3:
135
+ compress_cnt = 3
136
+ elif compress_cnt == 3:
139
137
  Compression.js_name = arg
140
- in_compress = 0
138
+ compress_cnt = 0
139
+ else:
140
+ print >> sys.stderr, 'Unknown parameter:', arg
141
+ sys.exit(1)
141
142
 
142
143
  if (not force) and len(data_files) == 0:
143
144
  has_preloaded = False
@@ -172,16 +173,14 @@ def has_hidden_attribute(filepath):
172
173
  result = False
173
174
  return result
174
175
 
175
- # The packager should never preload/embed any directories that have a component starting with '.' in them,
176
- # or if the file is hidden (Win32). Note that this filter ONLY applies to directories. Explicitly specified single files
177
- # are always preloaded/embedded, even if they start with a '.'.
178
- def should_ignore(filename):
179
- if has_hidden_attribute(filename):
176
+ # The packager should never preload/embed files if the file is hidden (Win32).
177
+ # or it matches any pattern specified in --exclude
178
+ def should_ignore(fullname):
179
+ if has_hidden_attribute(fullname):
180
180
  return True
181
181
 
182
- components = filename.replace('\\\\', '/').replace('\\', '/').split('/')
183
- for c in components:
184
- if c.startswith('.') and c != '.' and c != '..':
182
+ for p in excluded_patterns:
183
+ if fnmatch.fnmatch(fullname, p):
185
184
  return True
186
185
  return False
187
186
 
@@ -190,20 +189,31 @@ def add(arg, dirname, names):
190
189
  # rootpathsrc: The path name of the root directory on the local FS we are adding to emscripten virtual FS.
191
190
  # rootpathdst: The name we want to make the source path available on the emscripten virtual FS.
192
191
  mode, rootpathsrc, rootpathdst = arg
192
+ new_names = []
193
193
  for name in names:
194
194
  fullname = os.path.join(dirname, name)
195
- if not os.path.isdir(fullname):
196
- if should_ignore(fullname):
197
- if DEBUG:
198
- print >> sys.stderr, 'Skipping hidden file "' + fullname + '" from inclusion in the emscripten virtual file system.'
199
- else:
195
+ if should_ignore(fullname):
196
+ if DEBUG:
197
+ print >> sys.stderr, 'Skipping file "' + fullname + '" from inclusion in the emscripten virtual file system.'
198
+ else:
199
+ new_names.append(name)
200
+ if not os.path.isdir(fullname):
200
201
  dstpath = os.path.join(rootpathdst, os.path.relpath(fullname, rootpathsrc)) # Convert source filename relative to root directory of target FS.
201
- data_files.append({ 'srcpath': fullname, 'dstpath': dstpath, 'mode': mode })
202
+ new_data_files.append({ 'srcpath': fullname, 'dstpath': dstpath, 'mode': mode })
203
+ del names[:]
204
+ names.extend(new_names)
202
205
 
206
+ new_data_files = []
203
207
  for file_ in data_files:
204
- if os.path.isdir(file_['srcpath']):
205
- os.path.walk(file_['srcpath'], add, [file_['mode'], file_['srcpath'], file_['dstpath']])
206
- data_files = filter(lambda file_: not os.path.isdir(file_['srcpath']), data_files)
208
+ if not should_ignore(file_['srcpath']):
209
+ if os.path.isdir(file_['srcpath']):
210
+ os.path.walk(file_['srcpath'], add, [file_['mode'], file_['srcpath'], file_['dstpath']])
211
+ else:
212
+ new_data_files.append(file_)
213
+ data_files = filter(lambda file_: not os.path.isdir(file_['srcpath']), new_data_files)
214
+ if len(data_files) == 0:
215
+ print >> sys.stderr, 'Nothing to do!'
216
+ sys.exit(1)
207
217
 
208
218
  # Absolutize paths, and check that they make sense
209
219
  curr_abspath = os.path.abspath(os.getcwd())
@@ -271,6 +271,16 @@ function isEmptyNode(node) {
271
271
  return node.length === 2 && node[0] === 'toplevel' && node[1].length === 0;
272
272
  }
273
273
 
274
+ function clearEmptyNodes(list) {
275
+ for (var i = 0; i < list.length;) {
276
+ if (isEmptyNode(list[i]) || (list[i][0] === 'stat' && isEmptyNode(list[i][1]))) {
277
+ list.splice(i, 1);
278
+ } else {
279
+ i++;
280
+ }
281
+ }
282
+ }
283
+
274
284
  // Passes
275
285
 
276
286
  // Dump the AST. Useful for debugging. For example,
@@ -585,12 +595,24 @@ function simplifyExpressions(ast) {
585
595
  }
586
596
  } else if (type === 'assign') {
587
597
  // optimizations for assigning into HEAP32 specifically
588
- if (node[1] === true && node[2][0] === 'sub' && node[2][1][0] === 'name' && node[2][1][1] === 'HEAP32') {
589
- // HEAP32[..] = x | 0 does not need the | 0 (unless it is a mandatory |0 of a call)
590
- if (node[3][0] === 'binary' && node[3][1] === '|') {
591
- if (node[3][2][0] === 'num' && node[3][2][1] === 0 && node[3][3][0] != 'call') {
592
- node[3] = node[3][3];
593
- } else if (node[3][3][0] === 'num' && node[3][3][1] === 0 && node[3][2][0] != 'call') {
598
+ if (node[1] === true && node[2][0] === 'sub' && node[2][1][0] === 'name') {
599
+ if (node[2][1][1] === 'HEAP32') {
600
+ // HEAP32[..] = x | 0 does not need the | 0 (unless it is a mandatory |0 of a call)
601
+ if (node[3][0] === 'binary' && node[3][1] === '|') {
602
+ if (node[3][2][0] === 'num' && node[3][2][1] === 0 && node[3][3][0] != 'call') {
603
+ node[3] = node[3][3];
604
+ } else if (node[3][3][0] === 'num' && node[3][3][1] === 0 && node[3][2][0] != 'call') {
605
+ node[3] = node[3][2];
606
+ }
607
+ }
608
+ } else if (node[2][1][1] === 'HEAP8') {
609
+ // HEAP8[..] = x & 0xff does not need the & 0xff
610
+ if (node[3][0] === 'binary' && node[3][1] === '&' && node[3][3][0] == 'num' && node[3][3][1] == 0xff) {
611
+ node[3] = node[3][2];
612
+ }
613
+ } else if (node[2][1][1] === 'HEAP16') {
614
+ // HEAP16[..] = x & 0xffff does not need the & 0xffff
615
+ if (node[3][0] === 'binary' && node[3][1] === '&' && node[3][3][0] == 'num' && node[3][3][1] == 0xffff) {
594
616
  node[3] = node[3][2];
595
617
  }
596
618
  }
@@ -2122,7 +2144,7 @@ function registerize(ast) {
2122
2144
  // In memSafe mode, we are more careful and assume functions can replace HEAP and FUNCTION_TABLE, which
2123
2145
  // can happen in ALLOW_MEMORY_GROWTH mode
2124
2146
 
2125
- var ELIMINATION_SAFE_NODES = set('var', 'assign', 'call', 'if', 'toplevel', 'do', 'return', 'label', 'switch'); // do is checked carefully, however
2147
+ var ELIMINATION_SAFE_NODES = set('var', 'assign', 'call', 'if', 'toplevel', 'do', 'return', 'label', 'switch', 'binary', 'unary-prefix'); // do is checked carefully, however
2126
2148
  var IGNORABLE_ELIMINATOR_SCAN_NODES = set('num', 'toplevel', 'string', 'break', 'continue', 'dot'); // dot can only be STRING_TABLE.*
2127
2149
  var ABORTING_ELIMINATOR_SCAN_NODES = set('new', 'object', 'function', 'defun', 'for', 'while', 'array', 'throw'); // we could handle some of these, TODO, but nontrivial (e.g. for while, the condition is hit multiple times after the body)
2128
2150
 
@@ -2412,7 +2434,12 @@ function eliminate(ast, memSafe) {
2412
2434
  if (allowTracking) track(name, node[3], node);
2413
2435
  }
2414
2436
  } else if (target[0] === 'sub') {
2415
- if (!isTempDoublePtrAccess(target) && !memoryInvalidated) {
2437
+ if (isTempDoublePtrAccess(target)) {
2438
+ if (!globalsInvalidated) {
2439
+ invalidateGlobals();
2440
+ globalsInvalidated = true;
2441
+ }
2442
+ } else if (!memoryInvalidated) {
2416
2443
  invalidateMemory();
2417
2444
  memoryInvalidated = true;
2418
2445
  }
@@ -2672,6 +2699,7 @@ function eliminate(ast, memSafe) {
2672
2699
  }
2673
2700
  if (ifTrue[1][0] && ifTrue[1][0][0] === 'break') {
2674
2701
  var assigns = ifFalse[1];
2702
+ clearEmptyNodes(assigns);
2675
2703
  var loopers = [], helpers = [];
2676
2704
  for (var i = 0; i < assigns.length; i++) {
2677
2705
  if (assigns[i][0] === 'stat' && assigns[i][1][0] === 'assign') {
@@ -3097,6 +3125,17 @@ function outline(ast) {
3097
3125
  parts = [];
3098
3126
  var curr = node;
3099
3127
  while (1) {
3128
+ if (!curr[3]) {
3129
+ // we normally expect ..if (cond) { .. } else [if (nextCond) {] (in [] is what we hope to see)
3130
+ // but are now seeing ..if (cond) { .. } with no else. This might be
3131
+ // ..if (cond) if (nextCond) {
3132
+ // which vacuum can generate from if (cond) {} else if (nextCond), making it
3133
+ // if (!cond) if (nextCond)
3134
+ // so we undo that, in hopes of making it more flattenable
3135
+ curr[3] = curr[2];
3136
+ curr[2] = ['block', []];
3137
+ curr[1] = simplifyNotCompsDirect(['unary-prefix', '!', curr[1]]);
3138
+ }
3100
3139
  parts.push({ condition: curr[1], body: curr[2] });
3101
3140
  curr = curr[3];
3102
3141
  if (!curr) break;
@@ -322,7 +322,7 @@ def find_temp_directory():
322
322
  # we re-check sanity when the settings are changed)
323
323
  # We also re-check sanity and clear the cache when the version changes
324
324
 
325
- EMSCRIPTEN_VERSION = '1.7.8'
325
+ EMSCRIPTEN_VERSION = '1.8.0'
326
326
 
327
327
  def generate_sanity():
328
328
  return EMSCRIPTEN_VERSION + '|' + get_llvm_target() + '|' + LLVM_ROOT
@@ -682,7 +682,7 @@ def line_splitter(data):
682
682
 
683
683
  return out
684
684
 
685
- def limit_size(string, MAX=12000*20):
685
+ def limit_size(string, MAX=800*20):
686
686
  if len(string) < MAX: return string
687
687
  return string[0:MAX/2] + '\n[..]\n' + string[-MAX/2:]
688
688
 
@@ -1094,7 +1094,7 @@ class Building:
1094
1094
  # 8k is a bit of an arbitrary limit, but a reasonable one
1095
1095
  # for max command line size before we use a respose file
1096
1096
  response_file = None
1097
- if WINDOWS and len(' '.join(link_cmd)) > 8192:
1097
+ if len(' '.join(link_cmd)) > 8192:
1098
1098
  logging.debug('using response file for llvm-link')
1099
1099
  [response_fd, response_file] = mkstemp(suffix='.response', dir=TEMP_DIR)
1100
1100
 
@@ -58,12 +58,14 @@ function b($this, $__n) {
58
58
  _memset($38 + $23 | 0, 0, $__n | 0, 1, 1213141516);
59
59
  $40 = $23 + $__n | 0;
60
60
  if ((HEAP8[$4 & 16777215] & 1) == 0) {
61
- HEAP8[$4 & 16777215] = $40 << 1 & 255;
61
+ HEAP8[$4 & 16777215] = $40 << 1;
62
62
  } else {
63
63
  HEAP32[($this + 4 & 16777215) >> 2] = $40;
64
64
  }
65
65
  HEAP8[$38 + $40 & 16777215] = 0;
66
66
  HEAP32[$4] = ~HEAP32[$5];
67
+ HEAP8[$4] = HEAP32[$5];
68
+ HEAP16[$4] = HEAP32[$5];
67
69
  HEAP32[$4] = ~HEAP32[$5];
68
70
  HEAP32[$4] = ~HEAP32[$5];
69
71
  h(~~g ^ -1);
@@ -240,10 +242,10 @@ function _main($argc, $argv) {
240
242
  }
241
243
  if (($i_09_i_i | 0) > (HEAP32[9600 + ($j_08_i_i << 2) >> 2] | 0)) {
242
244
  $34 = $j_08_i_i + 1 | 0;
243
- HEAP8[$i_09_i_i + 8952 | 0] = $34 & 255;
245
+ HEAP8[$i_09_i_i + 8952 | 0] = $34;
244
246
  $j_1_i_i = $34;
245
247
  } else {
246
- HEAP8[$i_09_i_i + 8952 | 0] = $j_08_i_i & 255;
248
+ HEAP8[$i_09_i_i + 8952 | 0] = $j_08_i_i;
247
249
  $j_1_i_i = $j_08_i_i;
248
250
  }
249
251
  $38 = $i_09_i_i + 1 | 0;
@@ -66,6 +66,10 @@ function b($this, $__n) {
66
66
  HEAP8[($38 + $40 | 0) & 16777215] = 0;
67
67
  // Eliminate the |0.
68
68
  HEAP32[$4] = ((~(HEAP32[$5]|0))|0);
69
+ // Eliminate the &255
70
+ HEAP8[$4] = HEAP32[$5]&255;
71
+ // Eliminate the &65535
72
+ HEAP16[$4] = HEAP32[$5]&65535;
69
73
  // Rewrite to ~.
70
74
  HEAP32[$4] = HEAP32[$5]^-1;
71
75
  // Rewrite to ~ and eliminate the |0.
@@ -7,14 +7,19 @@
7
7
 
8
8
  1. Run make in the top directory.
9
9
 
10
- This command will create the following directories and
11
- store libraries and binaries files into them.
10
+ This command will create a build directory with a directory for the host environment
11
+ and one for each crossbuild environment based on the settings in the build_config.rb
12
+ file.
12
13
 
13
- * bin
14
- * lib
15
- * include
14
+ Assuming a default build, each of the environment directories will have the following
15
+ important directories:
16
16
 
17
- You can directory invoke 'minirake' as the following.
17
+ * bin - The binary executables for this environment
18
+ * lib - The libraries for this environment
19
+
20
+ You can find the header files in the include directory at the root of the project.
21
+
22
+ You can directory invoke 'minirake' as the following.
18
23
 
19
24
  $ ruby ./minirake
20
25
 
@@ -38,9 +38,6 @@
38
38
  /* initial size for IV khash; ignored when MRB_USE_IV_SEGLIST is set */
39
39
  //#define MRB_IVHASH_INIT_SIZE 8
40
40
 
41
- /* initial size for IREP array */
42
- //#define MRB_IREP_ARRAY_INIT_SIZE (256u)
43
-
44
41
  /* turn off generational GC by default */
45
42
  //#define MRB_GC_TURN_OFF_GENERATIONAL
46
43