webruby 0.1.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/driver/driver.c +12 -0
- data/lib/webruby/config.rb +3 -3
- data/lib/webruby/environment.rb +1 -0
- data/lib/webruby/rake/files.rake +22 -22
- data/lib/webruby/rake/general.rake +0 -1
- data/lib/webruby/utility.rb +2 -0
- data/modules/emscripten/AUTHORS +12 -1
- data/modules/emscripten/cmake/Platform/Emscripten.cmake +152 -15
- data/modules/emscripten/em++ +2 -0
- data/modules/emscripten/em++.bat +1 -1
- data/modules/emscripten/em-config.bat +1 -1
- data/modules/emscripten/emar.bat +1 -1
- data/modules/emscripten/emcc +233 -95
- data/modules/emscripten/emcc.bat +1 -1
- data/modules/emscripten/emconfigure.bat +1 -1
- data/modules/emscripten/emmake.bat +1 -1
- data/modules/emscripten/emranlib.bat +1 -1
- data/modules/emscripten/emscripten.py +221 -217
- data/modules/emscripten/package.json +7 -0
- data/modules/emscripten/src/analyzer.js +1437 -1385
- data/modules/emscripten/src/compiler.js +30 -6
- data/modules/emscripten/src/compiler_phase.html +33 -0
- data/modules/emscripten/src/fastLong.js +6 -6
- data/modules/emscripten/src/headless.js +47 -656
- data/modules/emscripten/src/headlessCanvas.js +618 -0
- data/modules/emscripten/src/intertyper.js +1038 -899
- data/modules/emscripten/src/jsifier.js +818 -714
- data/modules/emscripten/src/library.js +1794 -2968
- data/modules/emscripten/src/library_browser.js +81 -16
- data/modules/emscripten/src/library_egl.js +9 -3
- data/modules/emscripten/src/library_fs.js +1585 -0
- data/modules/emscripten/src/library_gl.js +445 -202
- data/modules/emscripten/src/library_glfw.js +4 -1
- data/modules/emscripten/src/library_glut.js +61 -13
- data/modules/emscripten/src/library_idbfs.js +216 -0
- data/modules/emscripten/src/library_memfs.js +279 -0
- data/modules/emscripten/src/library_nodefs.js +234 -0
- data/modules/emscripten/src/library_openal.js +131 -150
- data/modules/emscripten/src/library_path.js +3 -0
- data/modules/emscripten/src/library_sdl.js +499 -229
- data/modules/emscripten/src/library_sockfs.js +576 -0
- data/modules/emscripten/src/library_tty.js +146 -0
- data/modules/emscripten/src/modules.js +30 -35
- data/modules/emscripten/src/parseTools.js +356 -161
- data/modules/emscripten/src/postamble.js +76 -31
- data/modules/emscripten/src/preamble.js +271 -41
- data/modules/emscripten/src/proxyClient.js +82 -0
- data/modules/emscripten/src/proxyWorker.js +143 -0
- data/modules/emscripten/src/relooper/Relooper.cpp +60 -24
- data/modules/emscripten/src/relooper/Relooper.h +3 -2
- data/modules/emscripten/src/relooper/emscripten/glue.js +20 -10
- data/modules/emscripten/src/relooper/fuzzer.py +19 -10
- data/modules/emscripten/src/relooper/test.cpp +50 -50
- data/modules/emscripten/src/relooper/test.txt +147 -30
- data/modules/emscripten/src/relooper/test2.c +13 -13
- data/modules/emscripten/src/relooper/test2.txt +17 -3
- data/modules/emscripten/src/relooper/test3.c +7 -7
- data/modules/emscripten/src/relooper/test3.txt +36 -7
- data/modules/emscripten/src/relooper/test4.cpp +7 -7
- data/modules/emscripten/src/relooper/test4.txt +28 -7
- data/modules/emscripten/src/relooper/test5.cpp +6 -6
- data/modules/emscripten/src/relooper/test5.txt +34 -10
- data/modules/emscripten/src/relooper/test6.cpp +4 -4
- data/modules/emscripten/src/relooper/test6.txt +17 -3
- data/modules/emscripten/src/relooper/test_dead.cpp +2 -2
- data/modules/emscripten/src/relooper/test_debug.cpp +4 -4
- data/modules/emscripten/src/relooper/test_debug.txt +17 -3
- data/modules/emscripten/src/relooper/test_fuzz1.cpp +9 -9
- data/modules/emscripten/src/relooper/test_fuzz1.txt +45 -5
- data/modules/emscripten/src/relooper/test_fuzz2.cpp +4 -4
- data/modules/emscripten/src/relooper/test_fuzz2.txt +18 -1
- data/modules/emscripten/src/relooper/test_fuzz3.cpp +5 -5
- data/modules/emscripten/src/relooper/test_fuzz3.txt +16 -0
- data/modules/emscripten/src/relooper/test_fuzz4.cpp +5 -5
- data/modules/emscripten/src/relooper/test_fuzz4.txt +25 -3
- data/modules/emscripten/src/relooper/test_fuzz5.cpp +10 -10
- data/modules/emscripten/src/relooper/test_fuzz5.txt +49 -15
- data/modules/emscripten/src/relooper/test_fuzz6.cpp +92 -92
- data/modules/emscripten/src/relooper/test_fuzz6.txt +201 -18
- data/modules/emscripten/src/relooper/test_inf.cpp +184 -184
- data/modules/emscripten/src/relooper/test_inf.txt +1078 -332
- data/modules/emscripten/src/runtime.js +69 -45
- data/modules/emscripten/src/settings.js +48 -919
- data/modules/emscripten/src/shell.html +1 -1
- data/modules/emscripten/src/shell.js +14 -8
- data/modules/emscripten/src/shell_sharedlib.js +18 -1
- data/modules/emscripten/src/simd.js +958 -0
- data/modules/emscripten/src/struct_info.json +1045 -0
- data/modules/emscripten/src/utility.js +11 -0
- data/modules/emscripten/system/bin/sdl-config +13 -0
- data/modules/emscripten/system/include/compat/ctype.h +17 -0
- data/modules/emscripten/system/include/compat/malloc.h +48 -0
- data/modules/emscripten/system/include/compat/math.h +14 -0
- data/modules/emscripten/system/include/compat/netdb.h +22 -0
- data/modules/emscripten/system/include/compat/stdarg.h +16 -0
- data/modules/emscripten/system/include/compat/stdlib.h +16 -0
- data/modules/emscripten/system/include/compat/string.h +17 -0
- data/modules/emscripten/system/include/compat/sys/socketvar.h +14 -0
- data/modules/emscripten/system/include/compat/sys/stat.h +20 -0
- data/modules/emscripten/system/include/{libc → compat}/sys/timeb.h +3 -7
- data/modules/emscripten/system/include/compat/time.h +18 -0
- data/modules/emscripten/system/include/compat/unistd.h +16 -0
- data/modules/emscripten/system/include/compat/xlocale.h +19 -0
- data/modules/emscripten/system/include/emscripten/emscripten.h +48 -7
- data/modules/emscripten/system/include/emscripten/vector.h +6 -0
- data/modules/emscripten/system/include/libc/aio.h +69 -0
- data/modules/emscripten/system/include/libc/alloca.h +13 -13
- data/modules/emscripten/system/include/libc/ar.h +19 -63
- data/modules/emscripten/system/include/libc/arpa/ftp.h +35 -0
- data/modules/emscripten/system/include/libc/arpa/inet.h +36 -0
- data/modules/emscripten/system/include/libc/arpa/nameser.h +467 -0
- data/modules/emscripten/system/include/libc/arpa/nameser_compat.h +2 -0
- data/modules/emscripten/system/include/libc/arpa/telnet.h +251 -0
- data/modules/emscripten/system/include/libc/arpa/tftp.h +31 -0
- data/modules/emscripten/system/include/libc/assert.h +9 -36
- data/modules/emscripten/system/include/libc/bits/alltypes.h +397 -0
- data/modules/emscripten/system/include/libc/bits/endian.h +1 -0
- data/modules/emscripten/system/include/libc/bits/errno.h +134 -0
- data/modules/emscripten/system/include/libc/bits/fcntl.h +38 -0
- data/modules/emscripten/system/include/libc/bits/fenv.h +34 -0
- data/modules/emscripten/system/include/libc/bits/float.h +17 -0
- data/modules/emscripten/system/include/libc/bits/io.h +0 -0
- data/modules/emscripten/system/include/libc/bits/ioctl.h +197 -0
- data/modules/emscripten/system/include/libc/bits/ipc.h +14 -0
- data/modules/emscripten/system/include/libc/bits/limits.h +8 -0
- data/modules/emscripten/system/include/libc/bits/mman.h +62 -0
- data/modules/emscripten/system/include/libc/bits/msg.h +16 -0
- data/modules/emscripten/system/include/libc/bits/posix.h +2 -0
- data/modules/emscripten/system/include/libc/bits/reg.h +19 -0
- data/modules/emscripten/system/include/libc/bits/setjmp.h +1 -0
- data/modules/emscripten/system/include/libc/bits/shm.h +18 -0
- data/modules/emscripten/system/include/libc/bits/signal.h +112 -0
- data/modules/emscripten/system/include/libc/bits/socket.h +17 -0
- data/modules/emscripten/system/include/libc/bits/stat.h +22 -0
- data/modules/emscripten/system/include/libc/bits/statfs.h +7 -0
- data/modules/emscripten/system/include/libc/bits/stdarg.h +4 -0
- data/modules/emscripten/system/include/libc/bits/stdint.h +20 -0
- data/modules/emscripten/system/include/libc/bits/syscall.h +696 -0
- data/modules/emscripten/system/include/libc/bits/termios.h +160 -0
- data/modules/emscripten/system/include/libc/bits/user.h +48 -0
- data/modules/emscripten/system/include/libc/byteswap.h +26 -0
- data/modules/emscripten/system/include/libc/complex.h +55 -54
- data/modules/emscripten/system/include/libc/cpio.h +29 -0
- data/modules/emscripten/system/include/libc/crypt.h +20 -0
- data/modules/emscripten/system/include/libc/ctype.h +58 -187
- data/modules/emscripten/system/include/libc/dirent.h +69 -6
- data/modules/emscripten/system/include/libc/dlfcn.h +42 -0
- data/modules/emscripten/system/include/libc/elf.h +2555 -0
- data/modules/emscripten/system/include/libc/endian.h +80 -1
- data/modules/emscripten/system/include/libc/err.h +25 -0
- data/modules/emscripten/system/include/libc/errno.h +23 -7
- data/modules/emscripten/system/include/libc/fcntl.h +175 -1
- data/modules/emscripten/system/include/libc/features.h +32 -0
- data/modules/emscripten/system/include/libc/fenv.h +28 -0
- data/modules/emscripten/system/include/libc/float.h +34 -0
- data/modules/emscripten/system/include/libc/fnmatch.h +24 -50
- data/modules/emscripten/system/include/libc/ftw.h +42 -0
- data/modules/emscripten/system/include/libc/getopt.h +22 -187
- data/modules/emscripten/system/include/libc/glob.h +42 -83
- data/modules/emscripten/system/include/libc/grp.h +37 -79
- data/modules/emscripten/system/include/libc/iconv.h +18 -56
- data/modules/emscripten/system/include/libc/ifaddrs.h +24 -53
- data/modules/emscripten/system/include/libc/inttypes.h +208 -271
- data/modules/emscripten/system/include/libc/iso646.h +5 -28
- data/modules/emscripten/system/include/libc/langinfo.h +88 -316
- data/modules/emscripten/system/include/libc/lastlog.h +1 -0
- data/modules/emscripten/system/include/libc/libgen.h +5 -13
- data/modules/emscripten/system/include/libc/libintl.h +25 -0
- data/modules/emscripten/system/include/libc/limits.h +140 -149
- data/modules/emscripten/system/include/libc/link.h +54 -0
- data/modules/emscripten/system/include/libc/locale.h +72 -70
- data/modules/emscripten/system/include/libc/malloc.h +0 -169
- data/modules/emscripten/system/include/libc/math.h +393 -573
- data/modules/emscripten/system/include/libc/memory.h +1 -0
- data/modules/emscripten/system/include/libc/mntent.h +44 -0
- data/modules/emscripten/system/include/libc/monetary.h +23 -0
- data/modules/emscripten/system/include/libc/mqueue.h +36 -0
- data/modules/emscripten/system/include/libc/net/ethernet.h +55 -0
- data/modules/emscripten/system/include/libc/net/if.h +135 -0
- data/modules/emscripten/system/include/libc/net/if_arp.h +133 -0
- data/modules/emscripten/system/include/libc/net/route.h +124 -0
- data/modules/emscripten/system/include/libc/netdb.h +161 -0
- data/modules/emscripten/system/include/libc/netinet/ether.h +14 -0
- data/modules/emscripten/system/include/libc/netinet/icmp6.h +305 -0
- data/modules/emscripten/system/include/libc/netinet/if_ether.h +126 -0
- data/modules/emscripten/system/include/libc/netinet/in.h +336 -0
- data/modules/emscripten/system/include/libc/netinet/in_systm.h +9 -0
- data/modules/emscripten/system/include/libc/netinet/ip.h +186 -0
- data/modules/emscripten/system/include/libc/netinet/ip6.h +142 -0
- data/modules/emscripten/system/include/libc/netinet/ip_icmp.h +192 -0
- data/modules/emscripten/system/include/libc/netinet/tcp.h +71 -0
- data/modules/emscripten/system/include/libc/netinet/udp.h +35 -0
- data/modules/emscripten/system/include/libc/netpacket/packet.h +44 -0
- data/modules/emscripten/system/include/libc/nl_types.h +22 -0
- data/modules/emscripten/system/include/libc/paths.h +30 -5
- data/modules/emscripten/system/include/libc/poll.h +46 -0
- data/modules/emscripten/system/include/libc/pthread.h +191 -331
- data/modules/emscripten/system/include/libc/pty.h +18 -0
- data/modules/emscripten/system/include/libc/pwd.h +33 -62
- data/modules/emscripten/system/include/libc/readme.txt +2 -2
- data/modules/emscripten/system/include/libc/regex.h +53 -93
- data/modules/emscripten/system/include/libc/resolv.h +144 -0
- data/modules/emscripten/system/include/libc/sched.h +124 -89
- data/modules/emscripten/system/include/libc/search.h +40 -48
- data/modules/emscripten/system/include/libc/semaphore.h +35 -0
- data/modules/emscripten/system/include/libc/setjmp.h +35 -13
- data/modules/emscripten/system/include/libc/shadow.h +44 -0
- data/modules/emscripten/system/include/libc/signal.h +245 -20
- data/modules/emscripten/system/include/libc/spawn.h +74 -0
- data/modules/emscripten/system/include/libc/stdalign.h +15 -0
- data/modules/emscripten/system/include/libc/stdarg.h +18 -43
- data/modules/emscripten/system/include/libc/stdbool.h +14 -0
- data/modules/emscripten/system/include/libc/stddef.h +12 -58
- data/modules/emscripten/system/include/libc/stdint.h +82 -458
- data/modules/emscripten/system/include/libc/stdio.h +184 -679
- data/modules/emscripten/system/include/libc/stdio_ext.h +34 -0
- data/modules/emscripten/system/include/libc/stdlib.h +146 -205
- data/modules/emscripten/system/include/libc/stdnoreturn.h +5 -0
- data/modules/emscripten/system/include/libc/string.h +86 -89
- data/modules/emscripten/system/include/libc/strings.h +27 -27
- data/modules/emscripten/system/include/libc/stropts.h +139 -0
- data/modules/emscripten/system/include/libc/sys/acct.h +75 -0
- data/modules/emscripten/system/include/libc/sys/cachectl.h +22 -0
- data/modules/emscripten/system/include/libc/sys/dir.h +0 -8
- data/modules/emscripten/system/include/libc/sys/epoll.h +67 -0
- data/modules/emscripten/system/include/libc/sys/errno.h +2 -190
- data/modules/emscripten/system/include/libc/sys/eventfd.h +26 -0
- data/modules/emscripten/system/include/libc/sys/fcntl.h +2 -4
- data/modules/emscripten/system/include/libc/sys/file.h +20 -1
- data/modules/emscripten/system/include/libc/sys/fsuid.h +20 -0
- data/modules/emscripten/system/include/libc/sys/inotify.h +57 -0
- data/modules/emscripten/system/include/libc/sys/io.h +17 -0
- data/modules/emscripten/system/include/libc/sys/ioctl.h +14 -0
- data/modules/emscripten/system/include/libc/sys/ipc.h +42 -0
- data/modules/emscripten/system/include/{sys/sysctl.h → libc/sys/klog.h} +4 -4
- data/modules/emscripten/system/include/libc/sys/mman.h +55 -0
- data/modules/emscripten/system/include/libc/sys/mount.h +72 -0
- data/modules/emscripten/system/include/libc/sys/msg.h +52 -0
- data/modules/emscripten/system/include/libc/sys/mtio.h +188 -0
- data/modules/emscripten/system/include/libc/sys/param.h +29 -19
- data/modules/emscripten/system/include/libc/sys/personality.h +46 -0
- data/modules/emscripten/system/include/libc/sys/poll.h +2 -0
- data/modules/emscripten/system/include/libc/sys/prctl.h +101 -0
- data/modules/emscripten/system/include/libc/sys/procfs.h +65 -0
- data/modules/emscripten/system/include/libc/sys/ptrace.h +96 -0
- data/modules/emscripten/system/include/libc/sys/reboot.h +20 -0
- data/modules/emscripten/system/include/libc/sys/reg.h +9 -0
- data/modules/emscripten/system/include/libc/sys/resource.h +89 -45
- data/modules/emscripten/system/include/libc/sys/select.h +42 -0
- data/modules/emscripten/system/include/libc/sys/sem.h +82 -0
- data/modules/emscripten/system/include/libc/sys/sendfile.h +22 -0
- data/modules/emscripten/system/include/libc/sys/shm.h +61 -0
- data/modules/emscripten/system/include/libc/sys/signal.h +1 -315
- data/modules/emscripten/system/include/libc/sys/signalfd.h +44 -0
- data/modules/emscripten/system/include/libc/sys/socket.h +299 -0
- data/modules/emscripten/system/include/libc/sys/stat.h +95 -204
- data/modules/emscripten/system/include/libc/sys/statfs.h +32 -0
- data/modules/emscripten/system/include/libc/sys/statvfs.h +57 -0
- data/modules/emscripten/system/include/libc/sys/stropts.h +1 -0
- data/modules/emscripten/system/include/libc/sys/swap.h +21 -0
- data/modules/emscripten/system/include/libc/sys/syscall.h +6 -0
- data/modules/emscripten/system/include/libc/sys/sysctl.h +17 -0
- data/modules/emscripten/system/include/libc/sys/sysinfo.h +36 -0
- data/modules/emscripten/system/include/libc/sys/syslog.h +1 -0
- data/modules/emscripten/system/include/libc/sys/sysmacros.h +15 -0
- data/modules/emscripten/system/include/libc/sys/termios.h +2 -280
- data/modules/emscripten/system/include/libc/sys/time.h +40 -68
- data/modules/emscripten/system/include/libc/sys/timerfd.h +24 -0
- data/modules/emscripten/system/include/libc/sys/times.h +14 -16
- data/modules/emscripten/system/include/libc/sys/timex.h +98 -0
- data/modules/emscripten/system/include/libc/sys/ttydefaults.h +34 -92
- data/modules/emscripten/system/include/libc/sys/types.h +87 -481
- data/modules/emscripten/system/include/libc/sys/ucontext.h +1 -0
- data/modules/emscripten/system/include/libc/sys/uio.h +48 -0
- data/modules/emscripten/system/include/libc/sys/un.h +32 -0
- data/modules/emscripten/system/include/libc/sys/user.h +16 -0
- data/modules/emscripten/system/include/libc/sys/utsname.h +30 -0
- data/modules/emscripten/system/include/libc/sys/vfs.h +1 -0
- data/modules/emscripten/system/include/libc/sys/wait.h +41 -26
- data/modules/emscripten/system/include/libc/sys/xattr.h +30 -0
- data/modules/emscripten/system/include/libc/syscall.h +1 -0
- data/modules/emscripten/system/include/libc/sysexits.h +21 -0
- data/modules/emscripten/system/include/libc/syslog.h +104 -0
- data/modules/emscripten/system/include/libc/tar.h +27 -33
- data/modules/emscripten/system/include/libc/termios.h +40 -1
- data/modules/emscripten/system/include/libc/tgmath.h +270 -0
- data/modules/emscripten/system/include/libc/time.h +96 -237
- data/modules/emscripten/system/include/libc/ucontext.h +25 -0
- data/modules/emscripten/system/include/libc/ulimit.h +17 -0
- data/modules/emscripten/system/include/libc/unistd.h +517 -4
- data/modules/emscripten/system/include/libc/utime.h +15 -3
- data/modules/emscripten/system/include/libc/utmp.h +40 -1
- data/modules/emscripten/system/include/libc/utmpx.h +58 -0
- data/modules/emscripten/system/include/libc/values.h +39 -0
- data/modules/emscripten/system/include/libc/wchar.h +164 -175
- data/modules/emscripten/system/include/libc/wctype.h +67 -37
- data/modules/emscripten/system/include/libc/wordexp.h +31 -42
- data/modules/emscripten/system/include/libcxx/__locale +6 -6
- data/modules/emscripten/system/include/libcxx/locale +1 -1
- data/modules/emscripten/system/lib/libc/musl/readme.txt +9 -1
- data/modules/emscripten/system/lib/libc/musl/src/internal/locale_impl.h +5 -0
- data/modules/emscripten/system/lib/libc/musl/src/internal/stdio_impl.h +92 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/big5.h +1085 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/codepages.h +238 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/gb18030.h +1836 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/hkscs.h +390 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/iconv.c +454 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/iswalnum_l.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/iswalpha_l.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/iswblank_l.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/iswcntrl_l.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/iswctype_l.c +9 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/iswdigit_l.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/iswgraph_l.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/iswlower_l.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/iswprint_l.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/iswpunct_l.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/iswspace_l.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/iswupper_l.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/iswxdigit_l.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/jis0208.h +550 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/ksc.h +640 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/legacychars.h +39 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/strfmon.c +101 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/strxfrm.c +18 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/towctrans_l.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/towlower_l.c +9 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/towupper_l.c +9 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/wcscoll.c +16 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/wcscoll_l.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/wcsxfrm.c +21 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/wcsxfrm_l.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/wctrans_l.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/locale/wctype_l.c +9 -0
- data/modules/emscripten/system/lib/libc/musl/src/stdio/fwprintf.c +13 -0
- data/modules/emscripten/system/lib/libc/musl/src/stdio/swprintf.c +14 -0
- data/modules/emscripten/system/lib/libc/musl/src/stdio/vfwprintf.c +361 -0
- data/modules/emscripten/system/lib/libc/musl/src/stdio/vswprintf.c +53 -0
- data/modules/emscripten/system/lib/libc/musl/src/stdio/vwprintf.c +7 -0
- data/modules/emscripten/system/lib/libc/musl/src/stdio/wprintf.c +13 -0
- data/modules/emscripten/system/lib/libcextra.symbols +44 -0
- data/modules/emscripten/system/lib/libcxx/exception.cpp +3 -3
- data/modules/emscripten/system/lib/libcxx/locale.cpp +12 -12
- data/modules/emscripten/system/lib/libcxxabi/src/cxa_new_delete.cpp +1 -1
- data/modules/emscripten/tools/asm_module.py +2 -0
- data/modules/emscripten/tools/autodebugger.py +3 -1
- data/modules/emscripten/tools/eliminator/asm-eliminator-test-output.js +0 -4835
- data/modules/emscripten/tools/eliminator/asm-eliminator-test.js +0 -6495
- data/modules/emscripten/tools/file_packager.py +53 -56
- data/modules/emscripten/tools/find_bigfuncs.py +2 -2
- data/modules/emscripten/tools/find_bigvars.py +24 -0
- data/modules/emscripten/tools/gen_struct_info.py +509 -0
- data/modules/emscripten/tools/gen_struct_info.pyc +0 -0
- data/modules/emscripten/tools/js-optimizer.js +177 -86
- data/modules/emscripten/tools/js_optimizer.py +54 -19
- data/modules/emscripten/tools/js_optimizer.pyc +0 -0
- data/modules/emscripten/tools/jsrun.py +17 -7
- data/modules/emscripten/tools/jsrun.pyc +0 -0
- data/modules/emscripten/tools/response_file.py +2 -2
- data/modules/emscripten/tools/response_file.pyc +0 -0
- data/modules/emscripten/tools/shared.py +257 -123
- data/modules/emscripten/tools/shared.pyc +0 -0
- data/modules/emscripten/tools/source-maps/sourcemapper.js +37 -6
- data/modules/emscripten/tools/tempfiles.py +1 -0
- data/modules/emscripten/tools/tempfiles.pyc +0 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-minlast-output.js +2 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-minlast.js +8 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-outline1-output.js +412 -169
- data/modules/emscripten/tools/test-js-optimizer-asm-outline1.js +88 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-outline2-output.js +311 -265
- data/modules/emscripten/tools/test-js-optimizer-asm-pre-output.js +0 -20
- data/modules/emscripten/tools/test-js-optimizer-asm-pre.js +0 -21
- data/modules/emscripten/tools/test-js-optimizer-asm-regs.js +2 -2
- data/modules/emscripten/tools/test-js-optimizer-regs-output.js +8 -8
- data/modules/emscripten/tools/test-js-optimizer-regs.js +1 -1
- data/modules/emscripten/tools/validate_asmjs.py +82 -0
- data/modules/mruby/Rakefile +2 -2
- data/modules/mruby/include/mruby/class.h +2 -2
- data/modules/mruby/include/mruby/compile.h +12 -4
- data/modules/mruby/include/mruby/data.h +8 -3
- data/modules/mruby/include/mruby/debug.h +65 -0
- data/modules/mruby/include/mruby/dump.h +10 -2
- data/modules/mruby/include/mruby/irep.h +1 -0
- data/modules/mruby/include/mruby/string.h +2 -1
- data/modules/mruby/include/mruby/value.h +20 -13
- data/modules/mruby/include/mruby/variable.h +1 -0
- data/modules/mruby/include/mruby.h +5 -6
- data/modules/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +6 -4
- data/modules/mruby/mrbgems/mruby-math/src/math.c +4 -0
- data/modules/mruby/mrbgems/mruby-objectspace/src/mruby_objectspace.c +1 -1
- data/modules/mruby/mrbgems/mruby-proc-ext/src/proc.c +1 -1
- data/modules/mruby/mrbgems/mruby-random/src/random.c +1 -4
- data/modules/mruby/mrbgems/mruby-string-ext/src/string.c +25 -16
- data/modules/mruby/mrbgems/mruby-string-ext/test/string.rb +4 -0
- data/modules/mruby/mrbgems/mruby-struct/src/struct.c +1 -1
- data/modules/mruby/mrbgems/mruby-symbol-ext/mrblib/symbol.rb +51 -0
- data/modules/mruby/mrbgems/mruby-symbol-ext/test/symbol.rb +22 -0
- data/modules/mruby/mrbgems/mruby-time/src/time.c +38 -60
- data/modules/mruby/mrblib/class.rb +2 -2
- data/modules/mruby/src/backtrace.c +96 -23
- data/modules/mruby/src/class.c +43 -41
- data/modules/mruby/src/codegen.c +52 -46
- data/modules/mruby/src/debug.c +214 -0
- data/modules/mruby/src/dump.c +245 -17
- data/modules/mruby/src/error.c +14 -6
- data/modules/mruby/src/etc.c +17 -10
- data/modules/mruby/src/gc.c +9 -9
- data/modules/mruby/src/kernel.c +1 -1
- data/modules/mruby/src/load.c +137 -1
- data/modules/mruby/src/object.c +1 -1
- data/modules/mruby/src/parse.y +162 -37
- data/modules/mruby/src/state.c +2 -0
- data/modules/mruby/src/string.c +28 -19
- data/modules/mruby/src/symbol.c +0 -1
- data/modules/mruby/src/variable.c +12 -15
- data/modules/mruby/src/vm.c +38 -22
- data/modules/mruby/tasks/mrbgem_spec.rake +6 -4
- data/modules/mruby/tasks/mrbgems_test.rake +9 -9
- data/modules/mruby/tasks/mruby_build_gem.rake +9 -0
- data/modules/mruby/tasks/toolchains/androideabi.rake +2 -0
- data/modules/mruby/test/driver.c +3 -3
- data/modules/mruby/test/t/array.rb +13 -0
- data/modules/mruby/test/t/class.rb +28 -0
- data/modules/mruby/test/t/exception.rb +10 -0
- data/modules/mruby/test/t/literals.rb +50 -0
- data/modules/mruby/test/t/module.rb +22 -0
- data/modules/mruby/test/t/proc.rb +37 -0
- data/modules/mruby/test/t/string.rb +20 -21
- data/modules/mruby/tools/mrbc/mrbc.c +2 -4
- data/scripts/gen_post.rb +1 -0
- data/scripts/gen_require.rb +107 -0
- data/templates/minimal/Rakefile +20 -0
- metadata +210 -88
- data/driver/main.c +0 -40
- data/modules/emscripten/cmake/Platform/Emscripten_unix.cmake +0 -24
- data/modules/emscripten/emlibtool +0 -11
- data/modules/emscripten/emlibtool.bat +0 -2
- data/modules/emscripten/src/framework.js +0 -257
- data/modules/emscripten/system/include/bsd/float.h +0 -91
- data/modules/emscripten/system/include/bsd/readme.txt +0 -2
- data/modules/emscripten/system/include/bsd/sys/mman.h +0 -180
- data/modules/emscripten/system/include/bsd/sys/utsname.h +0 -70
- data/modules/emscripten/system/include/dlfcn.h +0 -31
- data/modules/emscripten/system/include/err.h +0 -95
- data/modules/emscripten/system/include/features.h +0 -3
- data/modules/emscripten/system/include/libc/_ansi.h +0 -135
- data/modules/emscripten/system/include/libc/_syslist.h +0 -40
- data/modules/emscripten/system/include/libc/argz.h +0 -33
- data/modules/emscripten/system/include/libc/envlock.h +0 -15
- data/modules/emscripten/system/include/libc/envz.h +0 -16
- data/modules/emscripten/system/include/libc/fastmath.h +0 -13
- data/modules/emscripten/system/include/libc/ieeefp.h +0 -256
- data/modules/emscripten/system/include/libc/machine/_default_types.h +0 -121
- data/modules/emscripten/system/include/libc/machine/_types.h +0 -8
- data/modules/emscripten/system/include/libc/machine/ansi.h +0 -1
- data/modules/emscripten/system/include/libc/machine/endian.h +0 -31
- data/modules/emscripten/system/include/libc/machine/fastmath.h +0 -100
- data/modules/emscripten/system/include/libc/machine/ieeefp.h +0 -376
- data/modules/emscripten/system/include/libc/machine/malloc.h +0 -8
- data/modules/emscripten/system/include/libc/machine/param.h +0 -1
- data/modules/emscripten/system/include/libc/machine/setjmp-dj.h +0 -43
- data/modules/emscripten/system/include/libc/machine/setjmp.h +0 -361
- data/modules/emscripten/system/include/libc/machine/stdlib.h +0 -8
- data/modules/emscripten/system/include/libc/machine/termios.h +0 -1
- data/modules/emscripten/system/include/libc/machine/time.h +0 -19
- data/modules/emscripten/system/include/libc/machine/types.h +0 -30
- data/modules/emscripten/system/include/libc/newlib.h +0 -2
- data/modules/emscripten/system/include/libc/process.h +0 -44
- data/modules/emscripten/system/include/libc/reent.h +0 -183
- data/modules/emscripten/system/include/libc/regdef.h +0 -7
- data/modules/emscripten/system/include/libc/sys/_default_fcntl.h +0 -223
- data/modules/emscripten/system/include/libc/sys/_types.h +0 -93
- data/modules/emscripten/system/include/libc/sys/cdefs.h +0 -123
- data/modules/emscripten/system/include/libc/sys/config.h +0 -255
- data/modules/emscripten/system/include/libc/sys/custom_file.h +0 -2
- data/modules/emscripten/system/include/libc/sys/dirent.h +0 -58
- data/modules/emscripten/system/include/libc/sys/features.h +0 -212
- data/modules/emscripten/system/include/libc/sys/iconvnls.h +0 -77
- data/modules/emscripten/system/include/libc/sys/lock.h +0 -24
- data/modules/emscripten/system/include/libc/sys/queue.h +0 -471
- data/modules/emscripten/system/include/libc/sys/reent.h +0 -843
- data/modules/emscripten/system/include/libc/sys/sched.h +0 -67
- data/modules/emscripten/system/include/libc/sys/stdio.h +0 -27
- data/modules/emscripten/system/include/libc/sys/string.h +0 -2
- data/modules/emscripten/system/include/libc/sys/syslimits.h +0 -65
- data/modules/emscripten/system/include/libc/sys/unistd.h +0 -514
- data/modules/emscripten/system/include/libc/sys/utime.h +0 -26
- data/modules/emscripten/system/include/libc/unctrl.h +0 -46
- data/modules/emscripten/system/include/memory.h +0 -10
- data/modules/emscripten/system/include/mntent.h +0 -23
- data/modules/emscripten/system/include/net/arpa/inet.h +0 -32
- data/modules/emscripten/system/include/net/arpa/nameser.h +0 -535
- data/modules/emscripten/system/include/net/arpa/nameser_compat.h +0 -187
- data/modules/emscripten/system/include/net/if.h +0 -106
- data/modules/emscripten/system/include/net/netinet/in.h +0 -230
- data/modules/emscripten/system/include/net/netinet/tcp.h +0 -246
- data/modules/emscripten/system/include/net/resolv.h +0 -389
- data/modules/emscripten/system/include/netdb.h +0 -130
- data/modules/emscripten/system/include/nl_types.h +0 -19
- data/modules/emscripten/system/include/poll.h +0 -3
- data/modules/emscripten/system/include/pty.h +0 -6
- data/modules/emscripten/system/include/semaphore.h +0 -31
- data/modules/emscripten/system/include/spawn.h +0 -105
- data/modules/emscripten/system/include/stdbool.h +0 -16
- data/modules/emscripten/system/include/sys/bitypes.h +0 -3
- data/modules/emscripten/system/include/sys/io.h +0 -14
- data/modules/emscripten/system/include/sys/ioctl.h +0 -78
- data/modules/emscripten/system/include/sys/poll.h +0 -31
- data/modules/emscripten/system/include/sys/select.h +0 -16
- data/modules/emscripten/system/include/sys/sendfile.h +0 -16
- data/modules/emscripten/system/include/sys/socket.h +0 -247
- data/modules/emscripten/system/include/sys/socketvar.h +0 -3
- data/modules/emscripten/system/include/sys/statvfs.h +0 -32
- data/modules/emscripten/system/include/sys/uio.h +0 -22
- data/modules/emscripten/system/include/sys/un.h +0 -66
- data/modules/emscripten/system/include/sysexits.h +0 -108
- data/modules/emscripten/system/include/xlocale.h +0 -47
@@ -5,11 +5,12 @@
|
|
5
5
|
|
6
6
|
// Does simple 'macro' substitution, using Django-like syntax,
|
7
7
|
// {{{ code }}} will be replaced with |eval(code)|.
|
8
|
+
// NOTE: Be careful with that ret check. If ret is |0|, |ret ? ret.toString() : ''| would result in ''!
|
8
9
|
function processMacros(text) {
|
9
10
|
return text.replace(/{{{([^}]|}(?!}))+}}}/g, function(str) {
|
10
11
|
str = str.substr(3, str.length-6);
|
11
12
|
var ret = eval(str);
|
12
|
-
return ret ? ret.toString() : '';
|
13
|
+
return ret !== null ? ret.toString() : '';
|
13
14
|
});
|
14
15
|
}
|
15
16
|
|
@@ -35,8 +36,13 @@ function preprocess(text) {
|
|
35
36
|
var op = parts[2];
|
36
37
|
var value = parts[3];
|
37
38
|
if (op) {
|
38
|
-
|
39
|
-
|
39
|
+
if (op === '==') {
|
40
|
+
showStack.push(ident in this && this[ident] == value);
|
41
|
+
} else if (op === '!=') {
|
42
|
+
showStack.push(!(ident in this && this[ident] == value));
|
43
|
+
} else {
|
44
|
+
error('unsupported preprecessor op ' + op);
|
45
|
+
}
|
40
46
|
} else {
|
41
47
|
showStack.push(ident in this && this[ident] > 0);
|
42
48
|
}
|
@@ -105,12 +111,22 @@ function isNiceIdent(ident, loose) {
|
|
105
111
|
}
|
106
112
|
|
107
113
|
function isJSVar(ident) {
|
108
|
-
|
109
|
-
|
114
|
+
if (ident[0] === '(') {
|
115
|
+
if (ident[ident.length-1] !== ')') return false;
|
116
|
+
ident = ident.substr(1, ident.length-2);
|
117
|
+
}
|
118
|
+
return /^[$_]?[\w$_\d]* *$/.test(ident);
|
110
119
|
}
|
111
120
|
|
112
121
|
function isLocalVar(ident) {
|
113
|
-
return ident[0]
|
122
|
+
return ident[0] === '$';
|
123
|
+
}
|
124
|
+
|
125
|
+
// Simple variables or numbers, or things already quoted, do not need to be quoted
|
126
|
+
function needsQuoting(ident) {
|
127
|
+
if (/^[-+]?[$_]?[\w$_\d]*$/.test(ident)) return false; // number or variable
|
128
|
+
if (ident[0] === '(' && ident[ident.length-1] === ')' && ident.indexOf('(', 1) < 0) return false; // already fully quoted
|
129
|
+
return true;
|
114
130
|
}
|
115
131
|
|
116
132
|
function isStructPointerType(type) {
|
@@ -214,9 +230,9 @@ function isFunctionDef(token, out) {
|
|
214
230
|
if (nonPointing[0] != '(' || nonPointing.substr(-1) != ')')
|
215
231
|
return false;
|
216
232
|
if (nonPointing === '()') return true;
|
217
|
-
if (!token.
|
233
|
+
if (!token.tokens) return false;
|
218
234
|
var fail = false;
|
219
|
-
var segments = splitTokenList(token.
|
235
|
+
var segments = splitTokenList(token.tokens);
|
220
236
|
segments.forEach(function(segment) {
|
221
237
|
var subtext = segment[0].text;
|
222
238
|
fail = fail || segment.length > 1 || !(isType(subtext) || subtext == '...');
|
@@ -264,7 +280,7 @@ function isFunctionType(type, out) {
|
|
264
280
|
i--;
|
265
281
|
}
|
266
282
|
assert(argText);
|
267
|
-
return isFunctionDef({ text: argText,
|
283
|
+
return isFunctionDef({ text: argText, tokens: tokenize(argText.substr(1, argText.length-2)) }, out);
|
268
284
|
}
|
269
285
|
|
270
286
|
function getReturnType(type) {
|
@@ -308,6 +324,32 @@ function countNormalArgs(type, out, legalized) {
|
|
308
324
|
return ret;
|
309
325
|
}
|
310
326
|
|
327
|
+
function getVectorSize(type) {
|
328
|
+
return parseInt(type.substring(1, type.indexOf(' ')));
|
329
|
+
}
|
330
|
+
|
331
|
+
function getVectorBaseType(type) {
|
332
|
+
Types.usesSIMD = true;
|
333
|
+
switch (type) {
|
334
|
+
case '<2 x float>':
|
335
|
+
case '<4 x float>': return 'float';
|
336
|
+
case '<2 x i32>':
|
337
|
+
case '<4 x i32>': return 'uint';
|
338
|
+
default: throw 'unknown vector type ' + type;
|
339
|
+
}
|
340
|
+
}
|
341
|
+
|
342
|
+
function getVectorNativeType(type) {
|
343
|
+
Types.usesSIMD = true;
|
344
|
+
switch (type) {
|
345
|
+
case '<2 x float>':
|
346
|
+
case '<4 x float>': return 'float';
|
347
|
+
case '<2 x i32>':
|
348
|
+
case '<4 x i32>': return 'i32';
|
349
|
+
default: throw 'unknown vector type ' + type;
|
350
|
+
}
|
351
|
+
}
|
352
|
+
|
311
353
|
function addIdent(token) {
|
312
354
|
token.ident = token.text;
|
313
355
|
return token;
|
@@ -360,7 +402,6 @@ var SPLIT_TOKEN_LIST_SPLITTERS = set(',', 'to'); // 'to' can separate parameters
|
|
360
402
|
function splitTokenList(tokens) {
|
361
403
|
if (tokens.length == 0) return [];
|
362
404
|
if (!tokens.slice) tokens = tokens.tokens;
|
363
|
-
if (tokens.slice(-1)[0].text != ',') tokens.push({text:','});
|
364
405
|
var ret = [];
|
365
406
|
var seg = [];
|
366
407
|
for (var i = 0; i < tokens.length; i++) {
|
@@ -370,24 +411,22 @@ function splitTokenList(tokens) {
|
|
370
411
|
seg = [];
|
371
412
|
} else if (token.text == ';') {
|
372
413
|
ret.push(seg);
|
373
|
-
|
414
|
+
return ret;
|
374
415
|
} else {
|
375
416
|
seg.push(token);
|
376
417
|
}
|
377
418
|
}
|
419
|
+
if (seg.length) ret.push(seg);
|
378
420
|
return ret;
|
379
421
|
}
|
380
422
|
|
381
423
|
function parseParamTokens(params) {
|
382
424
|
if (params.length === 0) return [];
|
383
425
|
var ret = [];
|
384
|
-
if (params[params.length-1].text != ',') {
|
385
|
-
params.push({ text: ',' });
|
386
|
-
}
|
387
426
|
var anonymousIndex = 0;
|
388
427
|
while (params.length > 0) {
|
389
428
|
var i = 0;
|
390
|
-
while (params[i].text != ',') i++;
|
429
|
+
while (i < params.length && params[i].text != ',') i++;
|
391
430
|
var segment = params.slice(0, i);
|
392
431
|
params = params.slice(i+1);
|
393
432
|
segment = cleanSegment(segment);
|
@@ -430,6 +469,8 @@ function parseParamTokens(params) {
|
|
430
469
|
ret.push(parseLLVMFunctionCall(segment));
|
431
470
|
} else if (segment[1].text === 'blockaddress') {
|
432
471
|
ret.push(parseBlockAddress(segment));
|
472
|
+
} else if (segment[1].type && segment[1].type == '{') {
|
473
|
+
ret.push(parseLLVMSegment(segment));
|
433
474
|
} else {
|
434
475
|
if (segment[2] && segment[2].text == 'to') { // part of bitcast params
|
435
476
|
segment = segment.slice(0, 2);
|
@@ -570,6 +611,16 @@ function parseLLVMSegment(segment) {
|
|
570
611
|
return parseBlockAddress(segment);
|
571
612
|
} else {
|
572
613
|
type = segment[0].text;
|
614
|
+
if (type[type.length-1] === '>' && segment[1].text[0] === '<') {
|
615
|
+
// vector literal
|
616
|
+
return {
|
617
|
+
intertype: 'vector',
|
618
|
+
idents: splitTokenList(segment[1].tokens).map(function(pair) {
|
619
|
+
return pair[1].text;
|
620
|
+
}),
|
621
|
+
type: type
|
622
|
+
};
|
623
|
+
}
|
573
624
|
Types.needAnalysis[type] = 0;
|
574
625
|
return {
|
575
626
|
intertype: 'value',
|
@@ -600,13 +651,13 @@ function parseLLVMFunctionCall(segment) {
|
|
600
651
|
segment = cleanSegment(segment);
|
601
652
|
// Remove additional modifiers
|
602
653
|
var variant = null;
|
603
|
-
if (!segment[2] || !segment[2].
|
654
|
+
if (!segment[2] || !segment[2].tokens) {
|
604
655
|
variant = segment.splice(2, 1)[0];
|
605
656
|
if (variant && variant.text) variant = variant.text; // needed for mathops
|
606
657
|
}
|
607
658
|
assertTrue(['inreg', 'byval'].indexOf(segment[1].text) == -1);
|
608
659
|
assert(segment[1].text in PARSABLE_LLVM_FUNCTIONS);
|
609
|
-
while (!segment[2].
|
660
|
+
while (!segment[2].tokens) {
|
610
661
|
segment.splice(2, 1); // Remove modifiers
|
611
662
|
if (!segment[2]) throw 'Invalid segment!';
|
612
663
|
}
|
@@ -615,15 +666,15 @@ function parseLLVMFunctionCall(segment) {
|
|
615
666
|
if (type === '?') {
|
616
667
|
if (intertype === 'getelementptr') {
|
617
668
|
type = '*'; // a pointer, we can easily say, this is
|
618
|
-
} else if (segment[2].
|
619
|
-
type = segment[2].
|
669
|
+
} else if (segment[2].tokens.slice(-2)[0].text === 'to') {
|
670
|
+
type = segment[2].tokens.slice(-1)[0].text;
|
620
671
|
}
|
621
672
|
}
|
622
673
|
var ret = {
|
623
674
|
intertype: intertype,
|
624
675
|
variant: variant,
|
625
676
|
type: type,
|
626
|
-
params: parseParamTokens(segment[2].
|
677
|
+
params: parseParamTokens(segment[2].tokens)
|
627
678
|
};
|
628
679
|
Types.needAnalysis[ret.type] = 0;
|
629
680
|
ret.ident = toNiceIdent(ret.params[0].ident || 'NOIDENT');
|
@@ -727,15 +778,37 @@ function makeI64(low, high) {
|
|
727
778
|
// Splits a number (an integer in a double, possibly > 32 bits) into an USE_TYPED_ARRAYS == 2 i64 value.
|
728
779
|
// Will suffer from rounding. mergeI64 does the opposite.
|
729
780
|
function splitI64(value, floatConversion) {
|
730
|
-
//
|
781
|
+
// general idea:
|
782
|
+
//
|
783
|
+
// $1$0 = ~~$d >>> 0;
|
784
|
+
// $1$1 = Math_abs($d) >= 1 ? (
|
785
|
+
// $d > 0 ? Math.min(Math_floor(($d)/ 4294967296.0), 4294967295.0)
|
786
|
+
// : Math_ceil(Math.min(-4294967296.0, $d - $1$0)/ 4294967296.0)
|
787
|
+
// ) : 0;
|
788
|
+
//
|
789
|
+
// We need to min on positive values here, since our input might be a double, and large values are rounded, so they can
|
731
790
|
// be slightly higher than expected. And if we get 4294967296, that will turn into a 0 if put into a
|
732
791
|
// HEAP32 or |0'd, etc.
|
792
|
+
//
|
793
|
+
// For negatives, we need to ensure a -1 if the value is overall negative, even if not significant negative component
|
794
|
+
|
733
795
|
var lowInput = legalizedI64s ? value : 'VALUE';
|
734
796
|
if (floatConversion && ASM_JS) lowInput = asmFloatToInt(lowInput);
|
797
|
+
var low = lowInput + '>>>0';
|
798
|
+
var high = makeInlineCalculation(
|
799
|
+
asmCoercion('Math_abs(VALUE)', 'double') + ' >= ' + asmEnsureFloat('1', 'double') + ' ? ' +
|
800
|
+
'(VALUE > ' + asmEnsureFloat('0', 'double') + ' ? ' +
|
801
|
+
asmCoercion('Math_min(' + asmCoercion('Math_floor((VALUE)/' + asmEnsureFloat(4294967296, 'float') + ')', 'double') + ', ' + asmEnsureFloat(4294967295, 'float') + ')', 'i32') + '>>>0' +
|
802
|
+
' : ' + asmFloatToInt(asmCoercion('Math_ceil((VALUE - +((' + asmFloatToInt('VALUE') + ')>>>0))/' + asmEnsureFloat(4294967296, 'float') + ')', 'double')) + '>>>0' +
|
803
|
+
')' +
|
804
|
+
' : 0',
|
805
|
+
value,
|
806
|
+
'tempDouble'
|
807
|
+
);
|
735
808
|
if (legalizedI64s) {
|
736
|
-
return [
|
809
|
+
return [low, high];
|
737
810
|
} else {
|
738
|
-
return
|
811
|
+
return makeI64(low, high);
|
739
812
|
}
|
740
813
|
}
|
741
814
|
function mergeI64(value, unsigned) {
|
@@ -874,13 +947,13 @@ function parseI64Constant(str, legalized) {
|
|
874
947
|
}
|
875
948
|
|
876
949
|
function parseNumerical(value, type) {
|
877
|
-
if ((!type || type
|
950
|
+
if ((!type || type === 'double' || type === 'float') && /^0x/.test(value)) {
|
878
951
|
// Hexadecimal double value, as the llvm docs say,
|
879
952
|
// "The one non-intuitive notation for constants is the hexadecimal form of floating point constants."
|
880
953
|
value = IEEEUnHex(value);
|
881
954
|
} else if (USE_TYPED_ARRAYS == 2 && isIllegalType(type)) {
|
882
955
|
return value; // do not parseFloat etc., that can lead to loss of precision
|
883
|
-
} else if (value
|
956
|
+
} else if (value === 'null') {
|
884
957
|
// NULL *is* 0, in C/C++. No JS null! (null == 0 is false, etc.)
|
885
958
|
value = '0';
|
886
959
|
} else if (value === 'true') {
|
@@ -890,7 +963,10 @@ function parseNumerical(value, type) {
|
|
890
963
|
}
|
891
964
|
if (isNumber(value)) {
|
892
965
|
var ret = parseFloat(value); // will change e.g. 5.000000e+01 to 50
|
893
|
-
if (type
|
966
|
+
if (type === 'double' || type === 'float') {
|
967
|
+
if (value[0] === '-' && ret === 0) return '-.0'; // fix negative 0, toString makes it 0
|
968
|
+
if (!RUNNING_JS_OPTS) ret = asmEnsureFloat(ret, type);
|
969
|
+
}
|
894
970
|
return ret.toString();
|
895
971
|
} else {
|
896
972
|
return value;
|
@@ -903,12 +979,12 @@ function parseLLVMString(str) {
|
|
903
979
|
var ret = [];
|
904
980
|
var i = 0;
|
905
981
|
while (i < str.length) {
|
906
|
-
var chr = str
|
907
|
-
if (chr
|
908
|
-
ret.push(chr
|
982
|
+
var chr = str.charCodeAt(i);
|
983
|
+
if (chr !== 92) { // 92 === '//'.charCodeAt(0)
|
984
|
+
ret.push(chr);
|
909
985
|
i++;
|
910
986
|
} else {
|
911
|
-
ret.push(
|
987
|
+
ret.push(parseInt(str[i+1]+str[i+2], '16'));
|
912
988
|
i += 3;
|
913
989
|
}
|
914
990
|
}
|
@@ -957,9 +1033,11 @@ function generateStructTypes(type) {
|
|
957
1033
|
var ret = new Array(size);
|
958
1034
|
var index = 0;
|
959
1035
|
function add(typeData) {
|
1036
|
+
var array = typeData.name_[0] === '['; // arrays just have 2 elements in their fields, see calculateStructAlignment
|
1037
|
+
var num = array ? parseInt(typeData.name_.substr(1)) : typeData.fields.length;
|
960
1038
|
var start = index;
|
961
|
-
for (var i = 0; i <
|
962
|
-
var type = typeData.fields[i];
|
1039
|
+
for (var i = 0; i < num; i++) {
|
1040
|
+
var type = array ? typeData.fields[0] : typeData.fields[i];
|
963
1041
|
if (!SAFE_HEAP && isPointerType(type)) type = '*'; // do not include unneeded type names without safe heap
|
964
1042
|
if (Runtime.isNumberType(type) || isPointerType(type)) {
|
965
1043
|
if (USE_TYPED_ARRAYS == 2 && type == 'i64') {
|
@@ -982,7 +1060,10 @@ function generateStructTypes(type) {
|
|
982
1060
|
}
|
983
1061
|
add(Types.types[type]);
|
984
1062
|
}
|
985
|
-
var more =
|
1063
|
+
var more = array ? (i+1)*typeData.flatSize/num : (
|
1064
|
+
(i+1 < typeData.fields.length ? typeData.flatIndexes[i+1] : typeData.flatSize)
|
1065
|
+
);
|
1066
|
+
more -= index - start;
|
986
1067
|
for (var j = 0; j < more; j++) {
|
987
1068
|
ret[index++] = 0;
|
988
1069
|
}
|
@@ -1096,7 +1177,16 @@ function asmEnsureFloat(value, type) { // ensures that a float type has either 5
|
|
1096
1177
|
if (!ASM_JS) return value;
|
1097
1178
|
// coerce if missing a '.', or if smaller than 1, so could be 1e-5 which has no .
|
1098
1179
|
if (type in Runtime.FLOAT_TYPES && isNumber(value) && (value.toString().indexOf('.') < 0 || Math.abs(value) < 1)) {
|
1099
|
-
|
1180
|
+
if (RUNNING_JS_OPTS) {
|
1181
|
+
return '(+' + value + ')'; // JS optimizer will run, we must do +x, and it will be corrected later
|
1182
|
+
} else {
|
1183
|
+
// ensure a .
|
1184
|
+
value = value.toString();
|
1185
|
+
if (value.indexOf('.') >= 0 || /[IN]/.test(value)) return value; // if already dotted, or Infinity or NaN, nothing to do here
|
1186
|
+
var e = value.indexOf('e');
|
1187
|
+
if (e < 0) return value + '.0';
|
1188
|
+
return value.substr(0, e) + '.0' + value.substr(e);
|
1189
|
+
}
|
1100
1190
|
} else {
|
1101
1191
|
return value;
|
1102
1192
|
}
|
@@ -1104,7 +1194,11 @@ function asmEnsureFloat(value, type) { // ensures that a float type has either 5
|
|
1104
1194
|
|
1105
1195
|
function asmInitializer(type, impl) {
|
1106
1196
|
if (type in Runtime.FLOAT_TYPES) {
|
1107
|
-
|
1197
|
+
if (RUNNING_JS_OPTS) {
|
1198
|
+
return '+0';
|
1199
|
+
} else {
|
1200
|
+
return '.0';
|
1201
|
+
}
|
1108
1202
|
} else {
|
1109
1203
|
return '0';
|
1110
1204
|
}
|
@@ -1167,7 +1261,7 @@ function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align, noSa
|
|
1167
1261
|
var typeData = Types.types[type];
|
1168
1262
|
var ret = [];
|
1169
1263
|
for (var i = 0; i < typeData.fields.length; i++) {
|
1170
|
-
ret.push('f' + i + ': ' + makeGetValue(ptr, pos + typeData.flatIndexes[i], typeData.fields[i], noNeedFirst, unsigned));
|
1264
|
+
ret.push('f' + i + ': ' + makeGetValue(ptr, pos + typeData.flatIndexes[i], typeData.fields[i], noNeedFirst, unsigned, 0, 0, noSafe));
|
1171
1265
|
}
|
1172
1266
|
return '{ ' + ret.join(', ') + ' }';
|
1173
1267
|
}
|
@@ -1175,8 +1269,8 @@ function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align, noSa
|
|
1175
1269
|
// In double mode 1, in x86 we always assume unaligned because we can't trust that; otherwise in le32
|
1176
1270
|
// we need this code path if we are not fully aligned.
|
1177
1271
|
if (DOUBLE_MODE == 1 && USE_TYPED_ARRAYS == 2 && type == 'double' && (TARGET_X86 || align < 8)) {
|
1178
|
-
return '(' + makeSetTempDouble(0, 'i32', makeGetValue(ptr, pos, 'i32', noNeedFirst, unsigned, ignore, align)) + ',' +
|
1179
|
-
makeSetTempDouble(1, 'i32', makeGetValue(ptr, getFastValue(pos, '+', Runtime.getNativeTypeSize('i32')), 'i32', noNeedFirst, unsigned, ignore, align)) + ',' +
|
1272
|
+
return '(' + makeSetTempDouble(0, 'i32', makeGetValue(ptr, pos, 'i32', noNeedFirst, unsigned, ignore, align, noSafe)) + ',' +
|
1273
|
+
makeSetTempDouble(1, 'i32', makeGetValue(ptr, getFastValue(pos, '+', Runtime.getNativeTypeSize('i32')), 'i32', noNeedFirst, unsigned, ignore, align, noSafe)) + ',' +
|
1180
1274
|
makeGetTempDouble(0, 'double') + ')';
|
1181
1275
|
}
|
1182
1276
|
|
@@ -1189,12 +1283,12 @@ function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align, noSa
|
|
1189
1283
|
if (isIntImplemented(type)) {
|
1190
1284
|
if (bytes == 4 && align == 2) {
|
1191
1285
|
// Special case that we can optimize
|
1192
|
-
ret += makeGetValue(ptr, pos, 'i16', noNeedFirst, 2, ignore) + '|' +
|
1193
|
-
'(' + makeGetValue(ptr, getFastValue(pos, '+', 2), 'i16', noNeedFirst, 2, ignore) + '<<16)';
|
1286
|
+
ret += makeGetValue(ptr, pos, 'i16', noNeedFirst, 2, ignore, 2, noSafe) + '|' +
|
1287
|
+
'(' + makeGetValue(ptr, getFastValue(pos, '+', 2), 'i16', noNeedFirst, 2, ignore, 2, noSafe) + '<<16)';
|
1194
1288
|
} else { // XXX we cannot truly handle > 4... (in x86)
|
1195
1289
|
ret = '';
|
1196
1290
|
for (var i = 0; i < bytes; i++) {
|
1197
|
-
ret += '(' + makeGetValue(ptr, getFastValue(pos, '+', i), 'i8', noNeedFirst, 1, ignore) + (i > 0 ? '<<' + (8*i) : '') + ')';
|
1291
|
+
ret += '(' + makeGetValue(ptr, getFastValue(pos, '+', i), 'i8', noNeedFirst, 1, ignore, 1, noSafe) + (i > 0 ? '<<' + (8*i) : '') + ')';
|
1198
1292
|
if (i < bytes-1) ret += '|';
|
1199
1293
|
}
|
1200
1294
|
ret = '(' + makeSignOp(ret, type, unsigned ? 'un' : 're', true);
|
@@ -1244,7 +1338,7 @@ function indexizeFunctions(value, type) {
|
|
1244
1338
|
if (!sig) {
|
1245
1339
|
sig = Functions.unimplementedFunctions[value] = Functions.getSignature(out.returnType, out.segments ? out.segments.map(function(segment) { return segment[0].text }) : [], isVarArgsFunctionType(type));
|
1246
1340
|
}
|
1247
|
-
return Functions.getIndex(value,
|
1341
|
+
return Functions.getIndex(value, sig);
|
1248
1342
|
}
|
1249
1343
|
return value;
|
1250
1344
|
}
|
@@ -1273,7 +1367,7 @@ function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, noSafe,
|
|
1273
1367
|
value = range(typeData.fields.length).map(function(i) { return value + '.f' + i });
|
1274
1368
|
}
|
1275
1369
|
for (var i = 0; i < typeData.fields.length; i++) {
|
1276
|
-
ret.push(makeSetValue(ptr, getFastValue(pos, '+', typeData.flatIndexes[i]), value[i], typeData.fields[i], noNeedFirst));
|
1370
|
+
ret.push(makeSetValue(ptr, getFastValue(pos, '+', typeData.flatIndexes[i]), value[i], typeData.fields[i], noNeedFirst, 0, 0, noSafe));
|
1277
1371
|
}
|
1278
1372
|
return ret.join('; ');
|
1279
1373
|
}
|
@@ -1300,17 +1394,17 @@ function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, noSafe,
|
|
1300
1394
|
if (bytes == 4 && align == 2) {
|
1301
1395
|
// Special case that we can optimize
|
1302
1396
|
ret += 'tempBigInt=' + value + sep;
|
1303
|
-
ret += makeSetValue(ptr, pos, 'tempBigInt&0xffff', 'i16', noNeedFirst, ignore, 2) + sep;
|
1304
|
-
ret += makeSetValue(ptr, getFastValue(pos, '+', 2), 'tempBigInt>>16', 'i16', noNeedFirst, ignore, 2);
|
1397
|
+
ret += makeSetValue(ptr, pos, 'tempBigInt&0xffff', 'i16', noNeedFirst, ignore, 2, noSafe) + sep;
|
1398
|
+
ret += makeSetValue(ptr, getFastValue(pos, '+', 2), 'tempBigInt>>16', 'i16', noNeedFirst, ignore, 2, noSafe);
|
1305
1399
|
} else {
|
1306
1400
|
ret += 'tempBigInt=' + value + sep;
|
1307
1401
|
for (var i = 0; i < bytes; i++) {
|
1308
|
-
ret += makeSetValue(ptr, getFastValue(pos, '+', i), 'tempBigInt&0xff', 'i8', noNeedFirst, ignore, 1);
|
1402
|
+
ret += makeSetValue(ptr, getFastValue(pos, '+', i), 'tempBigInt&0xff', 'i8', noNeedFirst, ignore, 1, noSafe);
|
1309
1403
|
if (i < bytes-1) ret += sep + 'tempBigInt = tempBigInt>>8' + sep;
|
1310
1404
|
}
|
1311
1405
|
}
|
1312
1406
|
} else {
|
1313
|
-
ret += makeSetValue('tempDoublePtr', 0, value, type, noNeedFirst, ignore, 8,
|
1407
|
+
ret += makeSetValue('tempDoublePtr', 0, value, type, noNeedFirst, ignore, 8, noSafe, null, true) + sep;
|
1314
1408
|
ret += makeCopyValues(getFastValue(ptr, '+', pos), 'tempDoublePtr', Runtime.getNativeTypeSize(type), type, null, align, sep);
|
1315
1409
|
}
|
1316
1410
|
return ret;
|
@@ -1319,6 +1413,7 @@ function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, noSafe,
|
|
1319
1413
|
|
1320
1414
|
value = indexizeFunctions(value, type);
|
1321
1415
|
var offset = calcFastOffset(ptr, pos, noNeedFirst);
|
1416
|
+
if (phase === 'pre' && isNumber(offset)) offset += ' '; // avoid pure numeric strings, seem to be perf issues with overly-aggressive interning or slt in pre processing of heap inits
|
1322
1417
|
if (SAFE_HEAP && !noSafe) {
|
1323
1418
|
var printType = type;
|
1324
1419
|
if (printType !== 'null' && printType[0] !== '#') printType = '"' + safeQuote(printType) + '"';
|
@@ -1435,77 +1530,97 @@ function makeHEAPView(which, start, end) {
|
|
1435
1530
|
return 'HEAP' + which + '.subarray((' + start + ')' + mod + ',(' + end + ')' + mod + ')';
|
1436
1531
|
}
|
1437
1532
|
|
1438
|
-
var PLUS_MUL = set('+', '*');
|
1439
|
-
var MUL_DIV = set('*', '/');
|
1440
|
-
var PLUS_MINUS = set('+', '-');
|
1441
1533
|
var TWO_TWENTY = Math.pow(2, 20);
|
1442
1534
|
|
1443
1535
|
// Given two values and an operation, returns the result of that operation.
|
1444
1536
|
// Tries to do as much as possible at compile time.
|
1445
1537
|
// Leaves overflows etc. unhandled, *except* for integer multiply, in order to be efficient with Math.imul
|
1446
1538
|
function getFastValue(a, op, b, type) {
|
1447
|
-
a = a
|
1448
|
-
b = b
|
1449
|
-
|
1450
|
-
|
1451
|
-
if (
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1539
|
+
a = a === 'true' ? '1' : (a === 'false' ? '0' : a);
|
1540
|
+
b = b === 'true' ? '1' : (b === 'false' ? '0' : b);
|
1541
|
+
|
1542
|
+
var aNumber = null, bNumber = null;
|
1543
|
+
if (typeof a === 'number') {
|
1544
|
+
aNumber = a;
|
1545
|
+
a = a.toString();
|
1546
|
+
} else if (isNumber(a)) aNumber = parseFloat(a);
|
1547
|
+
if (typeof b === 'number') {
|
1548
|
+
bNumber = b;
|
1549
|
+
b = b.toString();
|
1550
|
+
} else if (isNumber(b)) bNumber = parseFloat(b);
|
1551
|
+
|
1552
|
+
if (aNumber !== null && bNumber !== null) {
|
1553
|
+
switch (op) {
|
1554
|
+
case '+': return (aNumber + bNumber).toString();
|
1555
|
+
case '-': return (aNumber - bNumber).toString();
|
1556
|
+
case '*': return (aNumber * bNumber).toString();
|
1557
|
+
case '/': {
|
1558
|
+
if (type[0] === 'i') {
|
1559
|
+
return ((aNumber / bNumber)|0).toString();
|
1560
|
+
} else {
|
1561
|
+
return (aNumber / bNumber).toString();
|
1562
|
+
}
|
1563
|
+
}
|
1564
|
+
case '%': return (aNumber % bNumber).toString();
|
1565
|
+
case '|': return (aNumber | bNumber).toString();
|
1566
|
+
case '>>>': return (aNumber >>> bNumber).toString();
|
1567
|
+
case '&': return (aNumber & bNumber).toString();
|
1568
|
+
case 'pow': return Math.pow(aNumber, bNumber).toString();
|
1569
|
+
default: throw 'need to implement getFastValue pn ' + op;
|
1458
1570
|
}
|
1459
1571
|
}
|
1460
|
-
if (op
|
1461
|
-
if (a
|
1572
|
+
if (op === 'pow') {
|
1573
|
+
if (a === '2' && isIntImplemented(type)) {
|
1462
1574
|
return '(1 << (' + b + '))';
|
1463
1575
|
}
|
1464
|
-
return '
|
1576
|
+
return 'Math_pow(' + a + ', ' + b + ')';
|
1465
1577
|
}
|
1466
|
-
if (op
|
1578
|
+
if ((op === '+' || op === '*') && aNumber !== null) { // if one of them is a number, keep it last
|
1467
1579
|
var c = b;
|
1468
1580
|
b = a;
|
1469
1581
|
a = c;
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1582
|
+
var cNumber = bNumber;
|
1583
|
+
bNumber = aNumber;
|
1584
|
+
aNumber = cNumber;
|
1585
|
+
}
|
1586
|
+
if (op === '*') {
|
1587
|
+
// We can't eliminate where a or b are 0 as that would break things for creating
|
1588
|
+
// a negative 0.
|
1589
|
+
if ((aNumber === 0 || bNumber === 0) && !(type in Runtime.FLOAT_TYPES)) {
|
1590
|
+
return '0';
|
1591
|
+
} else if (aNumber === 1) {
|
1592
|
+
return b;
|
1593
|
+
} else if (bNumber === 1) {
|
1594
|
+
return a;
|
1595
|
+
} else if (bNumber !== null && type && isIntImplemented(type) && Runtime.getNativeTypeSize(type) <= 32) {
|
1596
|
+
var shifts = Math.log(bNumber)/Math.LN2;
|
1597
|
+
if (shifts % 1 === 0) {
|
1598
|
+
return '(' + a + '<<' + shifts + ')';
|
1484
1599
|
}
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
return '(Math.imul(' + a + ',' + b + ')|0)';
|
1600
|
+
}
|
1601
|
+
if (!(type in Runtime.FLOAT_TYPES)) {
|
1602
|
+
// if guaranteed small enough to not overflow into a double, do a normal multiply
|
1603
|
+
var bits = getBits(type) || 32; // default is 32-bit multiply for things like getelementptr indexes
|
1604
|
+
// Note that we can emit simple multiple in non-asm.js mode, but asm.js will not parse "16-bit" multiple, so must do imul there
|
1605
|
+
if ((aNumber !== null && Math.abs(a) < TWO_TWENTY) || (bNumber !== null && Math.abs(b) < TWO_TWENTY) || (bits < 32 && !ASM_JS)) {
|
1606
|
+
return '(((' + a + ')*(' + b + '))&' + ((Math.pow(2, bits)-1)|0) + ')'; // keep a non-eliminatable coercion directly on this
|
1493
1607
|
}
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1608
|
+
return '(Math_imul(' + a + ',' + b + ')|0)';
|
1609
|
+
}
|
1610
|
+
} else if (op === '/') {
|
1611
|
+
if (a === '0' && !(type in Runtime.FLOAT_TYPES)) { // careful on floats, since 0*NaN is not 0
|
1612
|
+
return '0';
|
1613
|
+
} else if (b === 1) {
|
1614
|
+
return a;
|
1615
|
+
} // Doing shifts for division is problematic, as getting the rounding right on negatives is tricky
|
1616
|
+
} else if (op === '+' || op === '-') {
|
1617
|
+
if (b[0] === '-') {
|
1618
|
+
op = op === '+' ? '-' : '+';
|
1504
1619
|
b = b.substr(1);
|
1505
1620
|
}
|
1506
|
-
if (
|
1507
|
-
return op
|
1508
|
-
} else if (
|
1621
|
+
if (aNumber === 0) {
|
1622
|
+
return op === '+' ? b : '(-' + b + ')';
|
1623
|
+
} else if (bNumber === 0) {
|
1509
1624
|
return a;
|
1510
1625
|
}
|
1511
1626
|
}
|
@@ -1534,12 +1649,8 @@ function getFastValues(list, op, type) {
|
|
1534
1649
|
}
|
1535
1650
|
|
1536
1651
|
function calcFastOffset(ptr, pos, noNeedFirst) {
|
1537
|
-
|
1538
|
-
return getFastValue(
|
1539
|
-
}
|
1540
|
-
|
1541
|
-
function makeGetPos(ptr) {
|
1542
|
-
return ptr;
|
1652
|
+
assert(!noNeedFirst);
|
1653
|
+
return getFastValue(ptr, '+', pos, 'i32');
|
1543
1654
|
}
|
1544
1655
|
|
1545
1656
|
var IHEAP_FHEAP = set('IHEAP', 'IHEAPU', 'FHEAP');
|
@@ -1698,11 +1809,13 @@ function makeGetSlabs(ptr, type, allowMultiple, unsigned) {
|
|
1698
1809
|
switch(type) {
|
1699
1810
|
case 'i1': case 'i8': return [unsigned ? 'HEAPU8' : 'HEAP8']; break;
|
1700
1811
|
case 'i16': return [unsigned ? 'HEAPU16' : 'HEAP16']; break;
|
1812
|
+
case '<4 x i32>': case 'uint':
|
1701
1813
|
case 'i32': case 'i64': return [unsigned ? 'HEAPU32' : 'HEAP32']; break;
|
1702
1814
|
case 'double': {
|
1703
1815
|
if (TARGET_LE32) return ['HEAPF64']; // in le32, we do have the ability to assume 64-bit alignment
|
1704
1816
|
// otherwise, fall through to float
|
1705
1817
|
}
|
1818
|
+
case '<4 x float>':
|
1706
1819
|
case 'float': return ['HEAPF32'];
|
1707
1820
|
default: {
|
1708
1821
|
throw 'what, exactly, can we do for unknown types in TA2?! ' + [new Error().stack, ptr, type, allowMultiple, unsigned];
|
@@ -1729,7 +1842,7 @@ function checkBitcast(item) {
|
|
1729
1842
|
} else {
|
1730
1843
|
warnOnce('Casting a function pointer type to a potentially incompatible one (use -s VERBOSE=1 to see more)');
|
1731
1844
|
}
|
1732
|
-
warnOnce('See https://github.com/kripken/emscripten/wiki/
|
1845
|
+
warnOnce('See https://github.com/kripken/emscripten/wiki/CodeGuidelinesAndLimitations#function-pointer-issues for more information on dangerous function pointer casts');
|
1733
1846
|
if (ASM_JS) warnOnce('Incompatible function pointer casts are very dangerous with ASM_JS=1, you should investigate and correct these');
|
1734
1847
|
}
|
1735
1848
|
if (oldCount != newCount && oldCount && newCount) showWarning();
|
@@ -1776,7 +1889,7 @@ function getGetElementPtrIndexes(item) {
|
|
1776
1889
|
// struct, and possibly further substructures, all embedded
|
1777
1890
|
// can also be to 'blocks': [8 x i32]*, not just structs
|
1778
1891
|
type = removePointing(type);
|
1779
|
-
var indexes = [
|
1892
|
+
var indexes = [ident];
|
1780
1893
|
var offset = item.params[1];
|
1781
1894
|
if (offset != 0) {
|
1782
1895
|
if (isStructType(type)) {
|
@@ -1831,8 +1944,10 @@ function handleOverflow(text, bits) {
|
|
1831
1944
|
if (CHECK_OVERFLOWS) return 'CHECK_OVERFLOW(' + text + ', ' + bits + ', ' + Math.floor(correctSpecificOverflow()) + ')';
|
1832
1945
|
if (!correct) return text;
|
1833
1946
|
if (bits == 32) {
|
1947
|
+
if (isNumber(text)) return text | 0;
|
1834
1948
|
return '((' + text + ')|0)';
|
1835
1949
|
} else if (bits < 32) {
|
1950
|
+
if (isNumber(text)) return text & (Math.pow(2, bits) - 1);
|
1836
1951
|
return '((' + text + ')&' + (Math.pow(2, bits) - 1) + ')';
|
1837
1952
|
} else {
|
1838
1953
|
return text; // We warned about this earlier
|
@@ -1908,6 +2023,8 @@ function finalizeLLVMParameter(param, noIndexizeFunctions) {
|
|
1908
2023
|
return param.ident; // we don't really want the type here
|
1909
2024
|
} else if (param.intertype == 'mathop') {
|
1910
2025
|
return processMathop(param);
|
2026
|
+
} else if (param.intertype === 'vector') {
|
2027
|
+
return 'float32x4(' + param.idents.join(',') + ')';
|
1911
2028
|
} else {
|
1912
2029
|
throw 'invalid llvm parameter: ' + param.intertype;
|
1913
2030
|
}
|
@@ -1922,7 +2039,7 @@ function makeComparison(a, op, b, type) {
|
|
1922
2039
|
return asmCoercion(a, type) + op + asmCoercion(b, type);
|
1923
2040
|
} else {
|
1924
2041
|
assert(type == 'i64');
|
1925
|
-
return asmCoercion(a + '$0', 'i32') + op + asmCoercion(b + '$0', 'i32') + '
|
2042
|
+
return asmCoercion(a + '$0', 'i32') + op + asmCoercion(b + '$0', 'i32') + '&' +
|
1926
2043
|
asmCoercion(a + '$1', 'i32') + op + asmCoercion(b + '$1', 'i32');
|
1927
2044
|
}
|
1928
2045
|
}
|
@@ -1931,13 +2048,12 @@ function makeSignOp(value, type, op, force, ignore) {
|
|
1931
2048
|
if (USE_TYPED_ARRAYS == 2 && type == 'i64') {
|
1932
2049
|
return value; // these are always assumed to be two 32-bit unsigneds.
|
1933
2050
|
}
|
1934
|
-
|
1935
2051
|
if (isPointerType(type)) type = 'i32'; // Pointers are treated as 32-bit ints
|
1936
2052
|
if (!value) return value;
|
1937
2053
|
var bits, full;
|
1938
2054
|
if (type in Runtime.INT_TYPES) {
|
1939
2055
|
bits = parseInt(type.substr(1));
|
1940
|
-
full = op + 'Sign(' + value + ', ' + bits + ', ' + Math.floor(ignore ||
|
2056
|
+
full = op + 'Sign(' + value + ', ' + bits + ', ' + Math.floor(ignore || correctSpecificSign()) + ')';
|
1941
2057
|
// Always sign/unsign constants at compile time, regardless of CHECK/CORRECT
|
1942
2058
|
if (isNumber(value)) {
|
1943
2059
|
return eval(full).toString();
|
@@ -1945,23 +2061,25 @@ function makeSignOp(value, type, op, force, ignore) {
|
|
1945
2061
|
}
|
1946
2062
|
if ((ignore || !correctSigns()) && !CHECK_SIGNS && !force) return value;
|
1947
2063
|
if (type in Runtime.INT_TYPES) {
|
2064
|
+
// this is an integer, but not a number (or we would have already handled it)
|
1948
2065
|
// shortcuts
|
1949
2066
|
if (!CHECK_SIGNS || ignore) {
|
2067
|
+
if (value === 'true') {
|
2068
|
+
value = '1';
|
2069
|
+
} else if (value === 'false') {
|
2070
|
+
value = '0';
|
2071
|
+
} else if (needsQuoting(value)) value = '(' + value + ')';
|
1950
2072
|
if (bits === 32) {
|
1951
2073
|
if (op === 're') {
|
1952
|
-
return '(' +
|
2074
|
+
return '(' + value + '|0)';
|
1953
2075
|
} else {
|
1954
|
-
|
1955
|
-
return '(' + getFastValue(value, '>>>', '0') + ')';
|
1956
|
-
// Alternatively, we can consider the lengthier
|
1957
|
-
// return makeInlineCalculation('VALUE >= 0 ? VALUE : ' + Math.pow(2, bits) + ' + VALUE', value, 'tempBigInt');
|
1958
|
-
// which does not always turn us into a 32-bit *un*signed value
|
2076
|
+
return '(' + value + '>>>0)';
|
1959
2077
|
}
|
1960
2078
|
} else if (bits < 32) {
|
1961
2079
|
if (op === 're') {
|
1962
|
-
return
|
2080
|
+
return '((' + value + '<<' + (32-bits) + ')>>' + (32-bits) + ')';
|
1963
2081
|
} else {
|
1964
|
-
return '(' +
|
2082
|
+
return '(' + value + '&' + (Math.pow(2, bits)-1) + ')';
|
1965
2083
|
}
|
1966
2084
|
} else { // bits > 32
|
1967
2085
|
if (op === 're') {
|
@@ -1989,12 +2107,12 @@ function makeRounding(value, bits, signed, floatConversion) {
|
|
1989
2107
|
// as |0, but &-1 hints to the js optimizer that this is a rounding correction
|
1990
2108
|
// Do Math.floor, which is reasonably fast, if we either don't care, or if we can be sure
|
1991
2109
|
// the value is non-negative
|
1992
|
-
if (!correctRoundings() || (!signed && !floatConversion)) return '
|
2110
|
+
if (!correctRoundings() || (!signed && !floatConversion)) return 'Math_floor(' + value + ')';
|
1993
2111
|
// We are left with >32 bits signed, or a float conversion. Check and correct inline
|
1994
2112
|
// Note that if converting a float, we may have the wrong sign at this point! But, we have
|
1995
2113
|
// been rounded properly regardless, and we will be sign-corrected later when actually used, if
|
1996
2114
|
// necessary.
|
1997
|
-
return makeInlineCalculation(makeComparison('VALUE', '>=', '0', 'float') + ' ?
|
2115
|
+
return makeInlineCalculation(makeComparison('VALUE', '>=', '0', 'float') + ' ? Math_floor(VALUE) : Math_ceil(VALUE)', value, 'tempBigIntR');
|
1998
2116
|
} else {
|
1999
2117
|
// asm.js mode, cleaner refactoring of this function as well. TODO: use in non-asm case, most of this
|
2000
2118
|
if (floatConversion && bits <= 32) {
|
@@ -2009,9 +2127,9 @@ function makeRounding(value, bits, signed, floatConversion) {
|
|
2009
2127
|
}
|
2010
2128
|
}
|
2011
2129
|
// Math.floor is reasonably fast if we don't care about corrections (and even correct if unsigned)
|
2012
|
-
if (!correctRoundings() || !signed) return '
|
2130
|
+
if (!correctRoundings() || !signed) return 'Math_floor(' + value + ')';
|
2013
2131
|
// We are left with >32 bits
|
2014
|
-
return makeInlineCalculation(makeComparison('VALUE', '>=', '0', 'float') + ' ?
|
2132
|
+
return makeInlineCalculation(makeComparison('VALUE', '>=', '0', 'float') + ' ? Math_floor(VALUE) : Math_ceil(VALUE)', value, 'tempBigIntR');
|
2015
2133
|
}
|
2016
2134
|
}
|
2017
2135
|
|
@@ -2020,6 +2138,13 @@ function makeIsNaN(value) {
|
|
2020
2138
|
return 'isNaN(' + value + ')';
|
2021
2139
|
}
|
2022
2140
|
|
2141
|
+
function makeFloat(value, type) {
|
2142
|
+
if (TO_FLOAT32 && type == 'float') {
|
2143
|
+
return 'Math_toFloat32(' + value + ')';
|
2144
|
+
}
|
2145
|
+
return value;
|
2146
|
+
}
|
2147
|
+
|
2023
2148
|
// fptoui and fptosi are not in these, because we need to be careful about what we do there. We can't
|
2024
2149
|
// just sign/unsign the input first.
|
2025
2150
|
var UNSIGNED_OP = set('udiv', 'urem', 'uitofp', 'zext', 'lshr');
|
@@ -2044,7 +2169,7 @@ function processMathop(item) {
|
|
2044
2169
|
if (item.params[i]) {
|
2045
2170
|
paramTypes[i] = item.params[i].type || type;
|
2046
2171
|
idents[i] = finalizeLLVMParameter(item.params[i]);
|
2047
|
-
if (
|
2172
|
+
if (needsQuoting(idents[i])) {
|
2048
2173
|
idents[i] = '(' + idents[i] + ')'; // we may have nested expressions. So enforce the order of operations we want
|
2049
2174
|
}
|
2050
2175
|
} else {
|
@@ -2091,7 +2216,13 @@ function processMathop(item) {
|
|
2091
2216
|
// If this is in legalization mode, steal the assign and assign into two vars
|
2092
2217
|
if (legalizedI64s) {
|
2093
2218
|
assert(item.assignTo);
|
2094
|
-
|
2219
|
+
if (ASM_JS) {
|
2220
|
+
var ret = item.assignTo + '$0=' + result[0] + ';' + item.assignTo + '$1=' + result[1] + ';';
|
2221
|
+
addVariable(item.assignTo + '$0', 'i32');
|
2222
|
+
addVariable(item.assignTo + '$1', 'i32');
|
2223
|
+
} else {
|
2224
|
+
var ret = 'var ' + item.assignTo + '$0=' + result[0] + ';var ' + item.assignTo + '$1=' + result[1] + ';';
|
2225
|
+
}
|
2095
2226
|
item.assignTo = null;
|
2096
2227
|
return ret;
|
2097
2228
|
} else {
|
@@ -2229,6 +2360,34 @@ function processMathop(item) {
|
|
2229
2360
|
}
|
2230
2361
|
}
|
2231
2362
|
|
2363
|
+
if (type[0] === '<' && type[type.length-1] !== '*') {
|
2364
|
+
// vector/SIMD operation
|
2365
|
+
Types.usesSIMD = true;
|
2366
|
+
switch (op) {
|
2367
|
+
case 'fadd': return 'SIMD.add(' + idents[0] + ',' + idents[1] + ')';
|
2368
|
+
case 'fsub': return 'SIMD.sub(' + idents[0] + ',' + idents[1] + ')';
|
2369
|
+
case 'fmul': return 'SIMD.mul(' + idents[0] + ',' + idents[1] + ')';
|
2370
|
+
case 'fdiv': return 'SIMD.div(' + idents[0] + ',' + idents[1] + ')';
|
2371
|
+
case 'add' : return 'SIMD.addu32(' + idents[0] + ',' + idents[1] + ')';
|
2372
|
+
case 'sub' : return 'SIMD.subu32(' + idents[0] + ',' + idents[1] + ')';
|
2373
|
+
case 'mul' : return 'SIMD.mulu32(' + idents[0] + ',' + idents[1] + ')';
|
2374
|
+
case 'udiv': return 'SIMD.divu32(' + idents[0] + ',' + idents[1] + ')';
|
2375
|
+
case 'bitcast': {
|
2376
|
+
var inType = item.params[0].type;
|
2377
|
+
var outType = item.type;
|
2378
|
+
if (inType === '<4 x float>') {
|
2379
|
+
assert(outType === '<4 x i32>');
|
2380
|
+
return 'SIMD.float32x4BitsToUint32x4(' + idents[0] + ')';
|
2381
|
+
} else {
|
2382
|
+
assert(inType === '<4 x i32>');
|
2383
|
+
assert(outType === '<4 x float>');
|
2384
|
+
return 'SIMD.uint32x4BitsToFloat32x4(' + idents[0] + ')';
|
2385
|
+
}
|
2386
|
+
}
|
2387
|
+
default: throw 'vector op todo: ' + dump(item);
|
2388
|
+
}
|
2389
|
+
}
|
2390
|
+
|
2232
2391
|
switch (op) {
|
2233
2392
|
// basic integer ops
|
2234
2393
|
case 'add': return handleOverflow(getFastValue(idents[0], '+', idents[1], item.type), bits);
|
@@ -2242,7 +2401,7 @@ function processMathop(item) {
|
|
2242
2401
|
dprint('Warning: 64 bit OR - precision limit may be hit on llvm line ' + item.lineNum);
|
2243
2402
|
return 'Runtime.or64(' + idents[0] + ', ' + idents[1] + ')';
|
2244
2403
|
}
|
2245
|
-
return idents[0] + '
|
2404
|
+
return idents[0] + '|' + idents[1];
|
2246
2405
|
}
|
2247
2406
|
case 'and': {
|
2248
2407
|
if (bits > 32) {
|
@@ -2250,7 +2409,7 @@ function processMathop(item) {
|
|
2250
2409
|
dprint('Warning: 64 bit AND - precision limit may be hit on llvm line ' + item.lineNum);
|
2251
2410
|
return 'Runtime.and64(' + idents[0] + ', ' + idents[1] + ')';
|
2252
2411
|
}
|
2253
|
-
return idents[0] + '
|
2412
|
+
return idents[0] + '&' + idents[1];
|
2254
2413
|
}
|
2255
2414
|
case 'xor': {
|
2256
2415
|
if (bits > 32) {
|
@@ -2258,28 +2417,28 @@ function processMathop(item) {
|
|
2258
2417
|
dprint('Warning: 64 bit XOR - precision limit may be hit on llvm line ' + item.lineNum);
|
2259
2418
|
return 'Runtime.xor64(' + idents[0] + ', ' + idents[1] + ')';
|
2260
2419
|
}
|
2261
|
-
return idents[0] + '
|
2420
|
+
return idents[0] + '^' + idents[1];
|
2262
2421
|
}
|
2263
2422
|
case 'shl': {
|
2264
2423
|
if (bits > 32) return idents[0] + '*' + getFastValue(2, 'pow', idents[1]);
|
2265
|
-
return idents[0] + '
|
2424
|
+
return idents[0] + '<<' + idents[1];
|
2266
2425
|
}
|
2267
2426
|
case 'ashr': {
|
2268
2427
|
if (bits > 32) return integerizeBignum(idents[0] + '/' + getFastValue(2, 'pow', idents[1]));
|
2269
|
-
if (bits === 32) return originalIdents[0] + '
|
2270
|
-
return idents[0] + '
|
2428
|
+
if (bits === 32) return originalIdents[0] + '>>' + idents[1]; // No need to reSign in this case
|
2429
|
+
return idents[0] + '>>' + idents[1];
|
2271
2430
|
}
|
2272
2431
|
case 'lshr': {
|
2273
2432
|
if (bits > 32) return integerizeBignum(idents[0] + '/' + getFastValue(2, 'pow', idents[1]));
|
2274
|
-
if (bits === 32) return originalIdents[0] + '
|
2275
|
-
return idents[0] + '
|
2433
|
+
if (bits === 32) return originalIdents[0] + '>>>' + idents[1]; // No need to unSign in this case
|
2434
|
+
return idents[0] + '>>>' + idents[1];
|
2276
2435
|
}
|
2277
2436
|
// basic float ops
|
2278
|
-
case 'fadd': return getFastValue(idents[0], '+', idents[1], item.type);
|
2279
|
-
case 'fsub': return getFastValue(idents[0], '-', idents[1], item.type);
|
2280
|
-
case 'fdiv': return getFastValue(idents[0], '/', idents[1], item.type);
|
2281
|
-
case 'fmul': return getFastValue(idents[0], '*', idents[1], item.type);
|
2282
|
-
case 'frem': return getFastValue(idents[0], '%', idents[1], item.type);
|
2437
|
+
case 'fadd': return makeFloat(getFastValue(idents[0], '+', idents[1], item.type), item.type);
|
2438
|
+
case 'fsub': return makeFloat(getFastValue(idents[0], '-', idents[1], item.type), item.type);
|
2439
|
+
case 'fdiv': return makeFloat(getFastValue(idents[0], '/', idents[1], item.type), item.type);
|
2440
|
+
case 'fmul': return makeFloat(getFastValue(idents[0], '*', idents[1], item.type), item.type);
|
2441
|
+
case 'frem': return makeFloat(getFastValue(idents[0], '%', idents[1], item.type), item.type);
|
2283
2442
|
case 'uitofp': case 'sitofp': return asmCoercion(idents[0], 'double', op[0]);
|
2284
2443
|
case 'fptoui': case 'fptosi': return makeRounding(idents[0], bitsLeft, op === 'fptosi', true);
|
2285
2444
|
|
@@ -2287,10 +2446,10 @@ function processMathop(item) {
|
|
2287
2446
|
// Note that with typed arrays, these become 0 when written. So that is a potential difference with non-typed array runs.
|
2288
2447
|
case 'icmp': {
|
2289
2448
|
switch (variant) {
|
2290
|
-
case 'uge': case 'sge': return idents[0] + '
|
2291
|
-
case 'ule': case 'sle': return idents[0] + '
|
2292
|
-
case 'ugt': case 'sgt': return idents[0] + '
|
2293
|
-
case 'ult': case 'slt': return idents[0] + '
|
2449
|
+
case 'uge': case 'sge': return idents[0] + '>=' + idents[1];
|
2450
|
+
case 'ule': case 'sle': return idents[0] + '<=' + idents[1];
|
2451
|
+
case 'ugt': case 'sgt': return idents[0] + '>' + idents[1];
|
2452
|
+
case 'ult': case 'slt': return idents[0] + '<' + idents[1];
|
2294
2453
|
// We use loose comparisons, which allows false == 0 to be true, etc. Ditto in fcmp
|
2295
2454
|
case 'ne': case 'eq': {
|
2296
2455
|
// We must sign them, so we do not compare -1 to 255 (could have unsigned them both too)
|
@@ -2306,14 +2465,14 @@ function processMathop(item) {
|
|
2306
2465
|
switch (variant) {
|
2307
2466
|
// TODO 'o' ones should be 'ordered (no NaN) and',
|
2308
2467
|
// 'u' ones should be 'unordered or'.
|
2309
|
-
case 'uge': case 'oge': return idents[0] + '
|
2310
|
-
case 'ule': case 'ole': return idents[0] + '
|
2311
|
-
case 'ugt': case 'ogt': return idents[0] + '
|
2312
|
-
case 'ult': case 'olt': return idents[0] + '
|
2313
|
-
case 'une': case 'one': return idents[0] + '
|
2314
|
-
case 'ueq': case 'oeq': return idents[0] + '
|
2315
|
-
case 'ord': return '!' + makeIsNaN(idents[0]) + '
|
2316
|
-
case 'uno': return makeIsNaN(idents[0]) + '
|
2468
|
+
case 'uge': case 'oge': return idents[0] + '>=' + idents[1];
|
2469
|
+
case 'ule': case 'ole': return idents[0] + '<=' + idents[1];
|
2470
|
+
case 'ugt': case 'ogt': return idents[0] + '>' + idents[1];
|
2471
|
+
case 'ult': case 'olt': return idents[0] + '<' + idents[1];
|
2472
|
+
case 'une': case 'one': return idents[0] + '!=' + idents[1];
|
2473
|
+
case 'ueq': case 'oeq': return idents[0] + '==' + idents[1];
|
2474
|
+
case 'ord': return '!' + makeIsNaN(idents[0]) + '&!' + makeIsNaN(idents[1]);
|
2475
|
+
case 'uno': return makeIsNaN(idents[0]) + '|' + makeIsNaN(idents[1]);
|
2317
2476
|
case 'true': return '1';
|
2318
2477
|
default: throw 'Unknown fcmp variant: ' + variant;
|
2319
2478
|
}
|
@@ -2329,7 +2488,7 @@ function processMathop(item) {
|
|
2329
2488
|
}
|
2330
2489
|
case 'fpext': case 'sext': return idents[0];
|
2331
2490
|
case 'fptrunc': return idents[0];
|
2332
|
-
case 'select': return idents[0] + '
|
2491
|
+
case 'select': return idents[0] + '?' + asmEnsureFloat(idents[1], item.type) + ':' + asmEnsureFloat(idents[2], item.type);
|
2333
2492
|
case 'ptrtoint': case 'inttoptr': {
|
2334
2493
|
var ret = '';
|
2335
2494
|
if (QUANTUM_SIZE == 1) {
|
@@ -2347,7 +2506,7 @@ function processMathop(item) {
|
|
2347
2506
|
// truncating can change the number, e.g. by truncating to an i1
|
2348
2507
|
// in order to get the first bit
|
2349
2508
|
assert(bitsLeft <= 32, 'Cannot truncate to more than 32 bits, since we use a native & op');
|
2350
|
-
return '((' + idents[0] + ')
|
2509
|
+
return '((' + idents[0] + ')&' + (Math.pow(2, bitsLeft)-1) + ')';
|
2351
2510
|
}
|
2352
2511
|
case 'bitcast': {
|
2353
2512
|
// Most bitcasts are no-ops for us. However, the exception is int to float and float to int
|
@@ -2385,13 +2544,6 @@ function walkInterdata(item, pre, post, obj) {
|
|
2385
2544
|
if (walkInterdata(item.params[i], pre, post, obj)) return true;
|
2386
2545
|
}
|
2387
2546
|
}
|
2388
|
-
if (item.possibleVars) { // other attributes that might contain interesting data; here, variables
|
2389
|
-
var box = { intertype: 'value', ident: '' };
|
2390
|
-
for (i = 0; i <= item.possibleVars.length; i++) {
|
2391
|
-
box.ident = item[item.possibleVars[i]];
|
2392
|
-
if (walkInterdata(box, pre, post, obj)) return true;
|
2393
|
-
}
|
2394
|
-
}
|
2395
2547
|
return post && post(item, originalObj, obj);
|
2396
2548
|
}
|
2397
2549
|
|
@@ -2411,11 +2563,10 @@ function walkAndModifyInterdata(item, pre) {
|
|
2411
2563
|
if (repl = walkAndModifyInterdata(item.params[i], pre)) item.params[i] = repl;
|
2412
2564
|
}
|
2413
2565
|
}
|
2414
|
-
// Ignore possibleVars because we can't replace them anyhow
|
2415
2566
|
}
|
2416
2567
|
|
2417
2568
|
function parseBlockAddress(segment) {
|
2418
|
-
return { intertype: 'blockaddress', func: toNiceIdent(segment[2].
|
2569
|
+
return { intertype: 'blockaddress', func: toNiceIdent(segment[2].tokens[0].text), label: toNiceIdent(segment[2].tokens[2].text), type: 'i32' };
|
2419
2570
|
}
|
2420
2571
|
|
2421
2572
|
function finalizeBlockAddress(param) {
|
@@ -2483,3 +2634,47 @@ function makePrintChars(s, sep) {
|
|
2483
2634
|
return ret;
|
2484
2635
|
}
|
2485
2636
|
|
2637
|
+
function parseAlign(text) { // parse ", align \d+"
|
2638
|
+
if (!text) return QUANTUM_SIZE;
|
2639
|
+
return parseInt(text.substr(8));
|
2640
|
+
}
|
2641
|
+
|
2642
|
+
function deParen(text) {
|
2643
|
+
if (text[0] === '(') return text.substr(1, text.length-2);
|
2644
|
+
return text;
|
2645
|
+
}
|
2646
|
+
|
2647
|
+
function deParenCarefully(text) {
|
2648
|
+
if (text[0] === '(' && text.indexOf('(', 1) < 0 && text[text.length-1] === ')') return text.substr(1, text.length-2);
|
2649
|
+
return text;
|
2650
|
+
}
|
2651
|
+
|
2652
|
+
function addVariable(ident, type, funcData) {
|
2653
|
+
funcData = funcData || Framework.currItem.funcData;
|
2654
|
+
assert(type);
|
2655
|
+
var old = funcData.variables[ident];
|
2656
|
+
if (old) {
|
2657
|
+
assert(old.type === type);
|
2658
|
+
} else {
|
2659
|
+
funcData.variables[ident] = {
|
2660
|
+
ident: ident,
|
2661
|
+
type: type,
|
2662
|
+
origin: 'added',
|
2663
|
+
lineNum: 0,
|
2664
|
+
rawLinesIndex: 0,
|
2665
|
+
hasValueTaken: false,
|
2666
|
+
pointingLevels: 0,
|
2667
|
+
uses: 0,
|
2668
|
+
impl: VAR_EMULATED
|
2669
|
+
};
|
2670
|
+
}
|
2671
|
+
}
|
2672
|
+
|
2673
|
+
var SIMDLane = ['X', 'Y', 'Z', 'W'];
|
2674
|
+
var simdLane = ['x', 'y', 'z', 'w'];
|
2675
|
+
|
2676
|
+
function ensureVector(ident, base) {
|
2677
|
+
Types.usesSIMD = true;
|
2678
|
+
return ident == 0 ? base + '32x4.zero()' : ident;
|
2679
|
+
}
|
2680
|
+
|